From e3ec6e2922cea629ed900aeb9a868a19dfe89c65 Mon Sep 17 00:00:00 2001 From: Sami Hiltunen Date: Mon, 4 Apr 2022 15:23:47 +0300 Subject: 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. --- _support/praefect-schema.sql | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '_support') 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 @@ -557,6 +557,13 @@ CREATE UNIQUE INDEX shard_node_names_on_node_status_idx ON public.node_status US CREATE UNIQUE INDEX storage_repositories_new_pkey ON public.storage_repositories USING btree (repository_id, storage); +-- +-- 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: - -- -- cgit v1.2.3