-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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] Fix pulsarLedgerIdGenerator can't delete index path when zk metadata store config rootPath. #17192
Conversation
@horizonzy Please provide a correct documentation label for your PR. |
@@ -173,7 +174,7 @@ private CompletableFuture<Long> generateLongLedgerId() { | |||
if (log.isDebugEnabled()) { | |||
log.debug("DELETING HIGH ORDER DIR: {}", path); | |||
} | |||
store.delete(path, Optional.of(0L)); |
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.
this is a relative path we build ourself and won't have the problem of carrying root path when getting path from stats.getPath()
?
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.
Yes, you are right. Thanks for reminder.
return path.replaceFirst(rootPath, ""); | ||
} | ||
return path; | ||
} |
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.
Could we make this in the constructor to avoid calling replaceFirst
every time?
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.
It's not a fixed path, it looks like we can't avoid replacing operation.
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.
It's not a fixed path, it looks like we can't avoid replacing operation.
+1
return path.replaceFirst(rootPath, ""); | ||
} | ||
return path; | ||
} |
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.
It's not a fixed path, it looks like we can't avoid replacing operation.
//So when we get the path from the stat, we should truncate the rootPath. | ||
private String handleTheDeletePath(String path) { | ||
if (store instanceof ZKMetadataStore) { | ||
String rootPath = ((ZKMetadataStore) store).getRootPath(); |
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.
I see we already have ledgersRoot
of PulsarLedgerIdGenerator
constructor, it's better to use it directly to avoid such checks here.
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.
And we don't need to introduce a new method in ZKMetadataStore.java
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.
I see we already have ledgersRoot of PulsarLedgerIdGenerator constructor, it's better to use it directly to avoid such checks here.
It's not the zk rootPath, the ledgersRoot
is /ledegrs
.
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.
The metadataServiceUriStr
is metadata-store:127.0.0.1:2181/test
, it's not a standard schema, so we can't resolve the path correctly in AbstractMetadataDriver#resolveLedgersRootPath
.
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.
I see.
//So when we get the path from the stat, we should truncate the rootPath. | ||
private String handleTheDeletePath(String path) { | ||
if (store instanceof ZKMetadataStore) { | ||
String rootPath = ((ZKMetadataStore) store).getRootPath(); |
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.
I see.
This problem may lead zk oom if the ManagedLedgerImpl create new ledger too frequent. |
789781e
to
365938c
Compare
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, left a minor suggestion.
@Test | ||
public void testGenerateLedgerIdWithZkPrefix() throws Exception { | ||
@Cleanup | ||
MetadataStoreExtended store = |
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.
If this line is the only difference between testGenerateLedgerId
and testGenerateLedgerIdWithZkPrefix
, we can reuse the common codes here.
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.
In testGenerateLedgerIdWithZkPrefix, we need check the index path is still exists.
You can add this to the Motivation. |
…n zk metadata store config rootPath. (#17192)
…n zk metadata store config rootPath. (apache#17192) (cherry picked from commit 9445fa7) (cherry picked from commit 805f985)
(If this PR fixes a github issue, please add
Fixes #<xyz>
.)Fixes #17191
Motivation
Fix pulsarLedgerIdGenerator can't delete index path when zk metadata store config rootPath.
This problem may lead zk oom if the ManagedLedgerImpl create new ledger too frequent.
Documentation
doc-not-needed
(Please explain why)