-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Invalid regex in PulsarLedgerManager causes zk data notification to be ignored #23977
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
[fix][broker] Invalid regex in PulsarLedgerManager causes zk data notification to be ignored #23977
Conversation
|
Some test is requried to ensure the notification logic is triggered and works correct. |
Great catch @TakaHiR07. What is the current impact of this in Pulsar & Bookkeeper (which is using PulsarLedgerManager in the Pulsar distribution of Bookkeeper)? |
One impact is all the asyncOpenLedgerNoRecovery in pulsar can not register successful MetadataListener. The code is here: https://github.com/apache/bookkeeper/blob/606db747eae9856fed0aeb3f16ef01e7c9254e26/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/ReadOnlyLedgerHandle.java#L95-L105 I am not sure whether other place use PulsarLedgerManager and register zk listener. |
@thetumbled That's right that there should be tests, but this just shows that the original code didn't have proper test coverage if it's currently broken. One possible resolution would be to add an issue report about the missing test coverage and add the tests later. That moment usually never comes, but it's also bad to have this issue around. |
I wonder what parts of the metadata could change. My guess is LAC (lastAddConfirmed) and length based on this: |
@lhotari I think if ledger is in recover state, LAC would be changed. But we should not use asyncOpenLedgerNoRecovery to register zk metadata listener, instead should use asyncOpenLedger to update ledgerHandler's metadata. This is no problem since it do not rely on zk. But if ledger is already closed, and then trigger bookkeeper auto-recovery because of disk error, ledger's quorum would be changed, ledger's zk node would also be changed. Actually, the issue is found when I fix another issue, you can see here. #21552 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #23977 +/- ##
============================================
- Coverage 74.26% 74.25% -0.02%
+ Complexity 33213 32847 -366
============================================
Files 1885 1885
Lines 146953 146953
Branches 16928 16928
============================================
- Hits 109136 109119 -17
- Misses 29116 29125 +9
- Partials 8701 8709 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
lhotari
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. The pattern looks correct although there aren't tests. The problem isn't caused by this PR since there doesn't seem to be existing tests for PulsarLedgerManager.
…ification to be ignored (#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798)
…ification to be ignored (#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798)
…ification to be ignored (#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798) (cherry picked from commit 3da4c7a)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798) (cherry picked from commit a54cb1a)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798) (cherry picked from commit a54cb1a)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798) (cherry picked from commit 3da4c7a)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]> (cherry picked from commit a532798)
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]>
…ification to be ignored (apache#23977) Co-authored-by: fanjianye <[email protected]>
Motivation
ledger zk path is like "/ledgers/00/0601/L7170". But currently it exist pattern regex error cause zk data notification can not execute.
ledgerPathRegex.matcher(n.getPath()).matches() is always false.
Modifications
use correct pattern.
Alternative modification: remove the judgement in handleDataNotification(), since getLedgerId(n.getPath()) would throw error if the path is not ledger path.
Verifying this change
(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:)
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
Documentation
docdoc-requireddoc-not-neededdoc-complete