Skip to content

fix(audit): make delivery durable and tenant-fair - #7146

Draft
TheSentinel454 wants to merge 1 commit into
mainfrom
codex/audit-outbox-fairness
Draft

fix(audit): make delivery durable and tenant-fair#7146
TheSentinel454 wants to merge 1 commit into
mainfrom
codex/audit-outbox-fairness

Conversation

@TheSentinel454

Copy link
Copy Markdown
Contributor

Why

The follow-up review on #6229 identified audit-delivery gaps under database timeouts, tenant contention, and worker teardown. In particular, a supported statement_timeout could lose an audit entry, one busy community could monopolize the bounded queue, and the idle-transaction test did not prove that PostgreSQL actually terminated and replaced the backend.

What

  • replace the in-memory audit channel with a durable, per-community ordered outbox
  • retain logical delivery keys so producer retries deduplicate both pending and delivered audit entries
  • retry PostgreSQL lock and statement timeouts without blocking unrelated communities
  • bound shutdown, abort timed-out workers, and resume durable work after restart
  • fail closed when an event or media audit intent cannot be persisted
  • add regression coverage for lock/statement timeouts, 1,001-item saturation, cross-community progress, cancellation, restart recovery, logical deduplication, and real idle-transaction backend replacement
  • update the stale event-handler retry comment

Risk Assessment

Medium. This adds two community-scoped tables and changes audit delivery from process memory to PostgreSQL. The migration and deletion manifests are covered by schema tests, and the delivery path is protected by transactional enqueue/deduplication, per-community ordering, advisory locking, bounded retry backoff, and restart tests.

Verification

  • cargo clippy -p buzz-db -p buzz-audit -p buzz-relay --all-targets -- -D warnings
  • cargo test -p buzz-db --lib
  • cargo test -p buzz-audit
  • cargo test -p buzz-audit -- --ignored --nocapture --test-threads=1
  • cargo test -p buzz-relay --lib
  • ignored PostgreSQL idle-transaction replacement and fresh-migration tests
  • repository pre-push hooks

References

Generated with Codex

Signed-off-by: Luke Tornquist <tornquist@squareup.com>
@github-actions

Copy link
Copy Markdown

🔐 Codex Security Review

Status: review required for the current range.

The current range is cb3144999bebc4939cb15b2200b373281d493b52...8c1b636d4473d15fef7516deb7e054d2e64c5e5e.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review 8c1b636d4473d15fef7516deb7e054d2e64c5e5e to authorize a new review.
Any previous review applies only to its recorded range.

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