Repository navigation
feat: detect events dropped by sql-tapd and treat reports with drops as incomplete - #45
Conversation
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
|
Copilot could not review this PR (insufficient quota), so it was reviewed locally with Claude Code's Fixed in 13bdbf8 (
The broker now signals a per-subscription Fixed in db8bd23 (
Not addressed
|
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Summary
sql-tapd's broker drops events for a subscriber whose buffer is full, so that a slow client never blocks the proxy. Until now this was silent: a
runor-cireport could miss events and still look complete, anddiffwould read the missing statements as an improvement. This PR counts the drops per subscription, sends the count to clients, and makes reports with drops incomplete.Changes
feat(broker): count dropped events per subscriptionBroker.Subscribereturns aSubscription(Events,Dropped(),Close()) instead of a channel and an unsubscribe function. Each subscription counts its own drops with anatomic.Uint64.serverandwebare updated; their behavior is unchanged.build: pin buf remote plugin versionsbuf.gen.yamlpinsprotocolbuffers/go:v1.36.11andgrpc/go:v1.6.1, the versions the checked-in code was generated with, so regenerating does not churngen/. Regenerating without proto changes produces no diff.feat(proto): report dropped events in WatchResponseuint64 dropped_events = 2: the cumulative number of events dropped for this subscription.feat(server): send the subscription's dropped count with each eventWatchResponsecarriessub.Dropped()at send time.Watchcan drain the queue betweenPublishseeing a full buffer and incrementing the count, so no later event carries it. See the fix below.feat(ci): report dropped events and refuse them in diffResult.DroppedEvents/ JSONdropped_events(omitted when zero) keep the latest cumulative count, in bothci.Run(-ci) andWatcher.Collect(run). The text report shows aDropped:line.diffrefuses a report with dropped events like an incomplete one (exit 2). This also covers-cireports, which are not markedincomplete.feat: mark run reports with dropped events incomplete and warn in -cirunmarks the report incomplete and exits 2 when events were dropped. The command's own failure still takes priority.-ciprints a warning but keeps its exit code, as with the zero-statement warning, so existing CI jobs are not affected.fix: report drops to clients as they happen instead of with the next eventDropschannel after incrementing the count, so a reader of the signal always sees the new count.WatchRequest.report_drops: when set, the server sends an event-lessWatchResponse{dropped_events}as soon as a drop happens.ci(runand-ci) sets it and skips event-less responses when counting. TUI and Web do not set it, so every response they receive still carries an event.report_dropsnever receives an event-less response.fix(broker): make the zero Subscription safe to useDropped()andClose()on a zeroSubscriptionno longer panic.Older sql-tapd does not send
dropped_events, which reads as zero, i.e. the previous behavior. See the review comment for the local review that found these issues.Verification
go test -race ./...passesgolangci-lint run ./...: 0 issuesbuf lintpasses;buf generatewith the pinned plugins only adds the new fields