You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cf78eca
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/design/2026-11-26-ticdc-traffic-metering.md
+10-2Lines changed: 10 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,8 +108,8 @@ The protocol operates as follows:
108
108
#### 3. Failure Recovery and Rolling Upgrade
109
109
110
110
-**Maintainer crash or migration (Coordinator alive)**: Coordinator retains `lastSeq` and `pendingBytes` in memory, and the new or migrated Maintainer inherits `(metering_epoch, lastSeq)` to realign with surviving `DispatcherManager` nodes. If the crash occurred before Coordinator accepted the round, DMs resend `sealedBytes` (zero loss); if it occurred after acceptance, the new Maintainer requests the next sequence and DMs discard the already-accepted snapshot and seal newly flushed traffic (zero double-counting).
111
-
-**DispatcherManager node crash or restart**: the restarted node starts from zero state and Maintainer removes the lost node from the active round. Events on the crashed node that were not yet confirmed at the checkpoint are resynchronized after rescheduling and metered normally upon confirmation, while at most the trailing unsealed/unacknowledged round (`~1s`) for already-confirmed events is discarded.
112
-
-**Transient object storage failures or object conflicts**: Coordinator retains in-memory `pendingBytes` without deducting it, merging it into the next whole-minute upload with zero loss.
111
+
-**DispatcherManager node crash or restart**: the restarted node starts from zero state and Maintainer removes the lost node from the active round. Events on the crashed node that were not yet confirmed at the checkpoint are resynchronized after rescheduling and metered normally upon confirmation, while the bytes flushed since that node's last seal, and any sealed snapshot the Maintainer has not yet received, are discarded; `defaultMeteringRoundInterval` delays the next round after an acknowledgment and does not bound how long a stalled round remains open.
112
+
-**Transient object storage failures or object conflicts**: Coordinator retains in-memory `pendingBytes` without deducting it; if a failed write already attempted storage `PUT` with an unknown outcome, Coordinator checks the object's existence before the next upload—committing the prior batch if persisted or merging it into the next whole-minute upload otherwise—guaranteeing zero loss and preventing cross-minute duplication.
113
113
-**Graceful shutdown, failover, and rolling upgrade**: before stepping down or exiting, Coordinator flushes unreported in-memory deltas to the next unused whole minute. The newly elected Coordinator holds a strictly greater `metering_epoch` and immediately advances sealing from sequence `1` of the new epoch across surviving `DispatcherManager` nodes without being blocked by prior `sealedSeq` values; any prior-term `sealedBytes` not yet absorbed before epoch switch—as well as the trailing unsealed round during changefeed deletion or close—are discarded on purpose rather than carried across epochs or blocking deletion, guaranteeing zero double-counting.
114
114
-**Unexpected Coordinator crash**: an abrupt process termination or host outage loses all unreported in-memory `pendingBytes` accumulated since the last successful upload (typically `< 60` seconds under healthy object storage, or the full unuploaded window during prolonged storage outages); the newly elected Coordinator resumes seamlessly with a higher `metering_epoch`.
115
115
-**Mixed-version rolling upgrade**: normal rolling upgrades upgrade the Coordinator node last. `DispatcherManager` nodes advertise metering capability during handshake and heartbeats; when advancing `metering_seq`, Maintainer waits only for capable nodes and skips un-upgraded nodes until they are upgraded and naturally join subsequent rounds.
@@ -188,3 +188,11 @@ During its term, Coordinator uploads per-minute **incremental traffic deltas** f
188
188
1.**Complete decoupling from protocols and sinks**: metering at the sink-agnostic event dispatching layer with event-level `PostFlush` confirmation avoids touching encoders or downstream SQL builders and remains invariant to batching and compression.
189
189
2.**Simple, accurate cross-node aggregation**: reusing existing heartbeats with `(metering_epoch, metering_seq)` achieves sealing and cumulative acknowledgment with zero new RPCs, avoiding double-counting and data loss while enabling fast failover recovery.
190
190
3.**Zero metadata intrusion and minimal storage cost**: pure in-memory aggregation combined with per-minute single-file delta uploads leaves etcd untouched, avoids metadata downgrade burdens, and keeps cluster-wide object storage writes down to one request per minute.
191
+
192
+
---
193
+
194
+
### Follow-up Work
195
+
196
+
-**Avoid re-submitting a batch whose previous upload may have succeeded.**`Reporter.write` returns success when a retry observes `ErrFileExists`, but if an earlier attempt stored the object and every later attempt fails before that check, `Report` returns an error and `reportAt` keeps the snapshot in `pendingBytes`; the next whole-minute upload then stores the same bytes under a later timestamp. Decide how a retry identifies the earlier batch, for example through the object path or payload, and whether an unprovable outcome favors duplicate counting or loss.
197
+
-**Clear `roundBytes` when an ACK advances `targetSeq`.**`meteringCollector.OnAck` sets `targetSeq = ackedSeq + 1` without clearing `roundBytes`. `meteringAccumulator.Accept` answers a stale sequence with the latest accepted sequence, so a Maintainer that starts from an older `MeteringLastSeq` can receive an ACK ahead of its target while `roundBytes` still holds entries recorded for the old target; the next completed round reuses those entries and the Coordinator counts the same bytes twice. Clear `roundBytes` and reset `roundStartedAt` whenever the ACK advances the target, and cover a stale `MeteringLastSeq` in a test.
198
+
-**State the shutdown flush guarantee.**`FlushOnShutdown` advances the timestamp only on `ErrFileExists`, stops on any other error, and gives up after five attempts within `meteringShutdownFlushTimeout`; when it stops, the buffered bytes are lost as the Coordinator exits. Either document the final flush as best-effort or keep retrying transient failures until the timeout.
0 commit comments