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

Fix unique_user_filter_index schema update #6175

Merged
merged 2 commits into from
Oct 7, 2019

Conversation

babolivier
Copy link
Contributor

Fixes a bug introduced in #1172

Fixes a syntax error in the ALTER TABLE statement (each ALTER COLUMN line must end with a comma, see https://www.postgresql.org/docs/9.6/sql-altertable.html).

@babolivier babolivier requested a review from a team October 7, 2019 12:18
@babolivier
Copy link
Contributor Author

babolivier commented Oct 7, 2019

For context, this bug killed my homeserver:

synapse[31398]: 2019-10-07 12:03:48,690 - root - 236 - WARNING - None- ***** STARTING SERVER *****
synapse[31398]: 2019-10-07 12:03:48,690 - root - 237 - WARNING - None- Server /home/synapse/synapse/synapse/app/homeserver.py version 1.4.0 (b=develop,ae0b78cb1)
synapse[31398]: 2019-10-07 12:03:48,691 - root - 238 - INFO - None- Server hostname: abolivier.bzh
synapse[31398]: 2019-10-07 12:03:48,692 - synapse.app.homeserver - 359 - INFO - None- Preparing database: psycopg2...
synapse[31398]: 2019-10-07 12:03:48,890 - synapse.storage.prepare_database - 249 - INFO - None- Upgrading schema to v56
synapse[31398]: 2019-10-07 12:03:48,894 - synapse.storage.prepare_database - 276 - INFO - None- Running script 56/unique_user_filter_index.py
synapse[31398]: 2019-10-07 12:03:48,896 - twisted - 171 - ERROR - - Traceback (most recent call last):
synapse[31398]: 2019-10-07 12:03:48,897 - twisted - 171 - ERROR - -   File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
synapse[31398]: 2019-10-07 12:03:48,898 - twisted - 171 - ERROR - -     "__main__", mod_spec)
synapse[31398]: 2019-10-07 12:03:48,899 - twisted - 171 - ERROR - -   File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
synapse[31398]: 2019-10-07 12:03:48,899 - twisted - 171 - ERROR - -     exec(code, run_globals)
synapse[31398]: 2019-10-07 12:03:48,900 - twisted - 171 - ERROR - -   File "/home/synapse/synapse/synapse/app/homeserver.py", line 659, in <module>
synapse[31398]: 2019-10-07 12:03:48,901 - twisted - 171 - ERROR - -     main()
synapse[31398]: 2019-10-07 12:03:48,902 - twisted - 171 - ERROR - -   File "/home/synapse/synapse/synapse/app/homeserver.py", line 654, in main
synapse[31398]: 2019-10-07 12:03:48,903 - twisted - 171 - ERROR - -     hs = setup(sys.argv[1:])
synapse[31398]: 2019-10-07 12:03:48,903 - twisted - 171 - ERROR - -   File "/home/synapse/synapse/synapse/app/homeserver.py", line 363, in setup
synapse[31398]: 2019-10-07 12:03:48,904 - twisted - 171 - ERROR - -     prepare_database(db_conn, database_engine, config=config)
synapse[31398]: 2019-10-07 12:03:48,904 - twisted - 171 - ERROR - -   File "/home/synapse/synapse/synapse/storage/prepare_database.py", line 71, in prepare_database
synapse[31398]: 2019-10-07 12:03:48,905 - twisted - 171 - ERROR - -     cur, user_version, delta_files, upgraded, database_engine, config
synapse[31398]: 2019-10-07 12:03:48,906 - twisted - 171 - ERROR - -   File "/home/synapse/synapse/synapse/storage/prepare_database.py", line 279, in _upgrade_existing_database
synapse[31398]: 2019-10-07 12:03:48,906 - twisted - 171 - ERROR - -     module.run_upgrade(cur, database_engine, config=config)
synapse[31398]: 2019-10-07 12:03:48,907 - twisted - 171 - ERROR - -   File "/home/synapse/synapse/synapse/storage/schema/delta/56/unique_user_filter_index.py", line 40, in run_upgrade
synapse[31398]: 2019-10-07 12:03:48,907 - twisted - 171 - ERROR - -     cur.execute(sql)
synapse[31398]: 2019-10-07 12:03:48,908 - twisted - 171 - ERROR - - psycopg2.errors.SyntaxError: syntax error at or near "ALTER"
synapse[31398]: 2019-10-07 12:03:48,908 - twisted - 171 - ERROR - - LINE 12:                ALTER COLUMN filter_id SET NOT NULL
synapse[31398]: 2019-10-07 12:03:48,909 - twisted - 171 - ERROR - -                         ^
synapse[31398]: 2019-10-07 12:03:48,909 - twisted - 171 - ERROR - -
systemd[1]: synapse.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: synapse.service: Failed with result 'exit-code'.

Running this fixed SQL manually on my postgres DB passed with no syntax error. No idea why it hasn't been picked up by CI.

Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@babolivier babolivier merged commit 97e2722 into develop Oct 7, 2019
babolivier added a commit that referenced this pull request Oct 7, 2019
@babolivier babolivier deleted the babolivier/fix_unique_user_filter_index branch January 9, 2020 15:46
babolivier pushed a commit that referenced this pull request Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants