Add gitlab:db:collation_checker rake task
What does this MR do and why?
This merge request adds a new database maintenance tool called "CollationChecker" that helps identify and fix PostgreSQL database issues that can occur when the operating system is upgraded.
The tool scans the database to find mismatches between stored and actual collation versions (which control how text is sorted and compared). When mismatches are found, it identifies which database indexes are affected and provides step-by-step instructions to fix them, including SQL commands to rebuild indexes and refresh collation versions.
The checker includes safety features like detecting duplicate data that could cause problems during repairs, and provides two repair options - one that minimizes downtime and another that's faster but requires taking the system offline.
A new command-line task is added so administrators can run the checker manually, and comprehensive tests ensure it works correctly in various scenarios including when no issues exist, when issues exist but don't affect indexes, and when critical repairs are needed.
This tool helps prevent database corruption and performance issues that can happen after OS upgrades, making GitLab more reliable and easier to maintain.
References
Database
Note: These will be run as maintenance task and not on live application code.
- Find Collation mismatch:
- Find possible indexes:
How to set up and validate locally
-
Run the rake task:
bin/rails gitlab:db:collation_checker # GitLab | DB | Check for PostgreSQL collation mismatches and list affected indexes bin/rails gitlab:db:collation_checker:ci # GitLab | DB | Check for PostgreSQL collation mismatches on the ci database bin/rails gitlab:db:collation_checker:main # GitLab | DB | Check for PostgreSQL collation mismatches on the main database
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.