[improve][meta] PIP-453: Improve the metadata store threading model#25187
Conversation
1. Trigger callbacks in the underlying metadata store's internal thread directly. 2. Add a dedicated scheduler for batch flushing tasks 3. Add a dedicated thread pool for `MetadataCache`'s computing tasks 4. Add tests to verify serialization and deserialization tasks are executed in the pool whose thread count is specified by `metadataStoreSerDesThreads`
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/AbstractMetadataStore.java
Outdated
Show resolved
Hide resolved
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/cache/impl/MetadataCacheImpl.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR implements PIP-453 to improve the metadata store threading model by separating concerns across multiple dedicated thread pools. The change aims to prevent a single metadata store thread from being overwhelmed by various types of tasks (event handling, scheduling, flushing, and serialization/deserialization).
Changes:
- Replaced single
ScheduledExecutorServicewith four specialized executors:eventExecutorfor notifications,schedulerExecutorfor delayed tasks,flushExecutorfor batch flushing, andserDesExecutorfor serialization/deserialization - Modified callback execution to use the underlying store's thread directly instead of switching to executor thread
- Removed batch metadata store queue size metrics since the dedicated flush executor only handles flushing
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| AbstractMetadataStore.java | Introduces new thread pool structure with separate executors for events, scheduling, and ser/des operations |
| AbstractBatchedMetadataStore.java | Adds dedicated flush executor and updates flush mechanism with synchronized method |
| BatchMetadataStoreStats.java | Removes executor queue size metrics and simplifies constructor |
| MetadataCacheImpl.java | Updates to use OrderedExecutor for ser/des operations and separate scheduler for retries |
| ZKMetadataStore.java | Updates callback execution to use new helper methods |
| EtcdMetadataStore.java | Updates async operations to execute callbacks in event executor |
| RocksdbMetadataStore.java, LocalMemoryMetadataStore.java, OxiaMetadataStore.java | Updates constructors to pass numSerDesThreads parameter |
| ServiceConfiguration.java, MetadataStoreConfig.java | Adds new configuration for ser/des thread pool size |
| PulsarService.java | Propagates new configuration to metadata store instances |
| PulsarServiceTest.java | Adds comprehensive test for ser/des thread pool behavior |
| OpenTelemetryMetadataStoreStatsTest.java | Updates test to reflect removed metrics |
| MetadataStoreFactoryImplTest.java | Updates test constructor call |
| pip-453.md | Updates PIP document to reflect actual implementation with 4 thread sets |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...ata/src/main/java/org/apache/pulsar/metadata/impl/batching/AbstractBatchedMetadataStore.java
Show resolved
Hide resolved
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
Outdated
Show resolved
Hide resolved
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/AbstractMetadataStore.java
Outdated
Show resolved
Hide resolved
...ata/src/main/java/org/apache/pulsar/metadata/impl/batching/AbstractBatchedMetadataStore.java
Outdated
Show resolved
Hide resolved
...ata/src/main/java/org/apache/pulsar/metadata/impl/batching/AbstractBatchedMetadataStore.java
Outdated
Show resolved
Hide resolved
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/AbstractMetadataStore.java
Outdated
Show resolved
Hide resolved
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
Outdated
Show resolved
Hide resolved
lhotari
left a comment
There was a problem hiding this comment.
LGTM, great work @BewareMyPower
pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
Show resolved
Hide resolved
…pache#25187) (cherry picked from commit 6d415c6) (cherry picked from commit c5f7271)
|
There is a bug with this PR: So don't cherry-pick it for now, I will push a fix soon |
@BewareMyPower It's already cherry-picked for 4.0.9 and 4.1.3 release candidate 1. Should I start a new release candidate after your fix is merged? |
|
Yes, please cancel the existing releases. I will work on the fix ASAP |
|
The fix is here: #25246 |
… model (apache#25187)" This reverts commit c5f7271. (cherry picked from commit a6aab86)
PIP: #25173
Modifications
MetadataCache's computing tasksmetadataStoreSerDesThreadsDocumentation
docdoc-requireddoc-not-neededdoc-completeMatching PR in forked repository
PR in forked repository: