PHOENIX-7877 More granular metrics for ReplicationLogWriter#2492
Merged
Conversation
Adds histograms to decompose ReplicationLogGroup sync latency: pendingSyncWaitTime measures wait between consumer pickup of a SYNC event and start of fsync; fsSyncTime (renamed from modeSyncTime) measures the underlying filesystem sync. Also instruments rotationTime in ReplicationLog so existing metric is actually emitted. Introduces a builder for ReplicationLogMetricValues to avoid positional argument hazards as the metric set grows.
apurtell
approved these changes
Jun 3, 2026
| } | ||
| metrics.updatePendingSyncCount(pendingSyncCount); | ||
| // Record per-event wait between SYNC pickup and fsync start. | ||
| long syncStartNs = System.nanoTime(); |
Contributor
There was a problem hiding this comment.
Move store to syncStartNs below the histogram updates to only time the actual sync. Just a nit.
There was a problem hiding this comment.
Pull request overview
Adds finer-grained metrics to ReplicationLogGroup/ReplicationLogWriter to improve visibility into disruptor batching behavior, pending SYNC coalescing, and underlying fsync/rotation timing, plus an IT sanity check to ensure metrics are emitted.
Changes:
- Instrument
ReplicationLogGroupconsumer to recordfsSyncTime,pendingSyncWaitTime,pendingSyncCount, and per-batchbatchSize. - Record
rotationTimefromReplicationLog.LogRotationTask.run()on both success and failure paths. - Extend metric snapshot plumbing (
MetricsReplicationLogGroupSource*,ReplicationLogMetricValues) and add an IT assertion that metrics were emitted.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| phoenix-core/src/it/java/org/apache/phoenix/replication/ReplicationLogGroupIT.java | Adds a metrics-emission sanity check to guard against declared-but-never-emitted metrics. |
| phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLogGroup.java | Adds disruptor-consumer instrumentation for per-batch sizing and pending-sync timing/coalescing. |
| phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLog.java | Instruments rotation task wall time for rotationTime. |
| phoenix-core-server/src/main/java/org/apache/phoenix/replication/metrics/ReplicationLogMetricValues.java | Extends metric snapshot structure to include new histograms via a builder. |
| phoenix-core-server/src/main/java/org/apache/phoenix/replication/metrics/MetricsReplicationLogGroupSourceImpl.java | Registers new histograms and includes them in snapshot values. |
| phoenix-core-server/src/main/java/org/apache/phoenix/replication/metrics/MetricsReplicationLogGroupSource.java | Defines new metric keys/descriptions (and adjusts existing ones). |
Comments suppressed due to low confidence (1)
phoenix-core-server/src/main/java/org/apache/phoenix/replication/ReplicationLogGroup.java:1181
- The early
returnonfatalException != nullhappens before thetry { ... } finally { ... }block, so theendOfBatchcleanup infinallynever runs in that path. With the newly addedbatchEventCount, this can leak the counter across batches (and potentially grow unbounded) once a fatal exception is set.
// so producer threads unblock without waiting for the sync timeout.
if (event.type == EVENT_TYPE_SYNC) {
event.syncFuture.completeExceptionally(fatalException);
}
return;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+37
to
+41
| // All time histograms in this source are nanoseconds. | ||
| String APPEND_TIME = "appendTime"; | ||
| String APPEND_TIME_DESC = "Histogram of time taken for append operations in nanoseconds"; | ||
|
|
||
| String SYNC_TIME = "syncTimeMs"; | ||
| String SYNC_TIME = "syncTime"; |
Comment on lines
+194
to
+195
| assertTrue("pendingSyncWaitTime should be > 0, got " + values.getPendingSyncWaitTime(), | ||
| values.getPendingSyncWaitTime() > 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds finer-grained histograms in
MetricsReplicationLogGroupSourceto give better visibility into where time is spent insideReplicationLogGroup:fsSyncTime— wall time of the underlying filesystem sync (fsync) insideprocessPendingSyncs.pendingSyncWaitTime— per-pending-sync wait between consumer pickup of a SYNC event and the start offsync. Helps quantify within-batch drain (events the consumer processes between picking up the SYNC marker and reachingendOfBatch).pendingSyncCount— number of sync futures coalesced into a single fsync. Indicates how well the disruptor batches sync calls.batchSize— number of events drained per disruptor batch. Counter is reset in afinallyblock onendOfBatchso the value never leaks across batches when an exception path bypassesprocessPendingSyncs.rotationTime— was declared but never populated; now instrumented inReplicationLog.LogRotationTask.runand recorded on both success and failure paths.Test plan
mvn test -pl phoenix-core -Dtest=ReplicationLogGroupTestpassesmvn verify -pl phoenix-core -Dit.test=ReplicationLogGroupITpassesmvn spotless:checkpassesRegionServer,sub=ReplicationLogGroup,haGroup=...JMX context with non-zero values during sustained workload