v0.6.72: billing pool contention fix#4496
Conversation
TheodoreSpeaks
commented
May 7, 2026
- fix(billing): drop transaction wrapper in recordUsage to relieve pool contention (fix(billing): drop transaction wrapper in recordUsage to relieve pool contention #4494)
… contention (#4494) * fix(billing): drop transaction wrapper in recordUsage to relieve pool contention * fix(billing): always warn on userStats drift in recordUsage
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview
Reviewed by Cursor Bugbot for commit ec5793f. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR removes the
Confidence Score: 4/5Safe to merge — the fix correctly addresses pool contention and the data durability trade-offs are clearly documented and intentional. The change is well-reasoned and the comments document the trade-offs clearly. The one gap is that all userStats UPDATE failures — including transient ones — are permanently dropped rather than retried, which could widen counter drift more than necessary. apps/sim/lib/billing/core/usage-log.ts — specifically the catch block in recordUsage and any downstream callers that read currentPeriodCost / totalCost from userStats to enforce billing limits. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant recordUsage
participant DB_usageLog as DB: usage_log
participant DB_userStats as DB: user_stats
Caller->>recordUsage: recordUsage(params)
alt "validEntries.length > 0"
recordUsage->>DB_usageLog: INSERT rows (propagates errors)
DB_usageLog-->>recordUsage: OK / throws
end
recordUsage->>DB_userStats: UPDATE userStats (lastActive, totalCost, currentPeriodCost)
alt UPDATE succeeds, row found
DB_userStats-->>recordUsage: "[{userId}]"
recordUsage-->>Caller: void
else UPDATE succeeds, row NOT found
DB_userStats-->>recordUsage: []
recordUsage->>recordUsage: logger.warn (counter dropped)
recordUsage-->>Caller: void
else UPDATE throws
DB_userStats-->>recordUsage: error
recordUsage->>recordUsage: logger.warn (counter dropped)
recordUsage-->>Caller: void
end
Reviews (1): Last reviewed commit: "fix(billing): drop transaction wrapper i..." | Re-trigger Greptile |