Skip to content

id(event_store): release/present_proof flush expired-buffer rows in the same transaction (#2690) - #2895

Merged
dezren39 merged 1 commit into
mainfrom
queue/4100-2690-mirror-expired-flush
Oct 31, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/4100-2690-mirror-expired-flush

Conversation

@dezren39

@dezren39 dezren39 commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

#2690 — Mirror::release / present_proof flush expired-buffer rows in the same transaction

pool.arrived expires due events into the pool's expired buffer as a side effect, but only Mirror::expire deleted those events' rows. A transaction whose waiting-pool work was a release could commit with the pool and the rows disagreeing: the expired event gone from the pool, its row (and waiting_by_dep entries) still on disk, and its expiry reported by a later, unrelated expire_waiting — or dropped silently by the reload after a restart.

Fix (pkgs/id/src/event_store/waiting_rows.rs): release and present_proof now flush the expired buffer the way Mirror::expire does — a shared flush_expired drains pool.expire(now) and deletes the rows, in the releasing call's own transaction. In present_proof the flush runs before the park, so a held proof that was itself due is still re-held for good rather than deleted by the flush.

Tests (laptop, cargo test --lib flushes — both pass):

  • test_a_mirror_release_flushes_the_events_it_expires — mirror-level regression, driven through transact/hold/release directly (the ingest path's expire-first composition would mask a mirror that forgot the flush): the expired event's row is gone in the releasing transaction, expire_waiting afterwards counts 0.
  • test_a_release_flushes_the_events_it_expires — ingest-level: hold two events, release a dependency at the moment the other is due; pool, rows (waiting_ids) and the expiry count agree immediately after the releasing call.

CI: id-check.yml has no pull_request trigger, so it is dispatched manually on this branch (see the task checkpoint for the run link). Queue task 4100.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Expired waiting events are now removed consistently when dependencies are released or proofs are presented, preventing stale rows from remaining for later expiry processing.
    • Proofs due for expiry can still be re-held when presented.

…he same transaction (#2690)

Mirror::release and Mirror::present_proof call pool.arrived, which
expires due events into the pool expired buffer as a side effect --
but only Mirror::expire deleted those events rows. A transaction
whose waiting-pool work was a release could therefore commit with
the pool and the rows disagreeing, and the expiry was reported by a
later, unrelated expire (or dropped silently by the reload after a
restart).

Both methods now flush the expired buffer the way Mirror::expire
does (shared flush_expired): the releasing call itself deletes the
expired rows, in its own transaction. In present_proof the flush
runs before the park, so a held proof that was itself due is still
re-held for good rather than deleted.

Regression tests: test_a_mirror_release_flushes_the_events_it_expires
(mirror-level, driven through transact/hold/release directly) and
test_a_release_flushes_the_events_it_expires (ingest-level: pool,
rows and the expire count agree immediately after the releasing
call).
@dezren39
dezren39 requested a review from a team as a code owner October 31, 2026 01:15
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T01:18:01.607379Z 77d015d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0163bf55-76a3-470d-b0ca-75728521e39b
Commits

Reviewing files that changed from the base of the PR and between ffa8639 and 77d015d.

Files selected for processing: 2
  • pkgs/id/src/event_store/ingest.rs
  • pkgs/id/src/event_store/waiting_rows.rs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The mirror now deletes rows for events that expire during release or proof presentation. Two regression tests cover expiry during direct release and ingest-triggered release.

Changes: Waiting-event expiry

Layer / File(s) Summary
Flush expired waiting-event rows
pkgs/id/src/event_store/waiting_rows.rs
expire delegates expiration and row deletion to flush_expired. release and present_proof also delete rows for events expired by pool.arrived(now).
Verify expiry during release
pkgs/id/src/event_store/ingest.rs
Two tests verify that direct release and ingest-triggered release remove expired rows before a later expiry call.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • developing-today/code#2690: The issue describes row cleanup and expiry reporting during Mirror::release and Mirror::present_proof, which these changes address.
Merge Risk: Minimal · up to 77d01

The release-time cleanup has direct regression coverage. No concrete merge-blocking issue remains; the change is ready subject to normal checks.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately and specifically summarizes the main change: flushing expired-buffer rows during release and present_proof within the same transaction.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 2 files.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.0)

Clippy execution timed out

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dezren39
dezren39 merged commit a51aab2 into main Oct 31, 2026
20 of 30 checks passed
@dezren39
dezren39 deleted the queue/4100-2690-mirror-expired-flush branch October 31, 2026 01:48
@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · done (merged)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant