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

Commit ec73463

Browse files
committed
Stop writing to event_reference_hashes
This table is never read, since #11794. We stop writing to it; in future we can drop it altogether.
1 parent a00462d commit ec73463

File tree

5 files changed

+5
-38
lines changed

5 files changed

+5
-38
lines changed

changelog.d/12679.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Preparation for database schema simplifications: stop writing to `event_reference_hashes`.

synapse/storage/databases/main/events.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import synapse.metrics
3737
from synapse.api.constants import EventContentFields, EventTypes, RelationTypes
3838
from synapse.api.room_versions import RoomVersions
39-
from synapse.crypto.event_signing import compute_event_reference_hash
4039
from synapse.events import EventBase # noqa: F401
4140
from synapse.events.snapshot import EventContext # noqa: F401
4241
from synapse.storage._base import db_to_json, make_in_list_sql_clause
@@ -1600,11 +1599,6 @@ def _update_metadata_tables_txn(
16001599
inhibit_local_membership_updates=inhibit_local_membership_updates,
16011600
)
16021601

1603-
# Insert event_reference_hashes table.
1604-
self._store_event_reference_hashes_txn(
1605-
txn, [event for event, _ in events_and_contexts]
1606-
)
1607-
16081602
# Prefill the event cache
16091603
self._add_to_cache(txn, events_and_contexts)
16101604

@@ -1704,25 +1698,6 @@ def _insert_event_expiry_txn(self, txn, event_id, expiry_ts):
17041698
values={"event_id": event_id, "expiry_ts": expiry_ts},
17051699
)
17061700

1707-
def _store_event_reference_hashes_txn(self, txn, events):
1708-
"""Store a hash for a PDU
1709-
Args:
1710-
txn (cursor):
1711-
events (list): list of Events.
1712-
"""
1713-
1714-
vals = []
1715-
for event in events:
1716-
ref_alg, ref_hash_bytes = compute_event_reference_hash(event)
1717-
vals.append((event.event_id, ref_alg, memoryview(ref_hash_bytes)))
1718-
1719-
self.db_pool.simple_insert_many_txn(
1720-
txn,
1721-
table="event_reference_hashes",
1722-
keys=("event_id", "algorithm", "hash"),
1723-
values=vals,
1724-
)
1725-
17261701
def _store_room_members_txn(
17271702
self, txn, events, *, inhibit_local_membership_updates: bool = False
17281703
):

synapse/storage/databases/main/purge_events.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def _purge_history_txn(
6969
# event_forward_extremities
7070
# event_json
7171
# event_push_actions
72-
# event_reference_hashes
7372
# event_relations
7473
# event_search
7574
# event_to_state_groups
@@ -220,7 +219,6 @@ def _purge_history_txn(
220219
"event_auth",
221220
"event_edges",
222221
"event_forward_extremities",
223-
"event_reference_hashes",
224222
"event_relations",
225223
"event_search",
226224
"rejections",
@@ -369,7 +367,6 @@ def _purge_room_txn(self, txn: LoggingTransaction, room_id: str) -> List[int]:
369367
"event_edges",
370368
"event_json",
371369
"event_push_actions_staging",
372-
"event_reference_hashes",
373370
"event_relations",
374371
"event_to_state_groups",
375372
"event_auth_chains",

synapse/storage/schema/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
SCHEMA_VERSION = 69 # remember to update the list below when updating
15+
SCHEMA_VERSION = 70 # remember to update the list below when updating
1616
"""Represents the expectations made by the codebase about the database schema
1717
1818
This should be incremented whenever the codebase changes its requirements on the
@@ -62,6 +62,9 @@
6262
Changes in SCHEMA_VERSION = 69:
6363
- We now write to `device_lists_changes_in_room` table.
6464
- Use sequence to generate future `application_services_txns.txn_id`s
65+
66+
Changes in SCHEMA_VERSION = 70:
67+
- event_reference_hashes is no longer written.
6568
"""
6669

6770

tests/storage/test_event_federation.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ def insert_event(txn, i):
5858
(room_id, event_id),
5959
)
6060

61-
txn.execute(
62-
(
63-
"INSERT INTO event_reference_hashes "
64-
"(event_id, algorithm, hash) "
65-
"VALUES (?, 'sha256', ?)"
66-
),
67-
(event_id, bytearray(b"ffff")),
68-
)
69-
7061
for i in range(0, 20):
7162
self.get_success(
7263
self.store.db_pool.runInteraction("insert", insert_event, i)

0 commit comments

Comments
 (0)