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][schema] Fix creating lots of versions for the same schema #18293
Conversation
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
5820663
to
d5fc973
Compare
d5fc973
to
3e644fc
Compare
Codecov Report
@@ Coverage Diff @@
## master #18293 +/- ##
============================================
- Coverage 47.06% 46.91% -0.16%
- Complexity 8956 10428 +1472
============================================
Files 592 698 +106
Lines 56313 68339 +12026
Branches 5844 7342 +1498
============================================
+ Hits 26503 32058 +5555
- Misses 26946 32658 +5712
- Partials 2864 3623 +759
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@gaoran10 @codelipenghui PTAL |
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
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 pr only guarantees the consistency of the zk storage schema, but it still creates useless ledger, right?
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
@congbobo184 The schema will create a useless ledger at two points.
This PR tries to resolve the second problem. I still working on the first problem and will send a new PR for it. |
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.
Nice work! Left some comments.
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistry.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryStats.java
Outdated
Show resolved
Hide resolved
To my understanding, this PR canceled the retry action in But I notice the |
@labuladong As described in issue #18292, the retry function in BTW, the retry function is only useful when there is a race condition updating the zookeeper, and the command of delete schema is invoked from the CLI or PulsarAdmin which is rare to have a high concurrency. So, little chance for delete the schema will fail. However, Also, if there is a scene where keeping the retry function in |
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Show resolved
Hide resolved
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/schema/SchemaServiceTest.java
Show resolved
Hide resolved
LGTM |
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Show resolved
Hide resolved
4576c48
to
69c0ce5
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.
I have tried a test to verify we will not get duplicated schemas with this fix.
But looks like the issue hasn't been fixed completely
~/GitHub/apache/incubator-pulsar/distribution/server/target/apache-pulsar-2.11.0-SNAPSHOT (schema-fix*) » bin/pulsar-admin schemas get test --version 2 lipenghui@lipenghuideMacBook-Pro-2
{
"name": "test",
"schema": {
"type": "record",
"name": "User",
"namespace": "io.streamnative.test.AvroConsumer",
"fields": [
{
"name": "age",
"type": "int"
},
{
"name": "description",
"type": [
"null",
"string"
]
},
{
"name": "name",
"type": [
"null",
"string"
]
}
]
},
"type": "AVRO",
"timestamp": 1668066392133,
"properties": {
"__alwaysAllowNull": "true",
"__jsr310ConversionEnabled": "false"
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/GitHub/apache/incubator-pulsar/distribution/server/target/apache-pulsar-2.11.0-SNAPSHOT (schema-fix*) » bin/pulsar-admin schemas get test --version 1 lipenghui@lipenghuideMacBook-Pro-2
{
"name": "test",
"schema": {
"type": "record",
"name": "User",
"namespace": "io.streamnative.test.AvroConsumer",
"fields": [
{
"name": "age",
"type": "int"
},
{
"name": "description",
"type": [
"null",
"string"
]
},
{
"name": "name",
"type": [
"null",
"string"
]
}
]
},
"type": "AVRO",
"timestamp": 1668066392023,
"properties": {
"__alwaysAllowNull": "true",
"__jsr310ConversionEnabled": "false"
}
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/GitHub/apache/incubator-pulsar/distribution/server/target/apache-pulsar-2.11.0-SNAPSHOT (schema-fix*) » bin/pulsar-admin schemas get test --version 0 lipenghui@lipenghuideMacBook-Pro-2
{
"name": "test",
"schema": {
"type": "record",
"name": "User",
"namespace": "io.streamnative.test.AvroConsumer",
"fields": [
{
"name": "age",
"type": "int"
},
{
"name": "name",
"type": [
"null",
"string"
]
}
]
},
"type": "AVRO",
"timestamp": 1668066223880,
"properties": {
"__alwaysAllowNull": "true",
"__jsr310ConversionEnabled": "false"
}
}
The schema version 1 and 2 is the same schema which was reproduced by creating 64 producers with the same schema.
The steps to reproduce
- Create 64 consumers with a schema (Only one schema created)
- Create 64 producers with a new schema (Two same schemas are created)
@codelipenghui This is another problem. The root cause is the concurrent access to zookeeper.
Before updating the If other threads updated the locator just before this point, it directly adds the position information of a new schema entry to the locator without exist check |
@aloyszhang hi, I move this PR to release/2.9.5, if you have any questions, please ping me. thanks. |
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
...ar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java
Outdated
Show resolved
Hide resolved
...-broker/src/main/java/org/apache/pulsar/broker/service/schema/SchemaRegistryServiceImpl.java
Outdated
Show resolved
Hide resolved
617326e
to
10cacda
Compare
@codelipenghui PTAL, thanks |
b0bd606
to
9fd555a
Compare
9fd555a
to
fe78ff2
Compare
close this pull request due to #18701 |
Fixes #18292
Motivation
fix creating lots of ledgers for the same schema
Modifications
when putting schema to zk failed, do not retry directly, but read the latest persistent schema from zk first
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: aloyszhang#3