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

Avoid adding duplicated BrokerEntryMetadata #12018

Merged

Conversation

BewareMyPower
Copy link
Contributor

@BewareMyPower BewareMyPower commented Sep 13, 2021

Motivation

When the Pulsar cluster enables broker entry metadata, sometimes there're some corrupted entries. See streamnative/kop#442 for example. It's because the broker entry metadata has been added twice.

This bug might be introduced from #9039

if (beforeAddEntry(existsOp)) {
pendingAddEntries.add(existsOp);
}

It happened during a managed ledger's rollover while there're some pending OpAddEntrys in updateLedgersIdsComplete, only the ledger id should be updated and the data of OpAddEntry should not be modified.

Modifications

Only call beforeAddEntry for once at the beginning of internalAsyncAddEntry.

Verifying this change

  • Make sure that the change passes the CI checks.

@BewareMyPower BewareMyPower requested review from codelipenghui and hangc0276 and removed request for codelipenghui September 13, 2021 04:00
@BewareMyPower BewareMyPower self-assigned this Sep 13, 2021
@BewareMyPower BewareMyPower added release/2.8.2 type/bug The PR fixed a bug or issue reported a bug area/broker labels Sep 13, 2021
@Anonymitaet
Copy link
Member

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)

@BewareMyPower BewareMyPower added the doc-not-needed Your PR changes do not impact docs label Sep 13, 2021
@BewareMyPower
Copy link
Contributor Author

@Anonymitaet label is added now.

@BewareMyPower BewareMyPower changed the title Avoid adding duplicated BrokerEntryMetadata [WIP] Avoid adding duplicated BrokerEntryMetadata Sep 13, 2021
@BewareMyPower BewareMyPower changed the title [WIP] Avoid adding duplicated BrokerEntryMetadata Avoid adding duplicated BrokerEntryMetadata Sep 13, 2021
@BewareMyPower
Copy link
Contributor Author

image

The current code works normally in most cases. However, there's somehow a chance that BrokerEntryMetadata was added twice, which leads to corrupted messages. I'm not sure in which case updateLedgersIdsComplete could be called for multiple times, but after this change, beforeAddEntry will be only called in internalAsyncAddEntry, which is guaranteed to be called only once.

PTAL @codelipenghui @hangc0276

@BewareMyPower BewareMyPower added this to the 2.9.0 milestone Sep 16, 2021
@BewareMyPower BewareMyPower merged commit 9d44617 into apache:master Sep 18, 2021
@BewareMyPower BewareMyPower deleted the bewaremypower/fix-repeat-metadata branch September 18, 2021 12:43
codelipenghui pushed a commit that referenced this pull request Sep 19, 2021
### Motivation

When the Pulsar cluster enables broker entry metadata, sometimes there're some corrupted entries. See streamnative/kop#442 for example. It's because the broker entry metadata has been added twice.

This bug might be introduced from #9039 https://github.com/apache/pulsar/blob/9b7c3275c904ac1e6a8ef67487a10a0506bb2c58/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L1516-L1518

It happened during a managed ledger's rollover while there're some pending `OpAddEntry`s in `updateLedgersIdsComplete`, only the ledger id should be updated and the data of `OpAddEntry` should not be modified.

### Modifications

Only call `beforeAddEntry` for once at the beginning of `internalAsyncAddEntry`.

(cherry picked from commit 9d44617)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Sep 19, 2021
eolivelli pushed a commit to datastax/pulsar that referenced this pull request Oct 19, 2021
### Motivation

When the Pulsar cluster enables broker entry metadata, sometimes there're some corrupted entries. See streamnative/kop#442 for example. It's because the broker entry metadata has been added twice.

This bug might be introduced from apache#9039 https://github.com/apache/pulsar/blob/9b7c3275c904ac1e6a8ef67487a10a0506bb2c58/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L1516-L1518

It happened during a managed ledger's rollover while there're some pending `OpAddEntry`s in `updateLedgersIdsComplete`, only the ledger id should be updated and the data of `OpAddEntry` should not be modified.

### Modifications

Only call `beforeAddEntry` for once at the beginning of `internalAsyncAddEntry`.

(cherry picked from commit 9d44617)
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
### Motivation

When the Pulsar cluster enables broker entry metadata, sometimes there're some corrupted entries. See streamnative/kop#442 for example. It's because the broker entry metadata has been added twice.

This bug might be introduced from apache#9039 https://github.com/apache/pulsar/blob/9b7c3275c904ac1e6a8ef67487a10a0506bb2c58/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java#L1516-L1518

It happened during a managed ledger's rollover while there're some pending `OpAddEntry`s in `updateLedgersIdsComplete`, only the ledger id should be updated and the data of `OpAddEntry` should not be modified.

### Modifications

Only call `beforeAddEntry` for once at the beginning of `internalAsyncAddEntry`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.8 Archived: 2.8 is end of life doc-not-needed Your PR changes do not impact docs release/2.8.2 release/2.9.0 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

5 participants