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

Fix off-by-one-error in synapse_port_db #9991

Merged
merged 3 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .buildkite/postgres-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# CI's Docker setup at the point where this file is considered.
server_name: "localhost:8800"

signing_key_path: "/src/.buildkite/test.signing.key"
signing_key_path: ".buildkite/test.signing.key"
Copy link
Member Author

Choose a reason for hiding this comment

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

the /src was redundant, inconsistent with the relative database: ".buildkite/test_db.db" in sqlite-config.yaml, and made it fiddly to test outside docker.


report_stats: false

Expand All @@ -16,6 +16,4 @@ database:
database: synapse

# Suppress the key server warning.
trusted_key_servers:
- server_name: "matrix.org"
suppress_key_server_warning: true
trusted_key_servers: []
Copy link
Member Author

Choose a reason for hiding this comment

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

this is a more concise way to suppress the warning.

4 changes: 4 additions & 0 deletions .buildkite/scripts/test_synapse_port_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ scripts-dev/update_database --database-config .buildkite/sqlite-config.yaml
echo "+++ Run synapse_port_db against test database"
coverage run scripts/synapse_port_db --sqlite-database .buildkite/test_db.db --postgres-config .buildkite/postgres-config.yaml

# We should be able to run twice against the same database.
echo "+++ Run synapse_port_db a second time"
coverage run scripts/synapse_port_db --sqlite-database .buildkite/test_db.db --postgres-config .buildkite/postgres-config.yaml

#####

# Now do the same again, on an empty database.
Expand Down
6 changes: 2 additions & 4 deletions .buildkite/sqlite-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# schema and run background updates on it.
server_name: "localhost:8800"

signing_key_path: "/src/.buildkite/test.signing.key"
signing_key_path: ".buildkite/test.signing.key"

report_stats: false

Expand All @@ -13,6 +13,4 @@ database:
database: ".buildkite/test_db.db"

# Suppress the key server warning.
trusted_key_servers:
- server_name: "matrix.org"
suppress_key_server_warning: true
trusted_key_servers: []
1 change: 1 addition & 0 deletions changelog.d/9991.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a bug introduced in v1.26.0 which meant that `synapse_port_db` would not correctly initialise some postgres sequences, requiring manual updates afterwards.
2 changes: 1 addition & 1 deletion scripts/synapse_port_db
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ class Porter(object):
def r(txn):
txn.execute(
"ALTER SEQUENCE event_auth_chain_id RESTART WITH %s",
(curr_chain_id,),
(curr_chain_id + 1,),
Copy link
Member Author

Choose a reason for hiding this comment

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

this was added in #9449, but I think it was wrong. compare with other ALTER SEQUENCE incantations in this script.

)

if curr_chain_id is not None:
Expand Down