Repository navigation
fix(alerts): maintenance window revision guard, locked org cap, shared weekdays - #2343
Conversation
The sync locked the window row and checked updatedAt, which is epoch ms, so a pass that read the window in the same millisecond as an edit could rewrite its silences from the superseded schedule. Every write to the window row now bumps an integer revision and the guard compares that.
createWindow counted the org's windows before its insert transaction, so two concurrent creates could both pass the 100-window cap. The count now runs inside the transaction after an org-scoped advisory lock of its own key.
|
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 26 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. |
Maple review🟢 Confidence 9/10 · safe to merge. The revision guard and recount are pinned by new tests; the advisory lock itself is untested because PGlite serialises transactions. Replaces the millisecond
Before merge
|
|
Merged with 1 step from "Before merge" still open. If it is done, tick it on the review comment; if not, now is the time.
|
Three fixes from the #2323 review (maintenance windows).
What changed
updatedAtin milliseconds. A materialize pass that read the window in the same millisecond as an edit could rewrite its silences from the old schedule.revision. It is 1 on create, and every update (enable and disable included) bumps it. The sync locks the row at the revision it read.revision integer NOT NULL DEFAULT 1.pg_advisory_xact_lock(hashtext(org), hashtext('alert_maintenance_windows'))) and recounts inside the transaction. The lock uses two keys, so it never contends with the rule lock. The count before the transaction is gone.MAINTENANCE_WEEKDAYS, andMaintenanceWeekdayis built from it. The MCP copy is deleted, and the create tool imports the domain array.Verification
updatedAtguard the test fails ("expected 4 to equal +0").maincode both succeed and the test fails.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.