Repository navigation
fix(db): atomic record_event, safe orphan purge, RFC3339 retention cutoff - #352
Merged
Merged
Conversation
…toff (#332) - record_event upserts issue + inserts event in one transaction (both backends); digest uses it - purge_orphan_issues(days) only removes unresolved orphans with last_seen < cutoff - bind Rust-computed RFC3339 cutoff for events/auth_attempts purge on both backends Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #332
What
Database::record_event(SQLite + Postgres): issue upsert and event insert run in one transaction; the digest pipeline uses it, so a failed event insert no longer leaves a bumped issue count.purge_orphan_issues(days)now deletes only orphans that are not resolved/ignored and havelast_seenolder than the retention cutoff, in a single atomic statement (NOT EXISTS).datetime('now', ...)).Why
RFC3339
received_at(Tseparator) was compared againstdatetime('now')(space separator), skewing retention by up to a day. The orphan purge could delete a just-upserted issue before its event landed and discarded resolved/ignored history. Upsert + insert were separate statements.Deferred / notes: the transaction is per event rather than per batch, so one bad event does not discard the rest of a batch. Postgres changes compile and mirror SQLite but are not exercised by a live Postgres test here.
Testing
New SQLite tests (failing before the fix, passing after):
test_record_event_is_atomic,test_purge_old_events_cutoff_format,test_purge_stale_auth_attempts_cutoff_format,test_purge_orphan_issues_safety.cargo fmt --checkOK,cargo clippy --workspace --all-targets -- -D warningsclean,cargo test --workspaceall passing.🤖 Generated with Claude Code