Zoekt repositories schema version
This code change enhances a monitoring system that tracks Zoekt (a code search engine) performance metrics.
The main improvement adds a new metric to monitor repositories that haven't been updated to the latest schema version. Previously, the system only tracked how many search tasks were waiting to be processed. Now it also counts how many repositories are running on outdated database schemas for each search node.
The code was restructured to handle multiple types of data collection - it now runs two separate database queries and combines their results. The first query (renamed for clarity) still gets the task processing queue information, while the new second query checks repository schema versions across different search nodes.
Error handling was also improved - instead of completely failing when one query has issues, the system now continues and reports whatever data it can successfully collect. This makes the monitoring more resilient.
The changes include updated tests to verify both the new functionality and the improved error handling work correctly. Overall, this gives administrators better visibility into both the search system's current workload and whether their repositories need schema updates.
| Before | After |
|---|---|
![]() |
![]() |
Test locally
- Switch to the MR branch.
- Start the server
bin/gitlab-exporter web -c config/gitlab-exporter.yml
- Visit http://localhost:9168/database
- You should see the
search_zoekt_repositories_schema_version_countat the bottom
Query reports
SELECT schema_version, id FROM zoekt_nodes
SELECT count(*)
FROM zoekt_repositories zr INNER JOIN zoekt_indices zi ON zr.zoekt_index_id = zi.id
WHERE zi.zoekt_node_id = 58 AND zr.schema_version < 2531 AND zr.state=10

