Skip to content

Prevent stale raw-data archive links - #3228

Open
Freika wants to merge 1 commit into
devfrom
fix/raw-data-archive-flag-race
Open

Prevent stale raw-data archive links#3228
Freika wants to merge 1 commit into
devfrom
fix/raw-data-archive-flag-race

Conversation

@Freika

@Freika Freika commented Jul 25, 2026

Copy link
Copy Markdown
Owner

Production signal

Root cause

The archiver compressed a raw-data snapshot, then unconditionally linked point rows after upload and verification. A concurrent tracker upsert in that interval could change a point before it was linked to the stale snapshot.

Fix

  • Record a checksum for every raw-data snapshot while compressing
  • Row-lock flagging batches in conflict-key order and link only rows whose current raw data still matches
  • Retry transient database contention while flagging
  • Leave changed rows eligible for a later archive pass using the current snapshot
  • Restore/cache only snapshots still linked to their source archive, with database rows locked through restore
  • Namespace temporary recovery cache entries by archive so detached/relinked points cannot read stale snapshots
  • Report actual linked counts in stats and metrics

Verification

  • asdf exec bundle exec rspec spec/models/concerns/archivable_spec.rb spec/services/points/raw_data/chunk_compressor_spec.rb spec/services/points/raw_data/archiver_spec.rb spec/services/points/raw_data/restorer_spec.rb — 80 examples, 0 failures
  • asdf exec bundle exec rubocop app/models/concerns/archivable.rb app/services/points/raw_data/chunk_compressor.rb app/services/points/raw_data/archiver.rb app/services/points/raw_data/restorer.rb spec/models/concerns/archivable_spec.rb spec/services/points/raw_data/chunk_compressor_spec.rb spec/services/points/raw_data/archiver_spec.rb spec/services/points/raw_data/restorer_spec.rb — 8 files, no offenses
  • git diff --check — passed

Existing legacy stale links still require an explicitly approved backup-first repair procedure. No production data mutation is included.

Review status

REQUEST_CHANGES — do not merge yet. Stable-head engineering and QA review still find lock-order deadlock risk: PostgreSQL geography ordering differs from ingestion's normalized numeric longitude/latitude order, and restore retains locks across independently ordered batches without contention retry. The two permitted fix/re-review cycles were exhausted.

GitHub writes: none.

- Prevent stale raw-data archive links
- fix: align raw data archive lock ordering
- test: document resumable raw data restores
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9cd1270c-34bf-4a98-8f2e-36a763e49068

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/raw-data-archive-flag-race

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.

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