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

Commit 237f3fe

Browse files
committed
Merge pull request #6464 from matrix-org/erikj/make_public_sql_base
* commit 'ddbbfc951': Newsfile Remove underscore from SQLBaseStore functions Don't call SQLBaseStore methods from outside stores
2 parents f6c28ac + ddbbfc9 commit 237f3fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+577
-578
lines changed

changelog.d/6464.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prepare SQLBaseStore functions being moved out of the stores.

scripts-dev/hash_history.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Store(object):
2727
"_store_pdu_reference_hash_txn"
2828
]
2929
_store_prev_pdu_hash_txn = SignatureStore.__dict__["_store_prev_pdu_hash_txn"]
30-
_simple_insert_txn = SQLBaseStore.__dict__["_simple_insert_txn"]
30+
simple_insert_txn = SQLBaseStore.__dict__["simple_insert_txn"]
3131

3232

3333
store = Store()

scripts/synapse_port_db

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class Porter(object):
223223
def setup_table(self, table):
224224
if table in APPEND_ONLY_TABLES:
225225
# It's safe to just carry on inserting.
226-
row = yield self.postgres_store._simple_select_one(
226+
row = yield self.postgres_store.simple_select_one(
227227
table="port_from_sqlite3",
228228
keyvalues={"table_name": table},
229229
retcols=("forward_rowid", "backward_rowid"),
@@ -238,7 +238,7 @@ class Porter(object):
238238
)
239239
backward_chunk = 0
240240
else:
241-
yield self.postgres_store._simple_insert(
241+
yield self.postgres_store.simple_insert(
242242
table="port_from_sqlite3",
243243
values={
244244
"table_name": table,
@@ -268,7 +268,7 @@ class Porter(object):
268268

269269
yield self.postgres_store.execute(delete_all)
270270

271-
yield self.postgres_store._simple_insert(
271+
yield self.postgres_store.simple_insert(
272272
table="port_from_sqlite3",
273273
values={"table_name": table, "forward_rowid": 1, "backward_rowid": 0},
274274
)
@@ -322,7 +322,7 @@ class Porter(object):
322322
if table == "user_directory_stream_pos":
323323
# We need to make sure there is a single row, `(X, null), as that is
324324
# what synapse expects to be there.
325-
yield self.postgres_store._simple_insert(
325+
yield self.postgres_store.simple_insert(
326326
table=table, values={"stream_id": None}
327327
)
328328
self.progress.update(table, table_size) # Mark table as done
@@ -377,7 +377,7 @@ class Porter(object):
377377
def insert(txn):
378378
self.postgres_store.insert_many_txn(txn, table, headers[1:], rows)
379379

380-
self.postgres_store._simple_update_one_txn(
380+
self.postgres_store.simple_update_one_txn(
381381
txn,
382382
table="port_from_sqlite3",
383383
keyvalues={"table_name": table},
@@ -454,7 +454,7 @@ class Porter(object):
454454
],
455455
)
456456

457-
self.postgres_store._simple_update_one_txn(
457+
self.postgres_store.simple_update_one_txn(
458458
txn,
459459
table="port_from_sqlite3",
460460
keyvalues={"table_name": "event_search"},
@@ -593,11 +593,11 @@ class Porter(object):
593593

594594
# Step 2. Get tables.
595595
self.progress.set_state("Fetching tables")
596-
sqlite_tables = yield self.sqlite_store._simple_select_onecol(
596+
sqlite_tables = yield self.sqlite_store.simple_select_onecol(
597597
table="sqlite_master", keyvalues={"type": "table"}, retcol="name"
598598
)
599599

600-
postgres_tables = yield self.postgres_store._simple_select_onecol(
600+
postgres_tables = yield self.postgres_store.simple_select_onecol(
601601
table="information_schema.tables",
602602
keyvalues={},
603603
retcol="distinct table_name",
@@ -724,7 +724,7 @@ class Porter(object):
724724
next_chunk = yield self.sqlite_store.execute(get_start_id)
725725
next_chunk = max(max_inserted_rowid + 1, next_chunk)
726726

727-
yield self.postgres_store._simple_insert(
727+
yield self.postgres_store.simple_insert(
728728
table="port_from_sqlite3",
729729
values={
730730
"table_name": "sent_transactions",

synapse/app/homeserver.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ def phone_stats_home(hs, stats, stats_process=_stats_process):
542542
# Database version
543543
#
544544

545-
stats["database_engine"] = hs.get_datastore().database_engine_name
546-
stats["database_server_version"] = hs.get_datastore().get_server_version()
545+
stats["database_engine"] = hs.database_engine.module.__name__
546+
stats["database_server_version"] = hs.database_engine.server_version
547547
logger.info("Reporting stats to %s: %s" % (hs.config.report_stats_endpoint, stats))
548548
try:
549549
yield hs.get_proxied_http_client().put_json(

synapse/app/user_dir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, db_conn, hs):
6464
super(UserDirectorySlaveStore, self).__init__(db_conn, hs)
6565

6666
events_max = self._stream_id_gen.get_current_token()
67-
curr_state_delta_prefill, min_curr_state_delta_id = self._get_cache_dict(
67+
curr_state_delta_prefill, min_curr_state_delta_id = self.get_cache_dict(
6868
db_conn,
6969
"current_state_delta_stream",
7070
entity_column="room_id",

synapse/push/bulk_push_rule_evaluator.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,7 @@ def _update_rules_with_member_event_ids(
386386
"""
387387
sequence = self.sequence
388388

389-
rows = yield self.store._simple_select_many_batch(
390-
table="room_memberships",
391-
column="event_id",
392-
iterable=member_event_ids.values(),
393-
retcols=("user_id", "membership", "event_id"),
394-
keyvalues={},
395-
batch_size=500,
396-
desc="_get_rules_for_member_event_ids",
397-
)
389+
rows = yield self.store.get_membership_from_event_ids(member_event_ids.values())
398390

399391
members = {row["event_id"]: (row["user_id"], row["membership"]) for row in rows}
400392

0 commit comments

Comments
 (0)