pulsar
pulsar copied to clipboard
[Bug] Too much schemas ledgers are created when multi producer start concurrently
Search before asking
- [X] I searched in the issues and found nothing similar.
Version
2.8.1
Minimal reproduce step
- create a new topic
- start up multi producers with the same Schema
- after producers are created, check the schemas by
bin/pulsar-admin schemas get -a tenant/namespace/topic
- you'll see many versions of schemas
What did you expect to see?
All producers with the same schema will only create one ledger to persistent schema entry.
What did you see instead?
Many duplicated ledgers for schema are created. like:
$ bin/pulsar-admin schemas get t_schema/ns_schema/t13 -a
{
"name" : "t13",
"schema" : "",
"type" : "STRING",
"timestamp" : 1666852962358,
"properties" : { },
"schemaDefinition" : ""
}
{
"name" : "t13",
"schema" : "",
"type" : "STRING",
"timestamp" : 1666852962365,
"properties" : { },
"schemaDefinition" : ""
}
{
"name" : "t13",
"schema" : "",
"type" : "STRING",
"timestamp" : 1666852962369,
"properties" : { },
"schemaDefinition" : ""
}
{
"name" : "t13",
"schema" : "",
"type" : "STRING",
"timestamp" : 1666852962365,
"properties" : { },
"schemaDefinition" : ""
}
{
"name" : "t13",
"schema" : "",
"type" : "STRING",
"timestamp" : 1666852962368,
"properties" : { },
"schemaDefinition" : ""
}
{
"name" : "t13",
"schema" : "",
"type" : "STRING",
"timestamp" : 1666852962368,
"properties" : { },
"schemaDefinition" : ""
}
Anything else?
Are you willing to submit a PR?
- [X] I'm willing to submit a PR!

This problem is caused by the update loop.
- Read exist schema entry
- build new schemaEntry
- create a new ledger
- write schemaEnry to BK
- builld new SchemaLocator
- put SchemaLocator to zk with expected version
if step 5 failed, broker will try again which will create a new ledger.
The issue had no activity for 30 days, mark with Stale label.