Add sequence synchronization between geo sites

What does this MR do and why?

PostgreSQL logical replication does not replicate sequence values. After Geo failover, creating new records causes PG::UniqueViolation errors because sequences still have their old values while replicated data has higher IDs.

This MR adds sync_sequences_with_table_data to Gitlab::Geo::GeoTasks which automatically runs during geo:set_secondary_as_primary when in logical replication mode. It sets each sequence to MAX(id) from its table (or the sequence's min_value, whichever is greater, to respect Cells configuration).

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.

Related to #593337 (closed)

Merge request reports

Loading
Loading