Repository navigation
[issue #1357][producer] fix: allow multiples callbacks with concurrent producer flushes (async publish) - #1409
Merged
crossoverJie merged 4 commits intoAug 27, 2025
Conversation
… to prevent deadlock
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a deadlock issue that occurs when multiple concurrent flush operations are performed on the same producer with async publishing. The solution changes the callback mechanism from a single callback to a list of callbacks to ensure all waiting flush requests are properly notified.
- Change single flush callback to a list of callbacks in pendingItem struct
- Update flush handling logic to append and iterate through multiple callbacks
- Add comprehensive test for concurrent flush scenarios
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pulsar/producer_partition.go | Core fix - changes single flushCallback to flushCallbacks slice and updates callback handling |
| pulsar/producer_test.go | Adds new test TestConcurrentFlushInProducer to validate the fix |
| pulsaradmin/pkg/admin/subscription_test.go | Updates test to use FlushWithCtx instead of deprecated Flush method |
| pulsar/consumer_test.go | Updates tests to use FlushWithCtx instead of deprecated Flush method |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
thomas-bousquet
force-pushed
the
fix/async-producer-concurrent-flushes
branch
from
August 26, 2025 03:18
c17a338 to
c6b5705
Compare
lhotari
reviewed
Aug 26, 2025
lhotari
approved these changes
Aug 26, 2025
lhotari
left a comment
Member
There was a problem hiding this comment.
LGTM, thanks for the contribution
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.
Fixes #1357
Motivation
When flushing concurrently with the same producer, the producer potentially creates a deadlock when the callback is only called once but the client waits for the flush request to be done in all
FlushWithCtx().Modifications
Change the callback function for to a list of callbacks.
Verifying this change
Testcase
TestConcurrentFlushInProduceradded in the producer test suite.