pulsar-client-go icon indicating copy to clipboard operation
pulsar-client-go copied to clipboard

Use critical section for batch counters in producer default_router

Open zzzming opened this issue 4 years ago • 0 comments

Motivation

A group of batch counters are not properly critical section protected in the producer's default_router. Read and update of these counters should be protected as a whole, instead of individually synchronized using Atomic access. Multiple goroutines can access and update these counters at the same time. Basically it is not thread safe.

Modifications

The change use mutex lock to protect the entire counters during the batch partition decision making process. Minor improvement includes to evaluate message max size, byte size, and batch window on a needed basis.

Verifying this change

  • [ v] Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): ( no)
  • The public API: (no)
  • The schema: ( no)
  • The default values of configurations: (no)
  • The wire protocol: (no)

Documentation

  • Does this pull request introduce a new feature? (/ no)
  • If yes, how is the feature documented? (not applicable )

zzzming avatar Dec 12 '21 02:12 zzzming