Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unique_user_filter_index schema update #6175

Merged
merged 2 commits into from Oct 7, 2019

Conversation

@babolivier
Copy link
Member

babolivier commented Oct 7, 2019

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 added 2 commits Oct 7, 2019
@babolivier babolivier requested a review from matrix-org/synapse-core Oct 7, 2019
@babolivier babolivier added this to In progress in Homeserver Task Board via automation Oct 7, 2019
@babolivier

This comment has been minimized.

Copy link
Member 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 left a comment

LGTM!

@babolivier babolivier moved this from In progress to Review in Homeserver Task Board Oct 7, 2019
@babolivier babolivier merged commit 97e2722 into develop Oct 7, 2019
18 checks passed
18 checks passed
buildkite/synapse Build #4807 passed (29 minutes, 36 seconds)
Details
buildkite/synapse/check-sample-config Passed (1 minute, 28 seconds)
Details
buildkite/synapse/check-style Passed (1 minute, 33 seconds)
Details
buildkite/synapse/isort Passed (42 seconds)
Details
buildkite/synapse/mypy Passed (23 seconds)
Details
buildkite/synapse/newspaper-newsfile Passed (42 seconds)
Details
buildkite/synapse/packaging Passed (17 seconds)
Details
buildkite/synapse/pipeline Passed (2 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-postgres-9-dot-5 Passed (17 minutes, 47 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite Passed (6 minutes, 7 seconds)
Details
buildkite/synapse/python-3-dot-5-slash-sqlite-slash-old-deps Passed (7 minutes, 54 seconds)
Details
buildkite/synapse/python-3-dot-6-slash-sqlite Passed (6 minutes, 17 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-11 Passed (18 minutes, 32 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-postgres-9-dot-5 Passed (18 minutes, 5 seconds)
Details
buildkite/synapse/python-3-dot-7-slash-sqlite Passed (5 minutes, 54 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-monolith Passed (12 minutes, 11 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-postgres-9-dot-6-slash-workers Passed (14 minutes, 15 seconds)
Details
buildkite/synapse/sytest-python-3-dot-5-slash-sqlite-slash-monolith Passed (12 minutes, 55 seconds)
Details
Homeserver Task Board automation moved this from Review to Done Oct 7, 2019
babolivier added a commit that referenced this pull request Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.