Skip to content

Add Collation Checker quick commands

This code change reorganizes how database diagnostic commands are handled in a GitLab troubleshooting tool. Instead of having one database query mixed in with other system commands, the code now groups all database-related checks into their own separate section.

The change moves an existing database query that checks for unanalyzed tables and adds two new database health checks: one that identifies database collation version mismatches (which can cause sorting and comparison issues), and another that detects duplicate entries in a specific database table related to build tags.

This reorganization makes the code cleaner and more maintainable while expanding the tool's ability to diagnose potential database problems that could affect GitLab's performance.

$ gdk psql -c "SELECT
              collname AS collation_name,
              collprovider AS provider,
              collversion AS stored_version,
              pg_collation_actual_version(oid) AS actual_version
            FROM pg_collation
            WHERE collprovider = 'c'
              AND collversion IS NOT NULL
              AND pg_collation_actual_version(oid) IS NOT NULL
              AND collversion <> pg_collation_actual_version(oid)
            ORDER BY collname;"
 collation_name | provider | stored_version | actual_version
----------------+----------+----------------+----------------
(0 rows)

$ gdk psql -c "SELECT CASE WHEN EXISTS (
                SELECT 1 FROM
                (SELECT tag_id, build_id, partition_id, COUNT(*)
                 FROM p_ci_build_tags
                 GROUP BY tag_id, build_id, partition_id
                 HAVING COUNT(*) > 1 LIMIT 1) AS dups
              ) THEN 'true' ELSE 'false' END AS duplicates_exist;"
 duplicates_exist
------------------
 false
(1 row)

Testing

Ran the gitlabsos.rb in self-managed instance and it creates new files correctly with correct value:

Screenshot 2025-06-26 at 11.26.33.png

Screenshot 2025-06-26 at 11.31.47.png

Edited by Bishwa Hang Rai

Merge request reports

Loading