GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [fix][client] Serialize chunked-message bookkeeping to fix use-after-free and count/queue drift by SongOf · Pull Request #26084 · apache/pulsar

[fix][client] Serialize chunked-message bookkeeping to fix use-after-free and count/queue drift #26084

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.

Sign up for GitHub

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
codelipenghui merged 15 commits into apache:master from SongOf:fix/client-chunked-message-bookkeeping-race
Oct 16, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

[fix][client] Serialize chunked-message bookkeeping to fix use-after-free and count/queue drift #26084

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
472efd8
[fix][client] Serialize chunked-message bookkeeping to fix use-after-…
song-of-bot Jun 24, 2026
3e4b95b
Merge branch 'master' into fix/client-chunked-message-bookkeeping-race
song-of-bot Jul 28, 2026
81f8ff7
Merge branch 'master' into fix/client-chunked-message-bookkeeping-race
lhotari Sep 18, 2026
60839af
Merge branch 'master' into fix/client-chunked-message-bookkeeping-race
lhotari Sep 19, 2026
82f814a
Merge remote-tracking branch 'apache/master' into fix/client-chunked-…
song-of-bot Sep 21, 2026
3a30fe4
[fix][client] Issue chunk acks outside chunkedMessageLock and release…
song-of-bot Sep 21, 2026
855c155
Merge remote-tracking branch 'origin/fix/client-chunked-message-bookk…
song-of-bot Sep 21, 2026
3b40ea1
[fix][test] Describe the ghost-head expiry test as a defensive invariant
song-of-bot Sep 21, 2026
d1b6a55
[fix][client] Issue acks queued under chunkedMessageLock even when ch…
song-of-bot Oct 13, 2026
30f2bbc
[fix][client] Release a malformed chunk's payload when appending it t…
song-of-bot Oct 15, 2026
9fe37e7
[improve][test] Stop the chunk race test's workers before teardown wh…
song-of-bot Oct 15, 2026
5835992
Merge remote-tracking branch 'apache/master' into fix/client-chunked-…
song-of-bot Oct 15, 2026
13d2033
[improve][test] Assert that chunk expiry cannot observe a half-remove…
song-of-bot Oct 15, 2026
704f024
Merge remote-tracking branch 'apache/master' into fix/client-chunked-…
codelipenghui Oct 15, 2026
96a4f72
Merge remote-tracking branch 'apache/master' into fix/client-chunked-…
codelipenghui Oct 15, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

30 changes: 17 additions & 13 deletions 30 pulsar-broker/src/test/java/org/apache/pulsar/client/impl/MessageChunkingTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -420,15 +421,15 @@ public void testExpirySkipsStaleQueueHeadFromDiscardPath() throws Exception {

/**
* Chunks are processed on the connection's IO thread while the expiry task runs on another thread.
* With queue [A, B], A's completion removes A's context and then A's uuid. If expiry inspects A in
* between (no context, so it skips A as a stale head) and only removes it after completion already
* did, it must remove A itself, not whatever is now at the head: dropping B would leave B's context
* in chunkedMessagesMap with nothing in the queue referencing it, so it could never expire or be
* evicted.
* With queue [A, B], A's completion removes A's context and then A's uuid. If expiry could inspect A in
* between (no context, so it skips A as a stale head) and only remove it after completion already did,
* it might drop whatever is now at the head: dropping B would leave B's context in chunkedMessagesMap
* with nothing in the queue referencing it, so it could never expire or be evicted.
*
* The interleaving is forced deterministically by wrapping chunkedMessagesMap: A's completion
* (map.remove("A") on the IO thread) starts expiry and waits until expiry has inspected A, and
* expiry (map.get("A")) then waits until completion has removed A's uuid before it continues.
* Completion and expiry both hold chunkedMessageLock, so expiry must not observe that intermediate
* state at all. The test wraps chunkedMessagesMap: A's completion (map.remove("A") on the IO thread,
* under the lock) starts expiry and waits until expiry either blocks or inspects A (map.get("A")),
* and inspecting A is a failure. Either way B must stay pending and reachable for expiry.
*/
@Test
public void testExpiryStaleHeadSkipDoesNotDropConcurrentLiveEntry() throws Exception {
Expand Down Expand Up @@ -461,6 +462,7 @@ public void testExpiryStaleHeadSkipDoesNotDropConcurrentLiveEntry() throws Excep

final CountDownLatch expiryInspectedA = new CountDownLatch(1);
final AtomicBoolean raceTriggered = new AtomicBoolean();
final AtomicBoolean expiryInspectedPartialRemoval = new AtomicBoolean();
final AtomicReference<Thread> expiryThread = new AtomicReference<>();
final AtomicReference<Throwable> expiryError = new AtomicReference<>();
Map<String, ConsumerImpl.ChunkedMessageCtx> hookedMap =
Expand All @@ -480,11 +482,11 @@ public ConsumerImpl.ChunkedMessageCtx remove(Object key) {
}, "test-chunk-expiry");
expiryThread.set(t);
t.start();
try {
expiryInspectedA.await(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
// Completion holds chunkedMessageLock here, so expiry has to block on it instead of
// inspecting A between A's map removal and its uuid removal.
Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() ->
t.getState() == Thread.State.BLOCKED || expiryInspectedA.getCount() == 0);
expiryInspectedPartialRemoval.set(expiryInspectedA.getCount() == 0);
}
return removed;
}
Expand Down Expand Up @@ -513,6 +515,8 @@ public ConsumerImpl.ChunkedMessageCtx get(Object key) {
assertEquals(a.getValue(), "chunk-A-0|chunk-A-1|");

assertTrue(raceTriggered.get(), "A's completion did not trigger the interleaving");
assertFalse(expiryInspectedPartialRemoval.get(),
"expiry inspected A after its context was removed but before its uuid was");
expiryThread.get().join(TimeUnit.SECONDS.toMillis(10));
assertNull(expiryError.get());

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.