Skip to content
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.

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

[broker] Key_Shared dispatcher with no connected consumers should be recreated if allowOutOfOrderDelivery changes #13063

Merged
merged 1 commit into from
Dec 1, 2021

Conversation

massakam
Copy link
Contributor

@massakam massakam commented Dec 1, 2021

Motivation

PersistentStickyKeyDispatcherMultipleConsumers has an instance variable named allowOutOfOrderDelivery, which is set by the first connected consumer and will not change unless the dispatcher is closed, such as by unloading. That is, end users have no way to change this setting.

As with keySharedMode, if a consumer with a different policy connects after all consumers have been disconnected, the dispatcher should be closed and recreated.

KeySharedMeta ksm = consumer.getKeySharedMeta();
KeySharedMode keySharedMode = ksm.getKeySharedMode();
if (dispatcher == null || dispatcher.getType() != SubType.Key_Shared
|| ((PersistentStickyKeyDispatcherMultipleConsumers) dispatcher).getKeySharedMode()
!= keySharedMode) {
previousDispatcher = dispatcher;
dispatcher = new PersistentStickyKeyDispatcherMultipleConsumers(topic, cursor, this,
topic.getBrokerService().getPulsar().getConfiguration(), ksm);
}

Modifications

If a consumer with a different keySharedMode or allowOutOfOrderDelivery policy tries to connect to PersistentStickyKeyDispatcherMultipleConsumers to which no consumer is connected, close that dispatcher and create a new one.

Verifying this change

  • Make sure that the change passes the CI checks.

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

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • no-need-doc

@massakam massakam added area/broker component/key-shared doc-not-needed Your PR changes do not impact docs labels Dec 1, 2021
@massakam massakam added this to the 2.10.0 milestone Dec 1, 2021
@massakam massakam self-assigned this Dec 1, 2021
@massakam massakam force-pushed the recreate-key-shared-dispatcher branch from 9362cf1 to f4d172a Compare December 1, 2021 10:51
@merlimat merlimat added the type/bug The PR fixed a bug or issue reported a bug label Dec 1, 2021
@merlimat merlimat merged commit 36c1c00 into apache:master Dec 1, 2021
@massakam massakam deleted the recreate-key-shared-dispatcher branch December 2, 2021 02:06
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker doc-not-needed Your PR changes do not impact docs type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants