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

Commit c46f103

Browse files
author
David Robertson
committed
Reword comment
1 parent 089ace2 commit c46f103

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

synapse/storage/database.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,9 +1180,18 @@ async def simple_upsert(
11801180
ignore the `lock` argument). Otherwise this class will use an emulated upsert,
11811181
in which case we want the safer option unless we been VERY CAREFUL.
11821182
1183-
[*]: This class is aware that some tables have unique indices added as
1184-
background updates. It checks at runtime to see if those updates are
1185-
pending: if not, they are deemed safe for use with native upserts.
1183+
[*]: Some tables have unique indices added to them in the background. Those
1184+
tables `T` are keys in the dictionary UNIQUE_INDEX_BACKGROUND_UPDATES,
1185+
where `T` maps to the background update that adds a unique index to `T`.
1186+
This dictionary is maintained by hand.
1187+
1188+
At runtime, we constantly check to see if each of these background updates
1189+
has run. If so, we deem the coresponding table safe to upsert into, because
1190+
we can now use a native insert to do so. If not, we deem the table unsafe
1191+
to upsert into and require an emulated upsert.
1192+
1193+
Tables that do not appear in this dictionary are assumed to have an
1194+
appropriate unique index and therefore be safe to upsert into.
11861195
11871196
Args:
11881197
table: The table to upsert into

0 commit comments

Comments
 (0)