GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||
GeezerVison is showing github.com — [fix][broker] Handle synchronous schema lookup failures in replication by Denovo1998 · Pull Request #26108 · apache/pulsar Conversation
|
|
Thanks for the update. The main concerns look addressed. One small follow-up: after this path calls |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I added a guard in readEntriesComplete() to skip the outer readMoreEntries() while the replicator is already waiting for cursor rewind. This leaves the scheduled doRewindCursor(true) as the path that resumes reads. I also updated the regression test to exercise readEntriesComplete() end-to-end and verify no extra read is triggered before the scheduled rewind runs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for addressing the comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I ran an AI-assisted review of this PR (combined Claude Fable 5 + OpenAI Codex gpt-5.6-sol review; findings merged and verified against the code). Overall the fix looks real and correctly targeted: getSchemaInfo() is a Guava LoadingCache.get() call that throws ExecutionException synchronously, and in current master that throw lands in the outer catch (Exception) after headersAndPayload.retain() — leaking the retained buffer, the entry, the MessageImpl and the in-flight permit, with the cursor neither rewound nor resumed. Routing the failure into the existing isCompletedExceptionally() skip-path reuses the proven cleanup + rewind machinery, and the new readEntriesComplete() guard properly defers read resumption to the scheduled doRewindCursor(true).
Findings, in decreasing severity:
Catching only ExecutionException leaves the same leak for unchecked synchronous failures (GeoPersistentReplicator.replicateEntries). Guava's LoadingCache.get() also throws UncheckedExecutionException (loader threw a RuntimeException) and ExecutionError, and getSchemaByVersion() can throw unchecked synchronously. Any of those still escape to the outer catch (Exception e), which only logs — reproducing exactly the failure mode this PR sets out to fix. Suggest broadening to catch (Exception e), or cleaner: move the try/catch into getSchemaInfo() so it returns a failed future and drop throws ExecutionException (a CompletableFuture-returning method shouldn't throw synchronously; GeoPersistentReplicator is its only caller and ShadowReplicator doesn't use it, so the signature change is contained).
The regression test self-repairs the leak it's meant to detect (GeoPersistentReplicatorTest, the finally block). The loop releasing headersAndPayload until refCnt() == 0 means the test would still pass if the production path forgot headersAndPayload.release(). Suggest asserting assertThat(headersAndPayload.refCnt()).isZero() right after the verifications, before any fallback cleanup. If finding 1 is addressed, please also add a companion test injecting an unchecked exception (e.g. UncheckedExecutionException), which the current test cannot cover.
Two behavior changes are not reflected in the PR description. The diff also (a) adds a MESSAGE_RATE_BACKOFF_MS (1s) delay before doRewindCursor(true) for all schema-fetch failures, including asynchronous ones — previously an async failure rewound immediately, so a persistently failing schema fetch could hot-loop read → fail → rewind → re-read; and (b) replaces the old 1s scheduled-retry polling from readEntriesComplete() with an explicit hand-off to the scheduled rewind. Both are good changes, but the description/commit message should state them — especially with the release/4.0.13 and release/4.2.4 labels, since backporters need the full behavioral delta (and should verify those branches have the InFlightTask/waitForCursorRewindingRefCnf structure this patch assumes).
Minor: the new debug log in readEntriesComplete() reads reasonOfWaitForCursorRewinding, which is non-volatile and written under the inFlightTasks lock, so the log line can print a stale or null reason. Harmless (log-only), just confirming it's intentional.
Minor: the scheduled rewind is fire-and-forget — if the broker executor rejects the task at shutdown, the exception is swallowed inside whenComplete and waitForCursorRewindingRefCnf never decrements, stalling that replicator until unload. This matches the existing idiom in readMoreEntries(), so it's acceptable as-is.
Concurrency was checked independently by both reviews and no race was found in the new guard: (a) for Fetching_Schema, resume is deterministically owned by doRewindCursor(true) (immediate on success, backoff-scheduled on failure), and if the rewind wins the race against the guard, the fallthrough readMoreEntries() safely no-ops on hasPendingRead(); (b) for the Failed_Publishing transient window (refcount briefly > 0 between beforeTerminateOrCursorRewinding and doRewindCursor(false) on the producer thread), resumption is still guaranteed because the same sendComplete continues on its thread and its queue-drain logic calls readMoreEntries() after the refcount is back to 0; (c) Terminating is handled by the earlier state check in readEntriesComplete().
Sorry, something went wrong.
There was an error while loading. Please reload this page.
@lhotari |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Dropping approval while checking for possible race conditions.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the follow-up — this is what I was asking for.
a6b5d111 drops the waitForCursorRewindingRefCnf branch from readEntriesComplete(), so readMoreEntries() is now the single place that consults the rewind state, and it does so at PersistentReplicator.java:310 inside synchronized (inFlightTasks). Falling through to readMoreEntries() is safe precisely because that method re-checks under the lock and self-skips. Dropping the readMoreEntries() override in the test is a real improvement too: the test now drives the actual read-scheduling path and asserts the externally observable behavior (cursor.asyncReadEntriesOrWait(...) never before the rewind, exactly once after) rather than an internal call count.
I checked the CompletableFuture contract on this path end to end, since that is the part that matters most here:
getSchemaInfo() now has its entire body inside the try, so there is no statement left that can throw before a future exists.ExecutionException | RuntimeException | ExecutionError catch list is an exact match for Guava's documented LoadingCache.get(K) contract (checked → ExecutionException, unchecked → UncheckedExecutionException, error → ExecutionError), and both caches on this path are Guava LoadingCaches — PulsarClientImpl.schemaProviderLoadingCache (PulsarClientImpl.java:200) and the per-topic cache inside MultiVersionSchemaInfoProvider. It deliberately does not swallow bare Error, which is right.log.warn().exception(e) at GeoPersistentReplicator.java:282-285.skipRemainingMessages guarantees at most one beforeTerminateOrCursorRewinding() per replicateEntries() call, and both whenComplete branches reach doRewindCursor(true) exactly once, so a persistently failing lookup settles into a ~1s retry cycle and recovers if the lookup ever succeeds — it does not strand the replicator. The added backoff also removes what was previously an unthrottled rewind→read→fail loop on the failure path.I ran the new test locally and also re-ran it with only the getSchemaInfo() change reverted, to confirm it actually pins the fix:
./gradlew :pulsar-broker:test --tests 'org.apache.pulsar.broker.service.persistent.GeoPersistentReplicatorTest' -PexcludedTestGroups=''
At a6b5d111: 3 tests, 0 failures. With getSchemaInfo() reverted to the throwing version: fails at GeoPersistentReplicatorTest.java:95 with expected: 2 but was: 0 — the in-flight permits are never released. That is the bug, reproduced.
Two non-blocking notes, plus one small logging nit inline:
Pulsar CI and Pulsar CI Flaky on a6b5d111 are sitting at action_required since 2026-08-03, so there are zero check runs on the head commit. That is the workflow-approval gate for contributor PRs, not anything you did wrong — I need to approve the runs. I would rather see a green CI before approving a change in the replication read path, so I am leaving this as a comment for now.readMoreEntries() call while waiting for cursor rewind, leaving doRewindCursor(true) responsible for resuming reads") now describes the code that a6b5d111 removed. Since we squash-merge the description into the commit message, it is worth updating that bullet before merge.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…n[fix][broker] Handle synchronous schema lookup failures in replication
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update. The last commit only touches the log lines. The retry log is now at DEBUG and the WARN text says it will retry after backoff. Scheduling, delay and cursor rewind are unchanged. One optional wording nit remains in the thread. The branch also has merge conflicts with master now, so it needs an update from master before merging.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for merging master and for keeping the fix small. The remaining change is getSchemaInfo() turning a synchronous lookup failure into a failed future, and the rewind and retry path handles it. The new tests cover the three failure types and the buffer release. The last open thread is about logging that this branch no longer changes. See my reply there.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Modified, PTAL. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for taking the optional logging follow-up here. The new commit moves the "Resume the data replication" INFO line into the success branch, so a failed schema fetch no longer claims to resume. The failure path still calls delayReadRetry() before doRewindCursor(false), so the retry behavior is unchanged. Nothing else changed since the last review apart from the master merge.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
#26108) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 43e0d58)
#26108) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 43e0d58)
apache#26108) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 43e0d58)
apache#26108) Co-authored-by: Lari Hotari <[email protected]> (cherry picked from commit 43e0d58)
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.