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 trace the managed-ledger offload scheduling path, identify how automatic triggers are queued while a run is active, then implement coalescing without changing explicit/manual future semantics. I’ll inspect relevant classes and tests first, reproduce or infer the race, patch the smallest area, and run focused tests plus compilation as available.
- Assistant
The current retry is driven by
offloadMutex: every automatic trigger that finds the mutex busy schedules another independent invocation, all sharing the same completed/null promise. I’ll separate automatic scheduling from explicit requests using internal state: one active/scheduled automatic run plus a boolean coalesced follow-up request. The follow-up will be scheduled only after the active run releases the mutex, and each run will re-read current policies. Explicit calls will retain the existing retry path unchanged. - Assistant
The coalescing state is now in place. I also handled the important completion race: a follow-up is launched directly while the automatic state remains active, rather than passing through the initial scheduler and accidentally marking itself as another follow-up. Policy removal during a run resets the state cleanly. I’ll now compile and run the managed-ledger tests relevant to offload behavior.
- Assistant
Implemented automatic offload trigger coalescing in
ManagedLedgerImpl.Changes:
- Added internal state to track one active automatic offload and one pending follow-up.
- Coalesced additional automatic triggers while a run is active or waiting on the mutex.
- Ensured follow-up runs re-read current policies and process newly eligible ledgers.
- Preserved the existing retry behavior for explicit/manual offload futures.
- Handled policy removal and offloader availability changes safely.
- No public interfaces were added.
Validation:
:managed-ledger:compileJavapassed.OffloadLedgerDeleteTestpassed.:managed-ledger:spotlessCheckpassed.- No issue-specific error reproduction was available; the redundant retry behavior was confirmed from the existing mutex retry implementation.
- Edge cases considered include triggers before a queued run starts, triggers during an active run, manual offloads holding the mutex, and policy changes during execution.
I’m submitting the verified changes now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.