Repository navigation
fix(tracker-core): [#2953] wait for the in-memory persisted downloads counter in the integration test - #2964
Conversation
…sted downloads wait helper The new test that the wait keeps going while only the database holds the expected value fails against the current helper, which waits for the database alone. The fix follows in the next commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…wnloads counter in the test helper The event listener writes the global downloads to the database first and increments the in-memory persisted counter after that write, so waiting for the database alone let the integration test assert on the counter before the increment. The helper now waits for both values within its existing 5-second bound. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ce and the design review Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at ff3861c7481c2aaee528918e6ffc84af241d3719. Recomputed from the bytes at this head, against the merge base 1f85267e8; git merge-tree against develop 1829126a0 writes a tree with no conflict, and develop has not touched the four changed files since the merge base.
Process: a bug fix, so fix-bug governs, with write-unit-test for the new tests, create-issue for the spec, and commit-changes and open-pull-request for history and description. The required order holds: the regression tests land red first, the helper fix second, the evidence third, and PR-branch states are cited by subject.
The change against its claim: the listener awaits the database write and only then increments tracker_core_persisted_torrents_downloads_total (handler.rs:118-127), so the old helper could return while the counter still read 0; at 1f85267e8 line 253 of integration.rs is that assertion. The helper now polls both values with >= under its 5 s bound. At the test commit the pending test fails (the old helper returns once the database holds 1; the cited panic test_env.rs:387:9 is that commit's assert!) and it passes after the fix. No production code changes.
Consistency: the spec frontmatter keeps every required field with allowed values; no link is added; the integration binary is the only target that includes common (12 + 2 = 14 tests, matching the filtered counts in V3 and V4); the evidence's line references recompute.
Hygiene: Conventional subjects with [#2953]; author equals committer on all three; each commit carries one attribution footer, which no rule in the tree addresses; git diff --check is clean; the skill's PR-branch commit-id check prints nothing; the closing-keyword scan matches only Closes #2953 in the description and nothing in the title or the commit messages.
Findings: F1 and F2 Minor, F3 to F5 Nit, F6 Suggestion, inline. None blocks.
Checked, no finding: import order and the over-long function-header layout match existing formatter output in the tree; no item follows the test module; the pending test is deterministic (no listener, the counter stays 0); the two new fixture helpers are reached only from the new module, which every test build compiles; the spec's other-callers search still holds at this head.
Checks
On the loop's compute node at this head, against the merge base 1f85267e8 (receipt server-gates-kranich-1254): the repository's pre-commit gate and lint roster exit 0 (220 s wall). This PR carries no audit record of its own, so the gate ran no validator for it. In a fresh per-PR target directory, cargo test --workspace passes 4399 tests with 0 failed and 5 ignored across 129 binaries (346 s wall), and cargo clippy --workspace --all-targets --all-features -- -D warnings is clean (64 s wall). cargo deny check exits 5 with the same 35 license rejections and four advisories as recent runs on develop, so this pull request changes nothing in that result. F2 checked against the bytes at posting: V3's steps are stamped 09:17:50 and 09:18:00, while test(tracker-core): [#2953] add regression tests for the persisted downloads wait helper was committed at 09:18:28Z. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Publish (Development): completed/skipped; Publish (Release): completed/skipped; Context: completed/success; Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-core): completed/success; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility MySQL (8.0): completed/success; Database Compatibility MySQL (8.4): completed/success; Database Compatibility PostgreSQL (16): completed/success; Database Compatibility PostgreSQL (14): completed/success; Test (Docker) (release): completed/success; Persistence Benchmark MySQL: completed/success; Persistence Benchmark PostgreSQL: completed/success; Persistence Benchmark SQLite3: completed/success; Generate Coverage Report: completed/success; Discover Package Coverage: completed/success; Build on windows-latest (nightly): completed/success; Build on windows-latest (stable): completed/success; Build on macos-latest (nightly): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on macos-latest (stable): completed/success; Docs Lint: completed/success; Docker E2E: completed/skipped; Layer Boundary Bans: completed/success; Unit (stable): completed/success; Workspace Packaging: completed/success; Unit (nightly): completed/success; Shipped Features: completed/success; Documented Clippy Allows: completed/success". At posting, develop is 1829126a0.
…ersisted downloads wait Add a test where only the in-memory counter has reached the expected value: the wait must still be pending, so dropping the database half of the condition now fails a test. The test that expects the wait to finish gets its own 4-second bound, separate from the short bound of the tests that expect it to be pending. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
3 open issues
load_global_downloads()errors are currently treated the same as “not ready yet” (the match falls… · New The helper repeats a deep container/persistence access chain on every poll iteration. Hoisting… · New The opening brace placement/indentation here is inconsistent with standard Rust formatting and the… · New
What changed in this PR
Fixes a race in a tracker-core integration test by making the test helper wait for both the persisted DB value and the in-memory “persisted downloads” counter before assertions/restart logic.
Changes:
- Update
wait_for_global_downloads_persistedto wait for both DB and in-memory counter thresholds. - Add regression tests and small fixture helpers to validate the wait helper’s behavior (too-early return vs. waiting correctly).
- Update issue documentation/evidence to reflect red/green runs and review notes.
| File | Description |
|---|---|
| packages/tracker-core/tests/integration.rs | Clarifies the integration test’s waiting rationale (DB write happens before counter increment). |
| packages/tracker-core/tests/common/test_env.rs | Fixes the wait helper to wait on DB + counter; adds regression tests and fixture utilities. |
| docs/issues/open/2953-fix-persisted-downloads-integration-test-race/manual-verification-evidence.md | Records updated verification evidence (V3/V4/V5) and outcomes. |
| docs/issues/open/2953-fix-persisted-downloads-integration-test-race/ISSUE.md | Updates issue status/progress, tasks, and acceptance criteria evidence links. |
Review effort: Lite
…the evidence Co-Authored-By: Claude Opus 5.5 <[email protected]>
…at once on a database error A database error was treated as "not persisted yet" and only surfaced as the 5-second timeout. The helper now fails with the error, and it looks up the metrics store and the stats repository once, before the poll loop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 278fefc25afc6990e3c74ca1679ba51348c2235f. Recomputed from the bytes at this head, against the merge base 1f85267e8; git merge-tree against develop 1829126a0 writes a tree with no conflict, and develop has not touched any of the five changed files.
Process: this round reads ff3861c74..278fefc25, five commits on a fast-forward, under fix-bug, write-unit-test and process-pr-review.
The change against its claim:
8a52bd0e9adds the counter-only test and gives the finishing test its own 4 s bound. A fresh database holds no global row (it is created on the first increment,downloads.rs:137), so the new comment is accurate.4bfa036bdlooks the store and repository up once and fails at once on a database error. Its success condition is unchanged, and V7 repeats the clause mutations at the shiftedassert!lines.- The F1 mutation I proposed could not compile under the
unuseddeny; V6 records that. 278fefc25adds the audit record, with nine rows: F1 to F6 for round 1 and F7 to F9 for the automated reviewer. Each row's reply is on its own thread, and each thread is resolved. The sections the template copies verbatim are identical to it. The processing log is in order and states that the three automated-reviewer threads were resolved early, reopened, then answered and resolved.
Validator: the logic of validate-audit-record.py, run offline against the captured review comments and the branch's eight commits, reports ok, with 9 rows, 4 log entries and 0 failures.
Earlier findings: F1 to F6 are fixed (F5 in the description). The description now lists all eight commits.
Hygiene: subjects are Conventional with [#2953], and author equals committer. Each commit has one attribution footer, which no rule in the tree addresses. git diff --check is clean, the commit-id check prints nothing, and only Closes #2953 matches the closing-keyword scan.
Findings: none.
Checked, no finding:
- V5 still cites
WAIT_LIMIT, which is correct for the state it records. - The helper's database-error
expectis undocumented, like theunwrapcalls in the file's other store helpers. - The audit commit's subject says round 1, while the record covers both reviews; the description explains this.
Checks
On the loop's compute node at this head, against the merge base 1f85267e8 (receipt server-gates-kranich-1261): the repository's pre-commit gate and lint roster exit 0 (58 s wall), and the audit validator passes this pull request's record (9 rows, 4 log entries, 0 failures). The code is unchanged since 28cd07d16, where cargo test --workspace in the PR's target directory passes 4400 tests with 0 failed and 5 ignored across 129 binaries (82 s wall, receipt server-gates-kranich-1260) and cargo clippy --workspace --all-targets --all-features -- -D warnings is clean. Checked against the bytes at posting: docs/pr-reviews/pr-2964-review/PR-REVIEW.md has nine finding rows at this head, which is the validator's row count. The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage Regression: completed/success; Package Coverage (torrust-tracker-core): completed/success; Docker E2E: completed/skipped; Unit (nightly): in_progress/pending; Unit (stable): in_progress/pending; Documented Clippy Allows: completed/success; Workspace Packaging: completed/success; Layer Boundary Bans: completed/success; Shipped Features: completed/success; Test (Docker) (release): in_progress/pending; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility MySQL (8.4): completed/success; Database Compatibility PostgreSQL (14): completed/success; Database Compatibility PostgreSQL (16): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility MySQL (8.0): completed/success; Generate Coverage Report: in_progress/pending; Discover Package Coverage: completed/success; Persistence Benchmark SQLite3: completed/success; Persistence Benchmark MySQL: completed/success; Persistence Benchmark PostgreSQL: completed/success; Docs Lint: completed/success; Build on macos-latest (nightly): completed/success; Build on macos-latest (stable): completed/success; Build on windows-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (nightly): completed/success". At posting, develop is 1829126a0.
… covers Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
ACK d34b1b9 |
|
ACK fad7e06 |
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at fad7e069310e597f73f5718d2a27ffb1ed2931b4. Recomputed from the bytes at this head, against the merge base 1f85267e8; git merge-tree against develop 36b24a9c5 writes a tree with no conflict, and develop has not touched the PR's paths since the merge base.
Process: this round reads 278fefc25..fad7e0693, two commits on a fast-forward, and the forge record since the round-2 review: one automated review with one thread ([Nit][F10]), its reply, its resolution and its audit row.
The change against its claim:
d34b1b9efscopes V7 step 3's revert check tohandler.rs, with the same commands as V2 and V4. It says why: thetest_env.rschange was still uncommitted, so the earlier unscopedgit diff --quiet HEADcould not have exited 0.fad7e0693adds the F10 row (author class as before,Nit,documentation,FIXED,RESOLVED), its details and a fifth log entry. The source review, the reply and the times match the capture.
Audit and validator: there are ten rows for ten threads. Each reply is on its own thread, and each thread is resolved. Every bracketed severity equals its row. The verbatim template sections are unchanged. The validator's logic, run offline against the captured comments and the ten commits, reports ok, with 10 rows, 5 log entries and 0 failures. The description lists all ten commits.
Hygiene: the subjects are Conventional with [#2953], and author equals committer. Each commit has one attribution footer, which no rule in the tree addresses. git diff --check is clean, the commit-id check prints nothing, and only Closes #2953 matches the closing-keyword scan.
Findings: F12 (Nit), inline. It is non-blocking: it is a rendering defect in the record, and it was raised after the head's last audit commit. F10 is the automated reviewer's ID, and F11 was a draft of mine that was closed before it was posted, so numbering starts at F12.
Checked, no finding: F1 to F9 are unchanged; the F10 grep claim holds, because no evidence line still has the unscoped form.
Checks
On the loop's compute node at this head, against the merge base 1f85267e8 (receipt server-gates-kranich-1268): the repository's pre-commit gate and lint roster exit 0 (157 s wall), and the audit validator passes this pull request's record (10 rows, 5 log entries, 0 failures). The commits since the last approved head change documentation only; the code is unchanged since 28cd07d16, where cargo test --workspace passed 4400 tests with 0 failed and clippy was clean (receipt server-gates-kranich-1260). Checked against the bytes at posting: the record has ten finding rows at this head, which is the validator's row count, and line 192 carries nine backticks, so its code spans cannot pair (F12). The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (torrust-tracker-core): in_progress/pending; Docker E2E: completed/skipped; Shipped Features: completed/success; Documented Clippy Allows: completed/success; Unit (stable): in_progress/pending; Layer Boundary Bans: completed/success; Unit (nightly): in_progress/pending; Workspace Packaging: completed/success; Test (Docker) (release): in_progress/pending; Persistence Benchmark SQLite3: completed/success; Persistence Benchmark MySQL: completed/success; Persistence Benchmark PostgreSQL: completed/success; Docs Lint: completed/success; Database Compatibility PostgreSQL (14): completed/success; Database Compatibility MySQL (8.4): completed/success; Database Compatibility PostgreSQL (16): completed/success; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility MySQL (8.0): completed/success; Generate Coverage Report: in_progress/pending; Discover Package Coverage: completed/success; Build on windows-latest (nightly): in_progress/pending; Build on macos-latest (nightly): completed/success; Build on ubuntu-latest (nightly): completed/success; Build on windows-latest (stable): completed/success; Build on ubuntu-latest (stable): completed/success; Build on macos-latest (stable): completed/success". At posting, develop is 36b24a9c5.
…ation command Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
da2ce7
left a comment
There was a problem hiding this comment.
Reviewed at 68117cb3d5a43dce7a327003166d3ce4f1bf1788. Recomputed from the bytes at this head, against the merge base 1f85267e8; git merge-tree against develop 36b24a9c5 writes a tree with no conflict, and develop has not touched the PR's paths since the merge base.
Process: this round reads fad7e0693..68117cb3d, two commits on a fast-forward, and the forge record since the round-3 review: the reply to and resolution of the F12 thread, its audit row, and an automated review with no new thread.
The change against its claim:
de6034e2eputs the F10 verification command in a double-backtick span. Paired by backtick-run length, line 192 now has four spans, the third holding the whole command, and no run is left over.68117cb3dadds a Round 4 paragraph, the F12 row (Human,Nitas bracketed,formatting,FIXED,RESOLVED), its details and a sixth log entry, and bumpslast-updated-utc. The source review, the reply on the F12 thread, the resolution subject and the logged times match the capture and the branch.
Audit and validator: there are eleven rows for eleven threads. Each reply is on its own thread, and each thread is resolved. Every bracketed severity equals its row, and the verbatim template sections are unchanged. The validator's logic, run offline against the captured comments and the twelve commits, reports ok, with 11 rows, 6 log entries and 0 failures. The description lists exactly the twelve commits.
Hygiene: the subjects are Conventional with [#2953], and author equals committer. Each commit has one attribution footer, which no rule in the tree addresses. git diff --check is clean, the commit-id check prints nothing, and only Closes #2953 matches the closing-keyword scan.
Findings: none. F1 to F10 and F12 are fixed or answered and recorded. F11 was a draft ID that was never posted.
Checked, no finding: the code is unchanged since 28cd07d16, and no thread was opened after the round-4 audit commit.
Checks
On the loop's compute node at this head, against the merge base 1f85267e8 (receipt server-gates-kranich-1272): the repository's pre-commit gate and lint roster exit 0 (44 s wall), and the audit validator passes this pull request's record (11 rows, 6 log entries, 0 failures). The commits since the last approved head change documentation only; the code is unchanged since 28cd07d16, where cargo test --workspace passed 4400 tests with 0 failed and clippy was clean (receipt server-gates-kranich-1260). Checked against the bytes at posting: the record has eleven finding rows at this head, including the F12 row (Nit, FIXED, RESOLVED). The head was confirmed with git ls-remote before posting. GitHub checks at this head at posting time: "Package Coverage (torrust-tracker-core): in_progress/pending; Docker E2E: completed/skipped; Unit (stable): queued/pending; Layer Boundary Bans: queued/pending; Documented Clippy Allows: queued/pending; Unit (nightly): in_progress/pending; Workspace Packaging: in_progress/pending; Shipped Features: in_progress/pending; Test (Docker) (release): in_progress/pending; Persistence Benchmark PostgreSQL: in_progress/pending; Persistence Benchmark MySQL: in_progress/pending; Persistence Benchmark SQLite3: in_progress/pending; Generate Coverage Report: in_progress/pending; Discover Package Coverage: completed/success; Docs Lint: completed/success; Build on ubuntu-latest (nightly): completed/success; Build on windows-latest (stable): in_progress/pending; Build on macos-latest (nightly): completed/success; Build on windows-latest (nightly): in_progress/pending; Build on ubuntu-latest (stable): in_progress/pending; Build on macos-latest (stable): in_progress/pending; Database Compatibility MySQL (8.0): in_progress/pending; Database Compatibility PostgreSQL (17): completed/success; Database Compatibility PostgreSQL (16): in_progress/pending; Database Compatibility PostgreSQL (14): in_progress/pending; Database Compatibility PostgreSQL (15): completed/success; Database Compatibility MySQL (8.4): in_progress/pending". At posting, develop is 36b24a9c5.
|
ACK 68117cb |
…ssues/closed 222b894 docs(pr-reviews): [#2953] audit review round 1 of PR 2970 (josecelano-bot) 3e2aaec chore(issues): [#2953] tick the acceptance criteria of the archived spec (josecelano-bot) ef7484f chore(issues): archive closed issue #2953 spec to docs/issues/closed (josecelano-bot) Pull request description: ## Summary Archives the spec for issue #2953 from `docs/issues/open/` to `docs/issues/closed/`, following the `cleanup-completed-issues` skill. The issue was closed by the merge of #2964 (merge commit `f7e8c4660`); the spec-only PR was #2954. Related to #2953 ## Changes - Moved `docs/issues/open/2953-fix-persisted-downloads-integration-test-race/` to `docs/issues/closed/`. - `ISSUE.md`: `status: done`, the new `spec-path`, `related-pr: 2964`, `last-updated-utc`, the "committer verified" and "issue closed and spec moved" checkpoints ticked, and a progress-log entry for the archival. - `manual-verification-evidence.md`: `issue-spec` points at the new path. After review round 1 (`chore(issues): [#2953] tick the acceptance criteria of the archived spec`), all eleven acceptance criteria are ticked from the recorded evidence, with a progress-log correction; the reviewer checkpoints stay unticked. The review audit is in `docs/pr-reviews/pr-2970-review/`. A repository search for the folder name finds no live reference to the old path; the one remaining mention is a past progress-log entry, kept as history. ## Validation - Verified issue #2953 is `CLOSED` on GitHub. - `git diff --cached --check` clean; pre-commit and pre-push hooks pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) ACKs for top commit: josecelano: ACK 222b894 Tree-SHA512: 6a9b7f97de6dd8f28264266eef89094e397b7918f1903c38965411d7facb48c983d99a95ff396de403da89b44dba07424ac57a5c2c412f2dea83f2551eb2d542


Summary
Fixes the race in the tracker-core integration test
it_should_persist_the_global_number_of_completed_peers_into_the_database, which failed once withleft: 0, right: 1atintegration.rs:253during the maintainer's merge-script pre-push run (merge of #2946). Implements the spec merged in #2954.Closes #2953
The test helper
TestEnv::wait_for_global_downloads_persistedwaited for the database value only. The event listener writes the database first and increments the in-memorytracker_core_persisted_torrents_downloads_totalcounter after that write, so the test could assert on the counter in between. The helper now waits for both values (each at leastexpected) within its existing 5-second bound. No production code changes.Commits
test(tracker-core): [#2953] add regression tests for the persisted downloads wait helper: two tests of the helper inpackages/tracker-core/tests/common/test_env.rs, with no listener running, plus two fixture helpers (persist_global_downloads,increment_persisted_downloads_counter). The test that the wait keeps going while only the database holds the expected value fails against the old helper; at this commit the branch is red on purpose.fix(tracker-core): [#2953] wait for the in-memory persisted downloads counter in the test helper: the helper fix, the updated comment inintegration.rs, and a one-line Arrange comment in the first new test stating that the in-memory counter stays at 0 (added in the design review, V5).docs(issues): [#2953] record the red, green and recheck evidence and the design review: V3 (red), V4 (green and like-for-like recheck) and V5 (design review) in the issue'smanual-verification-evidence.md, and the spec progress.test(tracker-core): [#2953] guard the database clause of the persisted downloads wait(review round 1): a third helper test, where only the in-memory counter has reached the expected value, so each clause of the wait condition has a test that fails when it is removed; the test that expects the wait to finish gets its own 4-second bound.docs(issues): [#2953] record the clause mutations and correct the evidence(review round 1): V6 (one mutation per clause, each failing exactly one test), corrected V3 initial state and V4 timing explanation, and the spec progress.test(tracker-core): [#2953] fail the persisted downloads wait at once on a database error(review round 2): a database error now fails the wait at once with its cause instead of showing up as the timeout, and the store and repository are looked up once before the poll loop.docs(issues): [#2953] record the recheck of the final wait helper(review round 2): V7, the tests, clause mutations, probe and plain runs repeated on the final helper.docs(pr-reviews): [#2953] audit review round 1 of PR 2964: the review audit indocs/pr-reviews/pr-2964-review/. Despite its subject, it records both rounds: da2ce7's review (F1 to F6) and Copilot's review (F7 to F9).docs(issues): [#2953] name the file the V7 probe-removal check covers(review round 3): V7 now records the exact probe-removal check, which was limited tohandler.rs.docs(pr-reviews): [#2953] audit review round 3 of PR 2964: F10 in the audit.docs(pr-reviews): [#2953] fix the code span of the F10 verification command(review round 4): a rendering fix in the audit.docs(pr-reviews): [#2953] audit review round 4 of PR 2964: F12 in the audit.Changes from the spec
The spec planned one helper test in two parts. It is two tests, so each has one reason to fail: one fails if the helper stops too early (the bug), the other if it waits too long. The maintainer reviewed and approved this design before the recheck (V5). Review round 1 added a third test for the database clause (V6).
Validation
cargo test -p torrust-tracker-core(187 passed before round 1; the integration binary now has 15 tests, all passing),linter all,cargo machete --with-metadataand the pre-commit and pre-push hooks pass.🤖 Generated with Claude Code