PHOENIX-7884 : Refactor tracking of IndexCdcConsumer lag#2506
Open
palashc wants to merge 2 commits into
Open
Conversation
Contributor
Author
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.
What changes were proposed in this pull request?
Decouples the
cdcIndexUpdateLagmetric from batch completion. A new package-private helperIndexCDCConsumerProgressholds the consumer's monotonic effective freshness watermark, advanced by:lastProcessedTimestamp), orpollEnd − timestampBufferMs).A new
sleepWithLagSampling(...)helper inIndexCDCConsumerreplaces every consumer-threadThread.sleepsite (run loop, startup wait, parent-progress wait, failure backoff). It chunks every sleep intolagSampleIntervalMsslices (default 1000ms, configurable via new propertyphoenix.index.cdc.consumer.lag.sample.interval.ms) and emits onecdcIndexUpdateLagsample per slice. The previous per-batchupdateCdcLagcalls are removed so the sampler is the single emitter, and parent-replay timestamps no longer pollute the per-table histogram.Files changed:
phoenix-core-server/.../IndexCDCConsumer.java— modifiedphoenix-core-server/.../IndexCDCConsumerProgress.java— newphoenix-core/src/test/.../IndexCDCConsumerProgressTest.java— new (9 unit tests)phoenix-core/src/it/.../IndexCDCConsumerLagIT.java— newWhy are the changes needed?
cdcIndexUpdateLagis the primary freshness SLO signal for eventually consistent secondary indexes, but pre-fix it only emits insideif (!batchMutations.isEmpty())blocks (IndexCDCConsumer.java:988and:1109). This produces three distinct bugs:replayAndCompleteParentRegions(...)runs (which can take hours), the child region's own writes accumulate unprocessed but the lag metric reports nothing.processPartitionToCompletionduring replay, so ancestor-partition timestamps pollute the per-data-table histogram with stale values.Net effect: freshness alerts produce false negatives during the operational windows that matter most.
Does this PR introduce any user-facing change?
Yes —
cdcIndexUpdateLagbehaviour changes (no name/shape change; histogram, same per-table fanout).timestampBufferMsbaselinenow − consumerStartTimeOne operational note for release notes: the metric now legitimately grows during post-split parent replay (the EC index is stale during that window). Alerts on
cdcIndexUpdateLagshould use a long-enough window (e.g. > 30 min) until a follow-up subtask ships acdcParentReplayActiveGaugefor suppression.New config:
phoenix.index.cdc.consumer.lag.sample.interval.ms(default 1000, floor 50).How was this patch tested?
Unit tests —
IndexCDCConsumerProgressTest, 9 deterministic tests, all passing. Covers cold-start floor, monotonicity of both signals, empty-poll watermark math, processed-vs-empty interaction, idle bounded growth, negative-lag clamp, and pre-buffer empty-poll edge case.Integration test —
IndexCDCConsumerLagIT, 1 test, passing in ~11s. Verifies on a real MiniCluster that the sampler keeps emitting samples during a 5s idle window (binary flow check — pre-fix delta would be 0). UsesawaitMinCount(1, 120s)rather than fixed sleeps for startup so the test is robust to slow CI / GC jitter. Numerical value-correctness is left to the unit tests, which are deterministic.Regression coverage on existing EC index ITs:
MultiTenantEventualIndexIT#testBasicMultiTenantEventualIndex— PASSMultiTenantEventualIndexGenerateIT#testBasicMultiTenantEventualIndex— PASS (covers theprocessCDCBatchGeneratedpath)ConcurrentMutationsCoveredEventualIT— 3/3 PASS (exercises sibling metricscdcBatchProcessTime/cdcBatchCount/cdcMutationCountthat are deliberately preserved in the same blocks)Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude (Anthropic)