8000 fix: minimize deadlocks by joseph-sentry · Pull Request #869 · codecov/worker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on May 5, 2025. It is now read-only.

fix: minimize deadlocks #869

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tasks/test_results_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ def create_daily_total():
# Upsert Tests
if len(test_data) > 0:
test_insert = insert(Test.__table__).values(
sorted(test_data.values(), key=lambda x: str(x["flags_hash"]))
sorted(
test_data.values(),
key=lambda x: str(x["id"]),
)
)
insert_on_conflict_do_update = test_insert.on_conflict_do_update(
index_elements=["repoid", "name", "testsuite", "flags_hash"],
Expand All @@ -345,7 +348,7 @@ def create_daily_total():
},
)
db_session.execute(insert_on_conflict_do_update)
db_session.flush()
db_session.commit()

if len(test_flag_bridge_data):
insert_on_conflict_do_nothing_flags = (
Expand All @@ -354,7 +357,7 @@ def create_daily_total():
.on_conflict_do_nothing(index_elements=["test_id", "flag_id"])
)
db_session.execute(insert_on_conflict_do_nothing_flags)
db_session.flush()
db_session.commit()

# Upsert Daily Test Totals
if len(daily_totals) > 0:
Expand Down Expand Up @@ -389,15 +392,15 @@ def create_daily_total():
)

db_session.execute(stmt)
db_session.flush()
db_session.commit()

# Save TestInstances
if len(test_instance_data) > 0:
insert_test_instances = insert(TestInstance.__table__).values(
test_instance_data
)
db_session.execute(insert_test_instances)
db_session.flush()
db_session.commit()

def process_individual_upload(
self, db_session, repoid, commitid, upload_obj: Upload, flaky_test_set: set[str]
Expand Down
9 changes: 5 additions & 4 deletions tasks/tests/unit/test_test_results_processor_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ def test_test_result_processor_task_delete_archive(
assert len(test_instances) == 4
assert len(failures) == 1

assert (
tests[0].flags_hash
== "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
assert set([test.flags_hash for test in tests]) == {
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
}
assert set([test_instance.test.id for test_instance in test_instances]) == set(
[test.id_ for test in tests]
)
assert test_instances[0].test.id == tests[0].id
assert "Deleting uploaded file as requested" in caplog.text
with pytest.raises(FileNotInStorageError):
mock_storage.read_file("archive", url)
Expand Down
Loading
0