Conversation
Persist aggregation completion state and defer month-boundary snapshots for one recovery cycle after long gaps. Replace snapshots transactionally and propagate snapshot generations to quota readers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3298 +/- ##
=============================================
- Coverage 64.24% 50.65% -13.59%
+ Complexity 10398 8722 -1676
=============================================
Files 840 940 +100
Lines 71755 81058 +9303
Branches 8611 9786 +1175
=============================================
- Hits 46099 41061 -5038
- Misses 23004 36585 +13581
- Partials 2652 3412 +760 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Fixes AMBRY-14502.
During the Aug 2026 prod-lva1 incident, account 1085's monthly
STORAGE_IN_GBbaseline was about 18 TB below peer fabrics. Once aggregation caught up, the apparent monthly delta jumped from about 13 TB to 31.5 TB and uploads began receiving 429s.The actual task order is current aggregation write first, monthly rollover second. Because
AggregatedAccountReports.updatedAtis refreshed by changed-row writes and host report timestamps do not prove report completeness, neither is a safe completed-run signal. This change adds a small durable aggregation state instead:This can slightly under-report usage for the remainder of a recovered month because the corrected baseline starts near zero. That is intentional: avoiding customer-facing 429s from a stale baseline is the higher-priority failure mode.
Deployment and rollback
The DDL adds nullable/defaulted columns and is backward compatible. Required rollout order is:
That order matters because an old aggregator can rewrite a same-month monthly table without incrementing the new snapshot version. Fully detecting that case would require a broader trigger/schema protocol or expensive snapshot fingerprinting.
For rollback, roll back quota readers first and aggregators second; retain the additive DDL. Existing binaries ignore the added columns, and retaining them preserves recovery state for a subsequent redeploy.
Durability risk
This does not change blob write/delete paths or client success callbacks. It changes quota metadata only. Monthly snapshot replacement and its state/version transition are transactional; SQL failures roll back rather than exposing an empty or partially replaced monthly table. Current aggregate writes are never suppressed, including when the recovery-state read fails.
Testing Done
JAVA_HOME=$(/usr/libexec/java_home -v 17) ./gradlew :ambry-clustermap:test --tests 'com.github.ambry.clustermap.MySqlReportAggregatorTaskTest' :ambry-mysql:test --tests 'com.github.ambry.accountstats.AggregatedAccountReportsDaoTest' :ambry-quota:test --tests 'com.github.ambry.quota.storage.MySqlStorageUsageRefresherUnitTest'JAVA_HOME=$(/usr/libexec/java_home -v 17) ./gradlew :ambry-api:test :ambry-mysql:test :ambry-clustermap:test :ambry-quota:testJAVA_HOME=$(/usr/libexec/java_home -v 17) ./gradlew :ambry-mysql:compileIntegrationTestJava :ambry-quota:compileIntegrationTestJavaambry_container_storage_statsMySQL service is available; the integration test sources compile../gradlew build -x testreaches an existing unrelated repository enforcement failure atHostThrottleConfig.java:120for directObjectMapperconstruction.