Skip to content

Conversation

@Savid
Copy link
Member

@Savid Savid commented Feb 4, 2026

Add verification that a block is still incomplete in ClickHouse before calling ReprocessBlock in gap detection. This closes a TOCTOU race window where a block could complete (MarkBlockComplete writes complete=1 and cleans up Redis tracking) between when gap detection queries ClickHouse and when it decides to reprocess.

Previously, gap detection only checked HasBlockTracking() which returns false after a block completes and Redis is cleaned up, causing already- complete blocks to be unnecessarily reprocessed.

  • Add IsBlockComplete() to state manager for fresh ClickHouse query
  • Add completion check in checkGaps() before ReprocessBlock call
  • Add unit test for race condition logic

Add verification that a block is still incomplete in ClickHouse before
calling ReprocessBlock in gap detection. This closes a TOCTOU race window
where a block could complete (MarkBlockComplete writes complete=1 and
cleans up Redis tracking) between when gap detection queries ClickHouse
and when it decides to reprocess.

Previously, gap detection only checked HasBlockTracking() which returns
false after a block completes and Redis is cleaned up, causing already-
complete blocks to be unnecessarily reprocessed.

- Add IsBlockComplete() to state manager for fresh ClickHouse query
- Add completion check in checkGaps() before ReprocessBlock call
- Add unit test for race condition logic
@Savid Savid closed this Feb 4, 2026
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