Skip to content

Add ordered in zoekt repository indexing

What does this MR do and why?

This change adds a simple ordering feature to how repositories are processed in a search indexing system.

The main addition is a new "ordered" scope that sorts repositories by their ID number, ensuring they are always processed in a consistent, predictable sequence rather than in random order. This ordering is then applied when the system selects which repositories need to be reindexed, making the process more deterministic.

The change also includes a test to verify that the ordering works correctly by creating three test repositories and confirming they are returned in the expected ID-based sequence.

This is a small but important improvement for system reliability, as consistent ordering can help with debugging, monitoring, and ensuring reproducible behavior when processing batches of repositories.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

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

Query report

SELECT
    "zoekt_repositories".*
FROM
    "zoekt_repositories"
    INNER JOIN "zoekt_indices" ON "zoekt_indices"."id" = "zoekt_repositories"."zoekt_index_id"
    INNER JOIN "zoekt_nodes" ON "zoekt_nodes"."id" = "zoekt_indices"."zoekt_node_id"
WHERE
    "zoekt_repositories"."state" IN (0, 1, 10)
    AND (zoekt_repositories.schema_version != zoekt_nodes.schema_version)
    AND "zoekt_repositories"."id" != 2
ORDER BY
    "zoekt_repositories"."id" ASC
LIMIT 1000

https://console.postgres.ai/shared/31cd1d38-f9c4-4a13-9c66-80008d9210ba

Related to #565031

Edited by Ravi Kumar

Merge request reports

Loading