You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix the race in the persisted global downloads integration test #2953
The tracker-core integration test it_should_persist_the_global_number_of_completed_peers_into_the_database is flaky. It failed once during the maintainer's merge-script pre-push run of all tests on develop (while merging #2946, a docs-only PR):
The background event listener (increase_global_downloads in packages/tracker-core/src/statistics/event/handler.rs) awaits the database write of the global downloads count first, and only then increments the in-memory counter tracker_core_persisted_torrents_downloads_total. The test helper TestEnv::wait_for_global_downloads_persisted (packages/tracker-core/tests/common/test_env.rs) waits for the database value only. If the test reads the counter after the database write but before the increment, it reads 0.
The production code is correct: the counter counts downloads that were actually persisted, so it must follow the database write. Only the test's wait condition is wrong.
Reproduction
300 runs of the test alone and 100 runs of the whole integration binary on develop all passed: the window is very short.
A temporary 300 ms sleep between the database write and the counter increment reproduces the exact failure (integration.rs:253:5, left: 0, right: 1).
Proposed fix
Make wait_for_global_downloads_persisted wait, within its existing 5-second timeout, until both the database value and the in-memory counter reach the expected value. No production code changes. No other test has the same race (the spec lists every test that reads the counter and why it is safe).
Specification
Spec-first: docs/issues/open/<number>-fix-persisted-downloads-integration-test-race/ISSUE.md with issue-local manual-verification-evidence.md, added in a spec-only PR before the implementation PR.
Activity
docs(issues): [torrust#2953] plan a maintained regression test for th…
docs(issues): [torrust#2953] keep the design-review checkpoint for th…
docs(pr-reviews): [torrust#2953] audit review round 1 of PR 2954
docs(pr-reviews): [torrust#2953] audit review round 2 of PR 2954
docs(issues): [torrust#2953] state the at-least comparison of the wai…
docs(pr-reviews): [torrust#2953] audit review round 3 of PR 2954
docs(issues): [torrust#2953] name the test with the similar bounded-r…
docs(issues): [torrust#2953] record the review-round spec changes in …
docs(pr-reviews): [torrust#2953] state the basis of the inferred seve…
docs(pr-reviews): [torrust#2953] audit review round 4 of PR 2954
docs(pr-reviews): [torrust#2953] stamp the round-4 log entry at its l…
docs(pr-reviews): [torrust#2953] audit review round 5 of PR 2954
docs(pr-reviews): [torrust#2953] restore the round-4 stamp and append…
docs(pr-reviews): [torrust#2953] audit review round 6 of PR 2954
docs(issues): add issue specification for #2953
4 remaining items
docs(issues): [torrust#2953] record the recheck of the final wait helper
docs(pr-reviews): [torrust#2953] audit review round 1 of PR 2964
docs(issues): [torrust#2953] name the file the V7 probe-removal check…
docs(pr-reviews): [torrust#2953] audit review round 3 of PR 2964
docs(pr-reviews): [torrust#2953] fix the code span of the F10 verific…
docs(pr-reviews): [torrust#2953] audit review round 4 of PR 2964
test(tracker-core): [#2953] add regression tests for the persisted do…
fix(tracker-core): [#2953] wait for the in-memory persisted downloads…
docs(issues): [#2953] record the red, green and recheck evidence and …
Merge torrust#2964: fix(tracker-core): [torrust#2953] wait for the in…
chore(issues): [torrust#2953] tick the acceptance criteria of the arc…
docs(pr-reviews): [torrust#2953] audit review round 1 of PR 2970
chore(issues): archive closed issue #2953 spec to docs/issues/closed
Merge #2970: chore(issues): archive closed issue #2953 spec to docs/i…