[Pipe] Add reliable DataNode completion metric - #18563
Open
Caideyipi wants to merge 1 commit into
Open
Conversation
7 tasks
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.
Pipe Completion Metric Design
1. Conclusion
This implementation retains the complete end-to-end barrier protocol from Apache IoTDB PR #18280 and adds expected-DataRegion integrity checks on the current branch.
The new metric is:
The metric has exactly two possible values,
0and1:1: On this sender DataNode, the latest full-FLUSH completion barrier for every DataRegion currently expected by this Pipe has passed through the source, processor, and sink, and has been committed in order after a successful sink ACK. There are no pending non-heartbeat events, and no changes have been detected in task, source, assigner, committer, exception, or degraded state.0: The operation is incomplete, unsupported, unknown, affected by a race, or failed a health check. The value0does not distinguish among these reasons.The design deliberately allows temporary false negatives but never false positives. The existing
remaining_event_countremains a progress metric: a value of0is necessary for completion, but it is not sufficient proof that sending has completed.2. Why
remaining_event_countcannot simply include "waiting for flush" and "captured TsFile"A smaller implementation could add the storage engine's processors waiting to close, captured TsFiles, and Pipe queues together, but that would provide only an approximate backlog and could not reliably prove that sending had completed.
2.1 State transitions create counting gaps
The same TsFile goes through:
If these structures are read and summed separately, an object moving between two structures may temporarily belong to neither of the snapshots that have been read, producing a transient
0. Adding more containers only narrows the window; it cannot eliminate a cross-component snapshot race.2.2 An empty queue does not mean that the sink has confirmed receipt
After an event is taken from the sink queue and before the destination returns a successful ACK, the queue may already be empty. At that point,
remaining_event_count == 0still does not prove that the destination has received or loaded the data.2.3 FLUSH and concurrent writes have a boundary race
After a full FLUSH starts, a concurrent insert may create a new working processor that is not included in the capture set for that FLUSH. Sending all older TsFiles therefore does not mean that the current round of writes is complete. Every full FLUSH must establish a token, and a concurrent insert must invalidate that token.
2.4 Lifecycle changes can make old state report completion incorrectly
If a Pipe task, realtime source, assigner, or committer is replaced, state committed by the old instance cannot prove that the new instance is complete. If task initialization fails and a DataRegion is missing, the absence of a local task must not be interpreted as completion.
Therefore, if the goal is only an approximate backlog, a small change to
remaining_event_countis sufficient. If the goal is to determine reliably that a Pipe has finished sending, an end-to-end ordered barrier is required. The main purpose of #18280 is to close the false-positive windows described above; retaining only one of its counting points would not be sufficient.3. Completion barrier flow
The key point is that the barrier is ordered after the TsFile events captured and published by this FLUSH. A DataRegion is marked complete only after the sink has successfully processed the barrier and the ordered commit has completed.
4. Fail-closed conditions
The metric returns
0if any of the following conditions holds:remaining_event_countstill contains a non-heartbeat event;Lost events and publication failures cannot be automatically proven to have recovered. The metric therefore remains
0; the usual recovery is to fix the problem, restart or rebuild the relevant Pipe tasks, and execute the completion protocol again.5. Supported scope
Currently, only the following combinations can return
1:iotdb-extractororiotdb-source;do-nothing-processor;sync;This metric does not currently prove that SchemaRegion/DDL operations have completed, and it provides no completion guarantee for custom processors, custom sinks, or asynchronous TsFile load strategies. These combinations conservatively return
0.6. Correct use of the protocol
0.FLUSHcovering every DataRegion that the Pipe may send. A global full FLUSH is recommended. Do not use a partial flush that closes onlySEQorUNSEQprocessors as the completion barrier.1.In a Prometheus deployment, also confirm that:
up == 1;creation_timedistinguishes different incarnations of a Pipe with the same name. The evaluation must be pinned to the exactname + creation_timefor this incarnation; do not aggregate old series bynamealone.7. Relationship to PR #18280 and adaptation on the current branch
This implementation adopts the core commit
12bc3f3a5c00265f5c04dc28a4e6c76affe326bffrom #18280 ([Pipe] Add reliable DataNode completion metric). The complete implementation includes:The current branch additionally reuses the expected-DataRegion calculation already present in master and requires:
This prevents a false positive when a DataRegion task fails to initialize or is missing, which could otherwise make an empty or incomplete local task set look complete.
8. Validation results
test-compilefor the relevant modules: passed;test-compile: 52/52 passed;test-compile: 52/52 passed; andgit diff --check: passed.The focused tests cover completion generation, fail-closed behavior, membership changes, source replacement, committer replacement, barriers not being merged with heartbeats, event-collection failure, inserts invalidating a flush token, and overlap between a full FLUSH and an ordinary asynchronous flush.