-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Remove option to skip locking of tables during emulated upserts #14469
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Remove option to skip locking of tables when performing emulated upserts, to avoid a class of bugs in future. |
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -481,7 +481,6 @@ def _update_profile_in_user_dir_txn(txn: LoggingTransaction) -> None: | |||||||||||||||||
table="user_directory", | ||||||||||||||||||
keyvalues={"user_id": user_id}, | ||||||||||||||||||
values={"display_name": display_name, "avatar_url": avatar_url}, | ||||||||||||||||||
lock=False, # We're only inserter | ||||||||||||||||||
DMRobertson marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
if isinstance(self.database_engine, PostgresEngine): | ||||||||||||||||||
|
@@ -511,7 +510,6 @@ def _update_profile_in_user_dir_txn(txn: LoggingTransaction) -> None: | |||||||||||||||||
table="user_directory_search", | ||||||||||||||||||
keyvalues={"user_id": user_id}, | ||||||||||||||||||
values={"value": value}, | ||||||||||||||||||
lock=False, # We're only inserter | ||||||||||||||||||
Comment on lines
510
to
-514
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unique index exists here for postgres:
... but not for sqlite. It's marked as unsafe to upsert into on sqlite here: synapse/synapse/storage/database.py Lines 534 to 538 in c3a4780
Does that mean that with this change we're now going to start locking synapse/synapse/storage/engines/sqlite.py Lines 103 to 104 in 8c94dd3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good spot with But if locking on sqlite has never done anything, then the rationale for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oops, sorry. That's probably me jumping to conclusions.
I suppose so! But to check: I don't think that suddenly makes it unsafe to remove the footgun? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, it's not unsafe, it just means this PR is rolling back a previous optimization we decided to add. |
||||||||||||||||||
) | ||||||||||||||||||
else: | ||||||||||||||||||
# This should be unreachable. | ||||||||||||||||||
|
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.
Why are we keeping this one conditional?
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.
It's to support
simple_upsert_many_txn_emulated
, which does its own locking beforehand.synapse/synapse/storage/database.py
Lines 1499 to 1509 in 9cae44f