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

Clean up SQLBaseStore private function usage #6464

Merged
merged 3 commits into from
Dec 5, 2019
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
1 change: 1 addition & 0 deletions changelog.d/6464.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prepare SQLBaseStore functions being moved out of the stores.
2 changes: 1 addition & 1 deletion scripts-dev/hash_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Store(object):
"_store_pdu_reference_hash_txn"
]
_store_prev_pdu_hash_txn = SignatureStore.__dict__["_store_prev_pdu_hash_txn"]
_simple_insert_txn = SQLBaseStore.__dict__["_simple_insert_txn"]
simple_insert_txn = SQLBaseStore.__dict__["simple_insert_txn"]


store = Store()
Expand Down
18 changes: 9 additions & 9 deletions scripts/synapse_port_db
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class Porter(object):
def setup_table(self, table):
if table in APPEND_ONLY_TABLES:
# It's safe to just carry on inserting.
row = yield self.postgres_store._simple_select_one(
row = yield self.postgres_store.simple_select_one(
table="port_from_sqlite3",
keyvalues={"table_name": table},
retcols=("forward_rowid", "backward_rowid"),
Expand All @@ -236,7 +236,7 @@ class Porter(object):
)
backward_chunk = 0
else:
yield self.postgres_store._simple_insert(
yield self.postgres_store.simple_insert(
table="port_from_sqlite3",
values={
"table_name": table,
Expand Down Expand Up @@ -266,7 +266,7 @@ class Porter(object):

yield self.postgres_store.execute(delete_all)

yield self.postgres_store._simple_insert(
yield self.postgres_store.simple_insert(
table="port_from_sqlite3",
values={"table_name": table, "forward_rowid": 1, "backward_rowid": 0},
)
Expand Down Expand Up @@ -320,7 +320,7 @@ class Porter(object):
if table == "user_directory_stream_pos":
# We need to make sure there is a single row, `(X, null), as that is
# what synapse expects to be there.
yield self.postgres_store._simple_insert(
yield self.postgres_store.simple_insert(
table=table, values={"stream_id": None}
)
self.progress.update(table, table_size) # Mark table as done
Expand Down Expand Up @@ -375,7 +375,7 @@ class Porter(object):
def insert(txn):
self.postgres_store.insert_many_txn(txn, table, headers[1:], rows)

self.postgres_store._simple_update_one_txn(
self.postgres_store.simple_update_one_txn(
txn,
table="port_from_sqlite3",
keyvalues={"table_name": table},
Expand Down Expand Up @@ -452,7 +452,7 @@ class Porter(object):
],
)

self.postgres_store._simple_update_one_txn(
self.postgres_store.simple_update_one_txn(
txn,
table="port_from_sqlite3",
keyvalues={"table_name": "event_search"},
Expand Down Expand Up @@ -591,11 +591,11 @@ class Porter(object):

# Step 2. Get tables.
self.progress.set_state("Fetching tables")
sqlite_tables = yield self.sqlite_store._simple_select_onecol(
sqlite_tables = yield self.sqlite_store.simple_select_onecol(
table="sqlite_master", keyvalues={"type": "table"}, retcol="name"
)

postgres_tables = yield self.postgres_store._simple_select_onecol(
postgres_tables = yield self.postgres_store.simple_select_onecol(
table="information_schema.tables",
keyvalues={},
retcol="distinct table_name",
Expand Down Expand Up @@ -722,7 +722,7 @@ class Porter(object):
next_chunk = yield self.sqlite_store.execute(get_start_id)
next_chunk = max(max_inserted_rowid + 1, next_chunk)

yield self.postgres_store._simple_insert(
yield self.postgres_store.simple_insert(
table="port_from_sqlite3",
values={
"table_name": "sent_transactions",
Expand Down
4 changes: 2 additions & 2 deletions synapse/app/homeserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,8 @@ def phone_stats_home(hs, stats, stats_process=_stats_process):
# Database version
#

stats["database_engine"] = hs.get_datastore().database_engine_name
stats["database_server_version"] = hs.get_datastore().get_server_version()
stats["database_engine"] = hs.database_engine.module.__name__
stats["database_server_version"] = hs.database_engine.server_version
logger.info("Reporting stats to %s: %s" % (hs.config.report_stats_endpoint, stats))
try:
yield hs.get_proxied_http_client().put_json(
Expand Down
2 changes: 1 addition & 1 deletion synapse/app/user_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, db_conn, hs):
super(UserDirectorySlaveStore, self).__init__(db_conn, hs)

events_max = self._stream_id_gen.get_current_token()
curr_state_delta_prefill, min_curr_state_delta_id = self._get_cache_dict(
curr_state_delta_prefill, min_curr_state_delta_id = self.get_cache_dict(
db_conn,
"current_state_delta_stream",
entity_column="room_id",
Expand Down
10 changes: 1 addition & 9 deletions synapse/push/bulk_push_rule_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,15 +386,7 @@ def _update_rules_with_member_event_ids(
"""
sequence = self.sequence

rows = yield self.store._simple_select_many_batch(
table="room_memberships",
column="event_id",
iterable=member_event_ids.values(),
retcols=("user_id", "membership", "event_id"),
keyvalues={},
batch_size=500,
desc="_get_rules_for_member_event_ids",
)
rows = yield self.store.get_membership_from_event_ids(member_event_ids.values())

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

Expand Down
Loading