This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Update synapse_port_db for new sequences #15965
Closed
Closed
+27
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This makes sure we that the port script sets up the "application_services_txns" sequence (matrix-org#12209). and the "un_partial_stated_event_stream_sequence" sequence (matrix-org#14545), which fixes errors like the one below from appearing when trying to connect to the postgresql database after running the script: Postgres sequence 'application_services_txn_id_seq' is inconsistent with associated table 'application_services_txns'. This can happen if Synapse has been downgraded and then upgraded again, or due to a bad migration. To fix this error, shut down Synapse (including any and all workers) and run the following SQL: SELECT setval('application_services_txn_id_seq', ( SELECT GREATEST(MAX(txn_id), 0) FROM application_services_txns )); See docs/postgres.md for more information. Signed-off-by: Guacamolie <guac@amolie.nl>
vanguacamolie
force-pushed
the
fix-portdb
branch
from
July 20, 2023 00:15
460200e
to
2109233
Compare
clokep
reviewed
Jul 24, 2023
Comment on lines
+1150
to
+1160
def r(txn: LoggingTransaction) -> None: | ||
txn.execute( | ||
"ALTER SEQUENCE application_services_txn_id_seq RESTART WITH %s", | ||
(curr_tnx_id + 1,), | ||
) | ||
|
||
if curr_tnx_id is not None: | ||
await self.postgres_store.db_pool.runInteraction( | ||
"_setup_application_services_sequence", | ||
r, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will fix the mypy issue:
Suggested change
def r(txn: LoggingTransaction) -> None: | |
txn.execute( | |
"ALTER SEQUENCE application_services_txn_id_seq RESTART WITH %s", | |
(curr_tnx_id + 1,), | |
) | |
if curr_tnx_id is not None: | |
await self.postgres_store.db_pool.runInteraction( | |
"_setup_application_services_sequence", | |
r, | |
) | |
if curr_tnx_id is not None: | |
def r(txn: LoggingTransaction) -> None: | |
txn.execute( | |
"ALTER SEQUENCE application_services_txn_id_seq RESTART WITH %s", | |
(curr_tnx_id + 1,), | |
) | |
await self.postgres_store.db_pool.runInteraction( | |
"_setup_application_services_sequence", | |
r, | |
) |
clokep
reviewed
Jul 24, 2023
Comment on lines
+1142
to
+1144
curr_tnx_id: Optional[ | ||
int | ||
] = await self.sqlite_store.db_pool.simple_select_one_onecol( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this ever really None
since we have the coalesce?
clokep
changed the title
teach synapse_port_db about new sequences
Update synapse_port_db for new sequences
Aug 1, 2023
@vanguacamolie Are you interested in updating this branch? If not, can you mark it as allowing edits by maintainers? |
#16043 is a simpler version of this. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes sure we that the port script sets up the
application_services_txns
sequence (#12209). and theun_partial_stated_event_stream_sequence
sequence (#14545), which fixes errors like the one below from appearing when trying to connect to the postgresql database after running the script:Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)