Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

check postgres sequences for validity on startup #7938

Open
richvdh opened this issue Jul 23, 2020 · 2 comments · Fixed by #8402
Open

check postgres sequences for validity on startup #7938

richvdh opened this issue Jul 23, 2020 · 2 comments · Fixed by #8402
Labels
T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label)

Comments

@richvdh
Copy link
Member

richvdh commented Jul 23, 2020

in the last two weeks, I've seen two people who have migrated their databases to a new postgres instance and forgotten to copy the sequence generators. At best, this causes confusing errors; at worst, it could lead to corruption.

To save people from shooting themselves in the foot, we could check at startup that there are no rows in the table with IDs above the next number in the sequence, and refuse to start if so.

@neilisfragile neilisfragile added enhancement z-p2 (Deprecated Label) labels Jul 29, 2020
@richvdh richvdh added the Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution label Aug 12, 2020
@richvdh
Copy link
Member Author

richvdh commented Aug 12, 2020

in the meantime, to manually check that your database dump has been correctly imported to your new database:

SELECT last_value FROM state_group_id_seq;

... that should return a value significantly larger than 1.

@richvdh richvdh changed the title sanity-check postgres sequences on startup check postgres sequences for validity on startup Sep 23, 2020
@erikjohnston
Copy link
Member

#8402 fixes this accept for the guest user ID generation, as per: https://github.com/matrix-org/synapse/pull/8402/files#diff-50fc898a46f43529763a3c63716ba0b4R44-R49 .

@erikjohnston erikjohnston reopened this Sep 28, 2020
@DMRobertson DMRobertson added T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. and removed z-enhancement labels Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. Z-Help-Wanted We know exactly how to fix this issue, and would be grateful for any contribution z-p2 (Deprecated Label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants