fix: wait for pending ACK callbacks in SolaceIO write finishBundle to prevent batch pipeline data loss [fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT] - #39664
Open
waterWang wants to merge 7 commits into
Conversation
…atch pipeline ACK coordination In batch pipelines, the SolaceIO write transform loses publish results because the pipeline finishes before asynchronous Solace ACK callbacks arrive. This change adds a pending-publish counter to PublishResultHandler so the writer can wait for in-flight ACKs before emitting results in finishBundle. Part of apache#39589.
… prevent batch pipeline data loss In batch pipelines, the @ontimer bundle_flusher may not fire before the pipeline ends, and the publishBatch ACK callbacks are asynchronous. finishBundle now tracks in-flight publishes via the pending count, waits for all ACKs to arrive, then emits the publish results. This prevents data loss when the pipeline ends before the timer or ACK callbacks complete. Part of apache#39589.
…to prevent batch pipeline data loss In batch pipelines, the asynchronous ACK callbacks from publishSingleMessage may not have arrived by the time finishBundle is called. This change tracks in-flight publishes via the pending count and waits for all ACKs to arrive before emitting publish results, preventing data loss when the pipeline ends before ACK callbacks complete. Part of apache#39589.
Contributor
|
Assigning reviewers: R: @chamikaramj added as fallback since no labels match configuration Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
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.
Description
Fixes #39589
Problem: In batch pipelines, the SolaceIO write transform loses publish results because the pipeline finishes before asynchronous Solace ACK callbacks arrive. The
@FinishBundlemethod callspublishResults()which drains thepublishedResultsQueue, but the ACK callbacks that populate the queue haven't fired yet, so the queue is empty and output is lost.Root cause: Both
UnboundedBatchedSolaceWriterandUnboundedStreamingSolaceWritercallpublishResults()in@FinishBundlewithout waiting for in-flight publish ACKs. The batched writer also relies on a@OnTimer("bundle_flusher")to "finalize" outputting publish results, but processing-time timers don't fire in batch pipelines before the pipeline ends.Fix: Track the number of in-flight publish operations using an
AtomicIntegercounter. The counter is incremented when a publish is sent and decremented when thePublishResultHandlerreceives the ACK callback. In@FinishBundle, the writer waits (with a 30-second timeout) for the counter to reach 0 before emitting results.Changes
PublishResultHandler.java: Accept anAtomicInteger pendingPublishCountin the constructor. Decrement it inprocessKey()when a publish result callback arrives.SessionService.java: Add abstract methodgetPendingPublishCount()returningAtomicInteger.JcsmpSessionService.java: AddAtomicInteger pendingPublishCountfield, implementgetPendingPublishCount(), pass it toPublishResultHandler.UnboundedSolaceWriter.java: AddincrementPendingPublishes(int count)andwaitForPendingPublishes()helper methods. The wait polls the counter with 50ms intervals up to a 30-second timeout, logging a warning if the timeout is exceeded.UnboundedBatchedSolaceWriter.java: InfinishBundle(), increment the pending count by the number of entries published in each batch, then callwaitForPendingPublishes()beforepublishResults(). Also add the wait influshBundle()(the timer handler) for consistency.UnboundedStreamingSolaceWriter.java: InprocessElement(), increment the pending count after each successfulpublishSingleMessage(). InfinishBundle(), callwaitForPendingPublishes()beforepublishResults().Testing
The existing unit tests cover the normal streaming and batched writer paths. The fix is exercised in batch pipeline mode where the
@FinishBundlewait ensures ACKs are processed before results are emitted. All existing tests should continue to pass since the wait is a no-op when there are no pending publishes.Wallet
Solana:
fj4WqyCCw3C5ShR1RfB7MoBPTpkRrBFYP1uT35g3MvT