Repository navigation
fix(#10634): a late-sample record ships to the followers, an unset watermark beside backing rows resumes from them - #10674
Conversation
…termark beside backing rows resumes from them Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 16 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
ReviewOverall this is a well-reasoned fix, and the Javadoc explains the trade-offs clearly. No security concerns: there are no new dependencies, no new inputs and no new endpoints. The HA test tags the class Strengths
Points to consider
Test coverage looks good: the engine unit tests cover the unset watermark in memory and after a reopen, plus the empty-backing-type case, and the HA IT covers replication. I couldn't run the tests here, so I'm going by the PR's reported results. Nothing blocking. LGTM with the minor nits above. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 14 |
🟢 Coverage 71.43% diff coverage · -4.86% coverage variation
Metric Results Coverage variation ✅ -4.86% coverage variation Diff coverage ✅ 71.43% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (ad9ebdd) 250685 218238 87.06% Head commit (d175c2a) 283422 (+32737) 232963 (+14725) 82.20% (-4.86%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#10674) 42 30 71.43% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…late-sample record in a helper Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review of #10674 The approach looks sound and the tests cover both writers. No security concerns. The changes are internal, add no dependencies, and add no new input surface. What I liked
Points to consider
Overall this is good work. Item 2 is the one I would verify before merging. |
…ships its record too (IT), adoption cost documented Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Review of #10674 (closes #10634) I read the diff only. I did not build the project or run the tests. Overall: the change is sound and the reasoning is well documented in the Javadoc. I found no security concerns, so I did not add the label. What looks good
Points to consider (non-blocking)
Style follows CLAUDE.md (imports, assertThat, no em dashes). LGTM from my side. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10674 +/- ##
=========================================
Coverage 78.98% 78.99%
- Complexity 4760 4771 +11
=========================================
Files 2295 2295
Lines 250685 250721 +36
Branches 54668 54675 +7
=========================================
+ Hits 198006 198045 +39
+ Misses 32487 32485 -2
+ Partials 20192 20191 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Closes #10634
Summary
The refresh state of a continuous aggregate (its watermark, and since #10502 the range of samples appended behind it) was written with a plain
LocalSchema.saveConfiguration(), outside any schema recording session, so under HA it reached the followers only with the next unrelated schema change. Two fixes, one per writer:TimeSeriesShard.invalidateContinuousAggregatesBehindWatermarknow ships the record in a schema recording session of its own (LocalSchema.recordContinuousAggregateChange) when the database is replicated. The append path runs outside every database lock, so the session can be opened there. Cost: one replicated schema entry, under the write lock, per bucket a stream of late samples reaches (invalidateLateSamplesalready widens to whole buckets so later samples of a recorded bucket change nothing). Off HA the plain save is kept. If the session fails, the old local save is the fallback, with a WARNING.RWLockContext.writeLock()refuses an upgrade. The issue said an older watermark on a promoted follower is safe, and for a set watermark that holds, because the refresh deletes and recomputes the buckets at or after it. It is not safe for an unset one (an aggregate created over an empty source, refreshed afterwards): a refresh from an unset watermark runs the whole query and deletes nothing, so every bucket the backing type holds was duplicated.ContinuousAggregateRefresher.refreshOncenow adopts the newest bucket of the backing type as the watermark when the watermark is unset and the backing type is not empty. The same state also exists on a single node, after a refresh whose schema save failed, and this fixes that too. The backing type is read by iterating its records, not with a query: the first refresh runs inside the creation's schema session under the write lock, and a parallel aggregate scan there deadlocked (found by the IT).Test plan
Issue10634UnsetWatermarkWithRowsTest(engine, 3 tests): unset watermark beside rows, in memory and after a reopen, with no duplicates. An empty backing type still reads every sample. Red before the fix (6 rows instead of 3).Issue10634ContinuousAggregateLateSampleReplicationIT(ha-raft, 2 nodes, 2 tests): a late sample's record and the leader's watermark reach the follower, and the follower converges after the refresh. The same holds for a late INSERT inside a transaction the caller opened (added in review). Red with the session disabled (follower had no record).aDeleteShipsTheRange..., follower record awaited 33 s) in a run of three IT classes back to back. It was green in 3 runs afterwards (twice the full class, once the single method) and in 1 baseline run without this change. I am treating it as intermittent; it does not touch the code this PR changes (the delete path).Coverage
Invariant: every piece of a continuous aggregate's refresh state whose loss on a promoted follower produces a wrong aggregate either reaches the followers, or can be recovered from replicated data.
TimeSeriesShard.appendSamples->invalidateContinuousAggregatesBehindWatermark(SQL INSERT, engine API, async, line protocol, gateways)TimeSeriesEngine.deleteSamples(insiderunWithCompactionReplication)ContinuousAggregateRefresher.refreshOncerefreshOnce->clearInvalidationContinuousAggregateBuilder.createKnown gaps
Adversarial pass
The subagent spawning tool was not available in this run, so the author did this pass as a self-review. That is weaker than the independent reviewer the workflow asks for. Findings:
Review cycles
NO_SCHEMA_CHANGEamong the fields) and #5 (local-save helper)Deferred / skipped review items
toEpochMson every bucket value its query returns, so such an aggregate failed every refresh before this change too.invalidateContinuousAggregatesBehindWatermark.Final state
clean-approval (3 cycles). CodeRabbit was rate-limited and did not review. Codacy reports 1 minor CodeStyle issue.
🤖 Generated with Claude Code