pulsar icon indicating copy to clipboard operation
pulsar copied to clipboard

[Bug] Too much schemas ledgers are created when multi producer start concurrently

Open aloyszhang opened this issue 2 years ago • 1 comments

Search before asking

  • [X] I searched in the issues and found nothing similar.

Version

2.8.1

Minimal reproduce step

  1. create a new topic
  2. start up multi producers with the same Schema
  3. after producers are created, check the schemas by bin/pulsar-admin schemas get -a tenant/namespace/topic
  4. 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!

aloyszhang avatar Nov 02 '22 06:11 aloyszhang

image

This problem is caused by the update loop.

  1. Read exist schema entry
  2. build new schemaEntry
  3. create a new ledger
  4. write schemaEnry to BK
  5. builld new SchemaLocator
  6. put SchemaLocator to zk with expected version

if step 5 failed, broker will try again which will create a new ledger.

aloyszhang avatar Nov 02 '22 06:11 aloyszhang

The issue had no activity for 30 days, mark with Stale label.

github-actions[bot] avatar Dec 03 '22 01:12 github-actions[bot]