diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2022-04-04 15:23:47 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2022-04-20 13:37:25 +0300 |
commit | e3ec6e2922cea629ed900aeb9a868a19dfe89c65 (patch) | |
tree | 8a4dcf3f4b60526e328d6c5116193f898be579d1 /_support | |
parent | 9413ca591ebe30dcb133c86d0ec53f6bc2fc30bb (diff) |
Release expired verification leases periodically
The background verifier sets a lease time on a replica when it picks
it up for verification. If the worker dies for some reason, the lease
will remain in place and no other worker will pick up the replica for
verification again until the lease is cleared. The lease itself tells
the maximum time the worker itself would be working on the replica.
After it has been passed, it would be safe for another worker to pick
up the replica for verification again. This commit adds a background
goroutine that periodically releases expired leases so other workers
can take up the work if the original worker failed and did not release
the lease. The 'verificaton_leases' index is added so the query can
efficiently find the replicas with leases acquired to find the stale
ones.
Diffstat (limited to '_support')
-rw-r--r-- | _support/praefect-schema.sql | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/_support/praefect-schema.sql b/_support/praefect-schema.sql index 78316e80c..813d4fa89 100644 --- a/_support/praefect-schema.sql +++ b/_support/praefect-schema.sql @@ -558,6 +558,13 @@ CREATE UNIQUE INDEX storage_repositories_new_pkey ON public.storage_repositories -- +-- Name: verification_leases; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX verification_leases ON public.storage_repositories USING btree (verification_leased_until) WHERE (verification_leased_until IS NOT NULL); + + +-- -- Name: verification_queue; Type: INDEX; Schema: public; Owner: - -- |