Skip to content

Comments

when consumer close and create frequently, delay message will be duplicated#14727

Closed
leizhiyuan wants to merge 7 commits intoapache:masterfrom
leizhiyuan:fix/14722
Closed

when consumer close and create frequently, delay message will be duplicated#14727
leizhiyuan wants to merge 7 commits intoapache:masterfrom
leizhiyuan:fix/14722

Conversation

@leizhiyuan
Copy link
Contributor

@leizhiyuan leizhiyuan commented Mar 17, 2022

Fixes #14722

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #14722

Motivation

Explain here the context, and why you're making that change. What is the problem you're trying to solve.

Modifications

Describe the modifications you've done.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

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

If yes was chosen, please highlight the changes

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

Documentation

Check the box below or label this PR directly (if you have committer privilege).

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@github-actions
Copy link

@leizhiyuan:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions
Copy link

@leizhiyuan:Thanks for providing doc info!

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 17, 2022
Copy link
Member

@wolfstudy wolfstudy left a comment

Choose a reason for hiding this comment

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

LGTM +1

@Demogorgon314
Copy link
Member

Can we add a units test to cover this case?


if (dispatcher != null && dispatcher.getConsumers().isEmpty()) {
// clear delay message avoid duplicate.
dispatcher.clearDelayedMessages();
Copy link
Contributor

Choose a reason for hiding this comment

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

There are other places will call cursor.rewind(); in the PersistentDispatcherMultipleConsumers. The cursor rewind will cause to add the duplicated delayed message index, and reset the cursor will also introduce this problem, could you please check them?

// All consumers got disconnected before the completion of the read operation
entries.forEach(Entry::release);
cursor.rewind();
clearDelayedMessages();
Copy link
Contributor

Choose a reason for hiding this comment

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

If clearDelayedMessages() binds with cursor.rewind(), it's better to wrap them into one method.

@leizhiyuan
Copy link
Contributor Author

see #14740

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

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

during delay time , close consumer and recreate new consumer will receive many delay message

8 participants