-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix pipe drop event discard with restart-aware committer keys #17748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
|
|
||
| import org.apache.iotdb.commons.exception.pipe.PipeRuntimeException; | ||
| import org.apache.iotdb.commons.pipe.agent.task.connection.UnboundedBlockingPendingQueue; | ||
| import org.apache.iotdb.commons.pipe.agent.task.progress.CommitterKey; | ||
| import org.apache.iotdb.commons.pipe.agent.task.subtask.PipeAbstractSinkSubtask; | ||
| import org.apache.iotdb.commons.pipe.config.PipeConfig; | ||
| import org.apache.iotdb.commons.pipe.event.EnrichedEvent; | ||
|
|
@@ -201,10 +202,9 @@ public void close() { | |
| * When a pipe is dropped, the connector maybe reused and will not be closed. So we just discard | ||
| * its queued events in the output pipe connector. | ||
| */ | ||
| public void discardEventsOfPipe( | ||
| final String pipeNameToDrop, final long creationTimeToDrop, final int regionId) { | ||
| public void discardEventsOfPipe(final CommitterKey committerKey) { | ||
| // Try to remove the events as much as possible | ||
| inputPendingQueue.discardEventsOfPipe(pipeNameToDrop, creationTimeToDrop, regionId); | ||
| inputPendingQueue.discardEventsOfPipe(committerKey); | ||
|
|
||
| try { | ||
| increaseHighPriorityTaskCount(); | ||
|
|
@@ -217,9 +217,7 @@ public void discardEventsOfPipe( | |
| // use a new thread to stop all the pipes, we will not encounter deadlock here. Or else we | ||
| // will. | ||
| if (lastEvent instanceof EnrichedEvent | ||
| && pipeNameToDrop.equals(((EnrichedEvent) lastEvent).getPipeName()) | ||
| && creationTimeToDrop == ((EnrichedEvent) lastEvent).getCreationTime() | ||
| && regionId == ((EnrichedEvent) lastEvent).getRegionId()) { | ||
| && isEventFromPipe((EnrichedEvent) lastEvent, committerKey)) { | ||
| // Do not clear the last event's reference counts because it may be on transferring | ||
| lastEvent = null; | ||
| // Submit self to avoid that the lastEvent has been retried "max times" times and has | ||
|
|
@@ -241,9 +239,7 @@ public void discardEventsOfPipe( | |
| // clear the lastExceptionEvent. It's safe to potentially clear it twice because we have the | ||
| // "nonnull" detection. | ||
| if (lastExceptionEvent instanceof EnrichedEvent | ||
| && pipeNameToDrop.equals(((EnrichedEvent) lastExceptionEvent).getPipeName()) | ||
| && creationTimeToDrop == ((EnrichedEvent) lastExceptionEvent).getCreationTime() | ||
| && regionId == ((EnrichedEvent) lastExceptionEvent).getRegionId()) { | ||
| && isEventFromPipe((EnrichedEvent) lastExceptionEvent, committerKey)) { | ||
| clearReferenceCountAndReleaseLastExceptionEvent(); | ||
| } | ||
| } | ||
|
|
@@ -252,11 +248,18 @@ public void discardEventsOfPipe( | |
| } | ||
|
|
||
| if (outputPipeSink instanceof PipeConnectorWithEventDiscard) { | ||
| ((PipeConnectorWithEventDiscard) outputPipeSink) | ||
| .discardEventsOfPipe(pipeNameToDrop, creationTimeToDrop, regionId); | ||
| ((PipeConnectorWithEventDiscard) outputPipeSink).discardEventsOfPipe(committerKey); | ||
| } | ||
| } | ||
|
|
||
| private static boolean isEventFromPipe( | ||
| final EnrichedEvent event, final CommitterKey committerKey) { | ||
| return committerKey.getPipeName().equals(event.getPipeName()) | ||
| && committerKey.getCreationTime() == event.getCreationTime() | ||
| && committerKey.getRegionId() == event.getRegionId() | ||
| && (committerKey.getRestartTimes() < 0 || committerKey.equals(event.getCommitterKey())); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. restartTimes < 0 skips restart comparison for drop-all-restarts behavior. Consider a named constant (e.g. DROP_ALL_RESTARTS) instead of a magic -1, and add a test: drop pipe, recreate same name, verify new events are not discarded. |
||
| } | ||
|
|
||
| //////////////////////////// APIs provided for metric framework //////////////////////////// | ||
|
|
||
| public String getAttributeSortedString() { | ||
|
|
||
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
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop logic uses isEventFromDroppedPipe when possible, and falls back to isPipeDropped only when committerKey is null. Please document when committerKey can still be null at collection time; if that window is wide, the fallback could discard events for a recreated pipe with the same name and creationTime.