From 465af6714c19c7a7d0b38fd02b626b08d1b6f343 Mon Sep 17 00:00:00 2001 From: Sami Hiltunen Date: Fri, 1 Apr 2022 16:45:07 +0300 Subject: Add migrations for background verification schema This commit adds the necessary schema changes for the metadata background verification. Each replica receives two new columns: 1. 'verified_at' which contains the timestamp of the last successful verification of the replica. This effectively allows for identifying replicas that are in need of reverification. 2. 'verification_leased_until' which contains a timestamp until which a worker has acquired a lease to reverify the repository. This prevents multiple workers from picking the same repository for reverification at the same time. 'verification_queue' index is added to index replicas which have not been acquired by any worker. This allows for efficientl querying replicas that are in need of reverification later. Changelog: other --- _support/praefect-schema.sql | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to '_support') diff --git a/_support/praefect-schema.sql b/_support/praefect-schema.sql index b69a2f0c6..78316e80c 100644 --- a/_support/praefect-schema.sql +++ b/_support/praefect-schema.sql @@ -266,7 +266,9 @@ CREATE TABLE public.storage_repositories ( relative_path text NOT NULL, storage text NOT NULL, generation bigint NOT NULL, - repository_id bigint NOT NULL + repository_id bigint NOT NULL, + verified_at timestamp with time zone, + verification_leased_until timestamp with time zone ); @@ -555,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_queue; Type: INDEX; Schema: public; Owner: - +-- + +CREATE INDEX verification_queue ON public.storage_repositories USING btree (verified_at NULLS FIRST) WHERE (verification_leased_until IS NULL); + + -- -- Name: virtual_target_on_replication_queue_idx; Type: INDEX; Schema: public; Owner: - -- -- cgit v1.2.3