Fix: Leasing for payload job (#2609)

* refactor: acquire a lease instead of an advisory lock

* refactor: partition dates

* fix: single query to acquire / extend

* fix: explicit alias

* fix: unwind

* fix: hwere clause

* fix: handle no rows

* fix: lease bug

* fix: rm debug

* fix: comment for clarity

* fix: syntax that doesn't actually matter

* fix: error
This commit is contained in:
matt
2025-12-05 13:55:59 -05:00
committed by GitHub
parent 18940869ae
commit 7e48ac7d02
6 changed files with 148 additions and 108 deletions
@@ -0,0 +1,14 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE v1_payload_cutover_job_offset
ADD COLUMN lease_process_id UUID NOT NULL DEFAULT gen_random_uuid(),
ADD COLUMN lease_expires_at TIMESTAMPTZ NOT NULL DEFAULT NOW();
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
ALTER TABLE v1_payload_cutover_job_offset
DROP COLUMN lease_expires_at,
DROP COLUMN lease_process_id;
-- +goose StatementEnd