Skip to content

Tolerate interior fs_events seq holes in EventBus gap detection#754

Open
mornyx wants to merge 1 commit into
mainfrom
feat/fs-events-gap-tolerance
Open

Tolerate interior fs_events seq holes in EventBus gap detection#754
mornyx wants to merge 1 commit into
mainfrom
feat/fs-events-gap-tolerance

Conversation

@mornyx

@mornyx mornyx commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

EventBus.EventsSince previously treated any seq hole between the client cursor and the first returned event as "events were pruned" and forced a client reset:

if since+1 < firstSeq { return nil, headSeq, false }

That assumption is wrong in two cases:

  1. Shared-schema fs_events tables (one table serving many tenants): other tenants' interleaved seqs make per-tenant holes the norm — every poll would detect a "gap" and reset continuously (reset storm).
  2. Standalone tables: rolled-back inserts burn AUTO_INCREMENT ids, creating the same benign interior holes.

Pruning only ever happens at the left edge of the retained window, so a gap is now a reset condition only when the cursor falls behind the oldest retained seq (since+1 < oldest) — identical semantics as before for actual pruning, and interior holes are delivered through. The no-rows branch already used exactly this comparison; this PR makes the got-rows branch consistent with it and updates the doc comment.

This is a prerequisite for moving fs_events onto shared (fs_id-keyed) tables.

Test plan

  • go test ./pkg/server/ -run 'TestEventBus' -count=1 -v — all pass
  • New TestEventBusEventsSinceInteriorGapDelivers: burned middle seq → delivered, no reset (previously would have reset)
  • New TestEventBusEventsSincePrunedGapResets: left-edge pruning past the cursor → still resets
  • bin/golangci-lint run ./pkg/server/... — 0 issues

EventsSince previously reset the client whenever since+1 < first returned
seq, treating any hole as pruned events. That assumption breaks on a
shared-schema fs_events table, where other tenants' interleaved seqs make
interior holes the norm and would cause a continuous reset storm; rolled
back inserts also burn AUTO_INCREMENT ids and create the same benign
holes on standalone tables.

Pruning only ever happens at the left edge of the retained window, so a
gap now triggers a reset only when the cursor falls behind the oldest
retained seq (since+1 < oldest). Interior holes are delivered through.
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@mornyx, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 50 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ed0cf82-15c6-4cb7-9fec-097d9482b6f6

📥 Commits

Reviewing files that changed from the base of the PR and between bfd070e and a0976cd.

📒 Files selected for processing (2)
  • pkg/server/eventbus.go
  • pkg/server/eventbus_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/fs-events-gap-tolerance

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