Skip to content

Add zoekt update_replica_states task

John Mason requested to merge jm-zoekt-replica-worker into master

What does this MR do and why?

Adds a task that is run on an interval that will update Zoekt::Replica states depending on the state of their assigned indices.

Related to #467406 (closed) and &14188

Query Plans

Finding ready replicas

SELECT "zoekt_replicas".* FROM "zoekt_replicas" INNER JOIN "zoekt_indices" "indices" ON "indices"."zoekt_replica_id" = "zoekt_replicas"."id" WHERE "zoekt_replicas"."state" = 0 AND "indices"."state" = 10 GROUP BY "zoekt_replicas"."id", "indices"."id" HAVING (count(indices.id) = (SELECT count(zi.id) FROM zoekt_indices zi WHERE zi.zoekt_replica_id = zoekt_replicas.id))

https://console.postgres.ai/gitlab/gitlab-production-main/sessions/29710/commands/92221

Time: 168.931 ms  
  - planning: 2.228 ms  
  - execution: 166.703 ms  
    - I/O read: 154.209 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 4078 (~31.90 MiB) from the buffer pool  
  - reads: 203 (~1.60 MiB) from the OS file cache, including disk I/O  
  - dirtied: 6 (~48.00 KiB)  
  - writes: 0  

Finding non ready replicas

SELECT "zoekt_replicas".* FROM "zoekt_replicas" INNER JOIN "zoekt_indices" "indices" ON "indices"."zoekt_replica_id" = "zoekt_replicas"."id" WHERE "zoekt_replicas"."state" = 10 AND "indices"."state" != 10

https://postgres.ai/console/gitlab/gitlab-production-main/sessions/29710/commands/92222

Time: 2.818 ms  
  - planning: 1.946 ms  
  - execution: 0.872 ms  
    - I/O read: 0.765 ms  
    - I/O write: 0.000 ms  
  
Shared buffers:  
  - hits: 3 (~24.00 KiB) from the buffer pool  
  - reads: 1 (~8.00 KiB) from the OS file cache, including disk I/O  
  - dirtied: 0  
  - writes: 0  

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

Edited by John Mason

Merge request reports