[fix][schema]ledger handle leak when update schema - #17283
Merged
congbobo184 merged 4 commits intoSep 20, 2022
Conversation
codelipenghui
requested review from
Technoboy-,
codelipenghui,
congbobo184,
gaoran10,
lhotari and
mattisonchao
August 30, 2022 02:15
poorbarcode
force-pushed
the
fix/ledgerHandleLeakWhenSchemaUpdate
branch
from
September 9, 2022 19:22
f3672a3 to
ce32a21
Compare
| admin.namespaces().setSchemaCompatibilityStrategy(namespaceName, SchemaCompatibilityStrategy.ALWAYS_COMPATIBLE); | ||
| ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); | ||
| // Update schema 100 times. | ||
| ArrayList<Class> classes = createManyClass(classLoader, 100); |
Contributor
There was a problem hiding this comment.
I think using the SchemaDefinitionBuilder is easier to create multiple schemas.
Contributor
Author
There was a problem hiding this comment.
Already use SchemaDefinitionBuilder instead dynamic generate class
poorbarcode
requested review from
codelipenghui
and removed request for
Technoboy-,
congbobo184,
gaoran10,
lhotari and
mattisonchao
September 14, 2022 18:37
poorbarcode
force-pushed
the
fix/ledgerHandleLeakWhenSchemaUpdate
branch
from
September 19, 2022 09:33
0ef6643 to
8869500
Compare
| return createLedger(schemaId).thenCompose(ledgerHandle -> { | ||
| final long ledgerId = ledgerHandle.getId(); | ||
| return addEntry(ledgerHandle, schemaEntry) | ||
| .thenCompose(entryId -> ledgerHandle.closeAsync().thenApply(__ -> entryId)) |
Contributor
There was a problem hiding this comment.
I think we only need to trigger the close? The client-side doesn't need to wait for the close operation done.
| admin.topics().delete(topicName, true); | ||
| } | ||
|
|
||
| private static class DynamicClassLoader extends ClassLoader{ |
Contributor
There was a problem hiding this comment.
We don't need this class anymore?
Contributor
Author
There was a problem hiding this comment.
Already remove this internal class
codelipenghui
approved these changes
Sep 20, 2022
Contributor
|
/pulsarbot run-failure-checks |
codelipenghui
requested review from
RobertIndie,
Technoboy-,
congbobo184,
gaoran10 and
mattisonchao
September 20, 2022 00:50
congbobo184
approved these changes
Sep 20, 2022
nicoloboschi
pushed a commit
to datastax/pulsar
that referenced
this pull request
Sep 20, 2022
### Motivation in the schema update, will create a `ledgerHandle` and write data to BK, after that `ledgerHandle` is no longer useful and no other object holds references to it. `ledgerHandle` will be recycled with GC, but `ledgerHandle` also hold external connections, which will cause leakage. https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L452-L456 ### Modifications after the schema is updated, close the `ledgerHandle`, just like schema-read: https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L519-L525 (cherry picked from commit 2620450)
Technoboy-
pushed a commit
that referenced
this pull request
Sep 20, 2022
### Motivation in the schema update, will create a `ledgerHandle` and write data to BK, after that `ledgerHandle` is no longer useful and no other object holds references to it. `ledgerHandle` will be recycled with GC, but `ledgerHandle` also hold external connections, which will cause leakage. https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L452-L456 ### Modifications after the schema is updated, close the `ledgerHandle`, just like schema-read: https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L519-L525
congbobo184
pushed a commit
that referenced
this pull request
Nov 14, 2022
in the schema update, will create a `ledgerHandle` and write data to BK, after that `ledgerHandle` is no longer useful and no other object holds references to it. `ledgerHandle` will be recycled with GC, but `ledgerHandle` also hold external connections, which will cause leakage. https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L452-L456 after the schema is updated, close the `ledgerHandle`, just like schema-read: https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L519-L525 (cherry picked from commit 2620450)
congbobo184
pushed a commit
that referenced
this pull request
Nov 26, 2022
in the schema update, will create a `ledgerHandle` and write data to BK, after that `ledgerHandle` is no longer useful and no other object holds references to it. `ledgerHandle` will be recycled with GC, but `ledgerHandle` also hold external connections, which will cause leakage. https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L452-L456 after the schema is updated, close the `ledgerHandle`, just like schema-read: https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L519-L525 (cherry picked from commit 2620450)
liangyepianzhou
pushed a commit
that referenced
this pull request
Dec 5, 2022
### Motivation in the schema update, will create a `ledgerHandle` and write data to BK, after that `ledgerHandle` is no longer useful and no other object holds references to it. `ledgerHandle` will be recycled with GC, but `ledgerHandle` also hold external connections, which will cause leakage. https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L452-L456 ### Modifications after the schema is updated, close the `ledgerHandle`, just like schema-read: https://github.com/apache/pulsar/blob/40b9d7ea50cef54becb09f2543193e08375abe0b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java#L519-L525 (cherry picked from commit 2620450)
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
in the schema update, will create a
ledgerHandleand write data to BK, after thatledgerHandleis no longer useful and no other object holds references to it.ledgerHandlewill be recycled with GC, butledgerHandlealso hold external connections, which will cause leakage.pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Lines 452 to 456 in 40b9d7e
Modifications
after the schema is updated, close the
ledgerHandle, just like schema-read:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Lines 519 to 525 in 40b9d7e
Documentation
doc-requireddoc-not-neededdocdoc-completeMatching PR in forked repository
PR in forked repository: