fix(cost-insights): bound rollup transaction lifecycle#4502
fix(cost-insights): bound rollup transaction lifecycle#4502jeanduplessis wants to merge 1 commit into
Conversation
| }); | ||
| scheduleCostInsightEvaluationAfterSpend(owner); | ||
| }, | ||
| reportError: error => { |
There was a problem hiding this comment.
[WARNING]: Timeout failures leave no durable repair signal
The new lock and statement timeouts can roll back captureCostInsightSpend, including its dirty-owner write, but this error path only logs the failure. Global rollup coverage therefore remains complete, so the hourly sweep can read a missing completed-hour rollup as zero instead of falling back to canonical usage, causing anomaly and threshold alerts to be missed until manual reconciliation. Record a degraded owner-hour/repair request, or otherwise force canonical fallback, before swallowing this failure.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Files Reviewed (5 files)
Reviewed by gpt-5.6-sol-20260709 · Input: 126.9K · Output: 16.4K · Cached: 1.8M Review guidance: REVIEW.md from base branch |
Summary
Prevent Cost Insights rollup transactions from outliving their tracked request lifecycle and creating prolonged database lock convoys.
Why this change is needed
Concurrent AI Gateway rollup writes serialize on one owner-hour unique-index entry. Detached post-commit transactions could finish SQL without reaching commit or rollback before serverless execution ended, retaining locks while queued writers consumed database connections.
How this is addressed
Human Verification
Reviewer Notes
Human Reviewer Flags
microdollar_usagebut do not create a durable dirty-owner marker.Code Reviewer Agent
Code Reviewer Notes
after()callback. Awaiting follow-up work extends that tracked promise while remaining valid for direct admin and script callers that lack request context.