fix(db): write canonical 'canceled' on all cancel paths + cleanup filter (follow-up to #1277)#1453
fix(db): write canonical 'canceled' on all cancel paths + cleanup filter (follow-up to #1277)#1453cristim wants to merge 1 commit into
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 50 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
All cancel write paths (CancelExecutionAtomic, CancelScheduledExecutionAtomic, CancelAllPendingExchanges, CancelPendingExchangesByOrigin) were still emitting status='cancelled' and the old cancelled_by column after PR #1277 added the expand-contract rename. TransitionRIExchangeStatus in handler_ri_exchange.go also used the legacy spelling. If #1278 narrows the CHECK before these writers switch, every cancel path fails with check_violation (SQLSTATE 23514). CleanupOldExecutions filtered only 'cancelled', so rows written by new code with status='canceled' were never terminal-cleaned. Fixes: - Switch all cancel SQL writes to StatusCanceled ("canceled") via $N params - Use canceled_by column in CancelExecutionAtomic + CancelScheduledExecutionAtomic - Add 'canceled' to CleanupOldExecutions terminal-status IN clause - Use config.StatusCanceled in rejectRIExchange handler (line ~1372 + response) - Add 8 pgxmock regression tests asserting canonical spelling per path - Update 4 test mocks that hard-coded "cancelled" as the reject-transition arg
97a1378 to
fa6ae3f
Compare
Summary
Follow-up to #1277 (expand-contract rename 'cancelled'->'canceled'). Three categories of defects verified on current main and fixed.
Defect 1 (medium, latent deploy trap): Every cancel write path still emitted
status='cancelled'and wrotecancelled_byinstead of the canonicalstatus='canceled'/canceled_by. If the contract migration #1278 narrows the CHECK to drop 'cancelled' before these writers switch, every session/RI-exchange cancel path fails with check_violation (SQLSTATE 23514).Paths fixed:
store_postgres.go:CancelExecutionAtomic,CancelScheduledExecutionAtomic- now writestatus=StatusCanceledvia$3param andcanceled_bycolumnstore_postgres.go:CancelAllPendingExchanges,CancelPendingExchangesByOrigin(both branches) - now writestatus=StatusCanceledvia$1paramhandler_ri_exchange.gorejectRIExchange(~line 1372) - usesconfig.StatusCanceledforTransitionRIExchangeStatuscall and response bodyDefect 2 (low, silent cleanup miss):
CleanupOldExecutionsfilteredstatus IN ('completed', 'cancelled')- omitting'canceled', so rows written by new code after #1277 would never be terminal-cleaned.Fixed: added
'canceled'to the IN clause; updated godoc comment.Regression tests added
8 new pgxmock tests in
store_postgres_pgxmock_test.go:TestPGXMock_CancelExecutionAtomic_WritesCanonicalStatus- asserts$3=StatusCanceledandcanceled_bycolumnTestPGXMock_CancelScheduledExecutionAtomic_WritesCanonicalStatus- same for scheduled pathTestPGXMock_CancelAllPendingExchanges_WritesCanonicalStatus- asserts$1=StatusCanceledTestPGXMock_CancelPendingExchangesByOrigin_Standalone_WritesCanonicalStatusTestPGXMock_CancelPendingExchangesByOrigin_Ladder_WritesCanonicalStatusTestPGXMock_CleanupOldExecutions_IncludesCanonicalStatus- regex pins both 'cancelled' and 'canceled' in SQL4 existing tests updated to reflect the canonical spelling (were asserting
"cancelled"as the transition target).Test plan
go build ./...cleango vet ./internal/config/... ./internal/api/...cleango test ./internal/config/...- 650 passedgo test ./internal/api/...- 1767 passedgo test ./internal/...- 5020 passed in 24 packages@coderabbitai review