Skip to content

CASSSIDECAR-452: Avoid blocking the event loop in CdcPublisher event-bus handler#345

Open
Klose6 wants to merge 5 commits into
apache:trunkfrom
Klose6:CASSSIDECAR-452
Open

CASSSIDECAR-452: Avoid blocking the event loop in CdcPublisher event-bus handler#345
Klose6 wants to merge 5 commits into
apache:trunkfrom
Klose6:CASSSIDECAR-452

Conversation

@Klose6
Copy link
Copy Markdown

@Klose6 Klose6 commented May 8, 2026

CdcPublisher subscribes to several event-bus addresses (token-range changed, range gained/lost, server stop, CDC cache warmed up) via vertx.eventBus().localConsumer(), so handle(Message) runs on the event loop. The four range/stop branches previously called handleTokenRangeChange / handleRangeGained / handleRangeLost / stop
synchronously, all of which transitively perform blocking work(closing the Kafka producer, stopping SidecarCdc consumers, querying virtual tables). This blocks the event loop and can starve other Vert.x consumers under topology churn.
Dispatch those four branches to the shared worker pool via executorPools.executeBlocking(), matching the existing
ConfigChangedHandler pattern. Keep ON_CDC_CACHE_WARMED_UP on the event loop since it is only a single volatile write. Drop the now-redundant synchronized from handle() (event-loop-dispatched consumers cannot race with themselves; the actual handler methods remain synchronized).

@Klose6 Klose6 force-pushed the CASSSIDECAR-452 branch from 334ea08 to caf34d4 Compare May 19, 2026 17:04
Comment thread server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcPublisher.java Outdated
Comment thread server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcPublisher.java Outdated
Comment thread server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcPublisher.java Outdated
@Klose6 Klose6 force-pushed the CASSSIDECAR-452 branch from 34bb08a to 81fb733 Compare May 21, 2026 18:53
@Klose6
Copy link
Copy Markdown
Author

Klose6 commented May 21, 2026

Hi @yifan-c could you also take a look of this PR when you got a chance(since it needs another approval)? thank you!

@Klose6
Copy link
Copy Markdown
Author

Klose6 commented May 22, 2026

@yifan-c yifan-c requested review from jyothsnakonisa and yifan-c May 22, 2026 07:05
Comment thread server/src/test/java/org/apache/cassandra/sidecar/cdc/CdcPublisherTests.java Outdated
Comment thread server/src/test/java/org/apache/cassandra/sidecar/cdc/CdcPublisherTests.java Outdated
Comment thread server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcPublisher.java Outdated
Comment thread server/src/main/java/org/apache/cassandra/sidecar/cdc/CdcPublisher.java Outdated
Comment on lines +176 to +181
private void handleAsyncFailure(String address, Throwable t)
{
LOGGER.error("Unexpected error while processing event '{}' on worker pool", address, t);
sidecarCdcStats.captureUnrecoverableCdcError(t);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think the method will be invoked, since the restart & stop methods does not re-throw exception. I am fine with keeping the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants