test(analysis): assert Cancelled event is published; correct cron-test rationale (0.87.21)

0.87.13 followup. The Cancelled publish had no asserting test —
mechanical revert of the publish block shipped green. New sqlx test
subscribes before spawn, drives SlowDispatcher into flight, cancels,
asserts both Started and Cancelled frames with breadcrumb fields.
Mutation-confirmed.

Also corrects: cron-test rationale comment (inverted unlock-axis),
Cancelled docstring (self-contradicting clear-triggers sentence).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-06-23 20:46:08 +02:00
parent e3e86843d6
commit a62a5f155b
6 changed files with 107 additions and 12 deletions

View File

@@ -896,11 +896,12 @@ async fn cron_shutdown_does_not_block_on_in_flight_metadata_pass(pool: PgPool) {
);
// The advisory lock must be released so another replica's cron can
// pick up the slot. Without this assertion, a refactor that moved
// the `pg_advisory_unlock` under the cancel arm (instead of running
// unconditionally below the select!) would ship green — only to
// wedge multi-replica deployments where the second replica's cron
// would block on `pg_try_advisory_lock` forever. `pg_try_advisory_lock`
// pick up the slot. The 0.87.4 fix runs `pg_advisory_unlock`
// UNCONDITIONALLY below the `tokio::select!` — both the
// cancel-arm and the body-completed paths converge there. Without
// this assertion, a refactor that moved the unlock INTO the
// body-completed arm only (skipping the cancel path) would ship
// green under shutdown-latency-only coverage. `pg_try_advisory_lock`
// returns true iff the lock is free, so we use it as the probe.
let acquired: bool = sqlx::query_scalar("SELECT pg_try_advisory_lock($1)")
.bind(CRON_LOCK_KEY)