Skip to content

[improve][broker] Add a random value upto 5% to avoid rollover multiple cursor ledgers - #26542

Open
TakaHiR07 wants to merge 2 commits into
apache:masterfrom
TakaHiR07:improve_avoid_rollover_multiple_cursor_ledger
Open

TakaHiR07 wants to merge 2 commits into
apache:masterfrom
TakaHiR07:improve_avoid_rollover_multiple_cursor_ledger

Conversation

@TakaHiR07

Copy link
Copy Markdown
Contributor

Motivation

If topic has multiple subscriptions, the cursor ledgers of subscriptions may rollover at the same time, which may bring additional pressure on zk.

企业微信截图_bf29c0d9-b029-4ff2-8bdc-30f72670d5e2

Topic ledger has added the random value to avoid rollover at the same time. While cursor ledger do not have this mechanism.

// Get the next rollover time. Add a random value upto 5% to avoid rollover multiple ledgers at the same time
this.maximumRolloverTimeMs = getMaximumRolloverTimeMs(config);

Modifications

Also add the 5% random value in rollover cursor ledger.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

@TakaHiR07
TakaHiR07 force-pushed the improve_avoid_rollover_multiple_cursor_ledger branch from beebec8 to 907ae39 Compare September 11, 2026 08:34
Comment on lines -4536 to 4542
this.cursors.forEach(c -> c.setThrottleMarkDelete(config.getThrottleMarkDelete()));
this.cursors.forEach(c -> {
if (c instanceof ManagedCursorImpl cursor) {
cursor.updateRolloverThresholds(config);
}
c.setThrottleMarkDelete(config.getThrottleMarkDelete());
});
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this get called when the config changes?
Could we add a updateConfig method to ManagedCursorImpl and handle the logic there?
There's no need to add the method to ManagedCursor interface since ManagedLedgerImpl only includes ManagedCursorImpl instances.

@TakaHiR07 TakaHiR07 Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that we add a updateConfig method to ManagedCursorImpl, which involve updateRolloverThresholds() and setThrottleMarkDelete() ?

Currently I add updateRolloverThresholds() to ManagedCursorImpl. While setThrottleMarkDelete() is still in ManagedCursor interface

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean that we add a updateConfig method to ManagedCursorImpl, which involve updateRolloverThresholds() and setThrottleMarkDelete() ?

yes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe configUpdated is a better method name, since the method is an event handler for config updates.

@TakaHiR07 TakaHiR07 Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is reasonable. I have modified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants