Repository navigation
sqllog: test poll batch fullness against pollBatchSize - #763
Merged
Merged
Conversation
The poll loop decides whether to re-query immediately or wait on notify/the ticker by comparing the batch it just read against a hardcoded 100, while the query itself is limited to pollBatchSize (--poll-batch-size, default 500). The two have never been tied together -- c7dd89e introduced the literal 100 in the same commit that set the limit to 500. Since After() returns one event per row and stops at the limit, len(events) < limit means the query drained everything available at that revision. Comparing against anything other than the limit makes the test mean something else: - At the default 500, a burst of 100-499 events is a fully drained batch that reads as "not full", so the loop immediately re-issues the same 500-row After query and finds nothing. - Below 100, a completely full batch always reads as "not full", so the loop waits between batches instead of draining. Clearing a backlog of N revisions then takes up to N/pollBatchSize seconds of watch lag, turning the knob into a latency cliff. This only affects when the loop sleeps, never which events it emits. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Manuel Rüger <manuel@rueg.eu>
Member
|
c7dd89e is early Darren code and as such has very little supporting it to help us understand if the batch size and wait-for-more threshold are intentionally different... and I don't think the current behavior is WRONG so much as just maybe slightly sub-optimal... so, sure, let's align the two. |
brandond
approved these changes
Sep 8, 2026
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.
Problem
pkg/logstructured/sqllog/sql.go:532:The poll loop uses this to decide whether to re-query immediately or wait on
notify/the 1s ticker. But the query it just ran is limited tos.pollBatchSize—--poll-batch-size, default 500 — and the two values have never been connected.c7dd89e("Select rows to trigger in batches of 500") introduced the literal100in the same commit that set the limit to500, so this is an original inconsistency rather than drift; the later change that made 500 configurable just widened the gap.After()returns one event per row and stops at the limit, solen(events) < limitis exactly the condition "this query drained everything available at that revision". Comparing against any other number makes the test mean something else, in both directions:After ... LIMIT 500query and finds nothing. One wasted round trip per burst.N / pollBatchSizeseconds of watch lag — lowering the knob to reduce per-poll cost silently turns it into a latency cliff.Every other consumer of the knob is already correct:
app.go→endpoint.go→drivers/config.go→ each driver'ssqllog.New(...)→ the SQLLIMIT. Only this comparison was left on a literal.Solution
Risk
This only affects when the loop sleeps, never which events it emits or in what order — the sequential-revision logic below it is untouched.
The one path worth checking is the revision-gap break, which discards the rest of the batch without advancing
pollRevision. That case is unaffected: it sendss.notify <- nextwithnext > pollRevision, so the select wakes and re-queries immediately regardless of whatwaitForMorewas set to.At the default of 500 the only behavioral difference is that batches of 100-499 stop triggering a redundant requery; full batches still re-query immediately, exactly as before.
Verification
go build ./...andgo test -tags=test ./...pass.🤖 Generated with Claude Code