ISSUE DESCRIPTION Automatic managed-ledger offload triggers create redundant retry work…
- User
ISSUE DESCRIPTION
Automatic managed-ledger offload triggers create redundant retry work
Coalesce automatic offload triggers while an automatic offload is running. There must be at most one active automatic run and at most one follow-up run when additional triggers arrive. A follow-up must still process newly eligible ledgers, and explicit/manual offload futures must retain their existing behavior.
Interface
No new public interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /pulsar, current file: none) bash-$
- Assistant
I'll start by exploring the repository structure and finding the managed-ledger offload related code.
- Assistant
I'll search the managed-ledger module for automatic offload trigger logic.
- Assistant
Let me read the offload-related methods in ManagedLedgerImpl.
- Assistant
The mutex retry schedule is the problem — I'll read the rest of the offload flow and find related fields.
- Assistant
Let me also look at how offloadMutex is used and locations where maybeOffloadInBackground is called, as well as the asyncOffloadPrefix methods for manual offloads.
- Assistant
Let me read the asyncOffloadPrefix method and also look at related tests. Also let me check git log/blame and any recent PRs about this.
- Assistant
Let me continue reading the asyncOffloadPrefix lock handling
- Assistant
I'll look for similar mutex/coalesce patterns and inspect the fields around
offloadMutex. - Assistant
I'll check whether trim or similar background work already coalesces triggers, and inspect offload tests for expected behavior.
- Assistant
Let me check all call sites of maybeOffloadInBackground and how promises are used.
- Assistant
I'll inspect how OffloadLedgerDeleteTest waits on offload completion.
- Assistant
I'll check the git history and any related comments or uncommitted changes for this work.
- Assistant
I'll review CallbackMutex and any related open branches or issue notes.
- Assistant
I have a clear approach. I'll check existing imports and implement the coalescing state machine.
- Assistant
I'll add the AtomicIntegerFieldUpdater import and the auto-offload coalescing state fields.
- Assistant
Now add the fields near offloadMutex.
- Assistant
I'll open the file at the offloadMutex field and apply the edit.
- Assistant
Now I can do the replace.
- Assistant
Now I'll update maybeOffloadInBackground and maybeOffload.
- Assistant
I'll replace the maybeOffloadInBackground and maybeOffload methods with the coalescing version.
- Assistant
Let me verify the full maybeOffload method looks correct after our changes.
- Assistant
I need to verify OffloadPolicies import is present.
- Assistant
I'll keep mutex-retry work on the managed-ledger executor for ordering consistency.
- Assistant
I'll compile the managed-ledger module and run the offload-related tests.
- Assistant
Compilation succeeded. Running the offload-related unit tests next.
- Assistant
I'll confirm the test results more explicitly.
- Assistant
I'll force the offload tests to re-run.
- Assistant
I'll review the OffloadInProgress test and validate the coalescing logic with a small temporary script.
- Assistant
Let me check the OffloadInProgress test around line 972.
- Assistant
There are relevant automated-offload tests already — I'll inspect them.
- Assistant
I'll read the multipleAutoTriggers test next.
- Assistant
I'll also confirm failures weren't hidden in the HTML reports.
- Assistant
I'll review the final dig sum of changes before submitting.
- Assistant
Fixing a race when thresholds are disabled during a pending follow-up so we don't drop concurrent PENDING.
- Assistant
I'll fix the race by using continue / recursive finish instead of set IDLE.
- Assistant
I'll re-run the offload tests after the race fix.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.