diff options
author | Jason Little <realtyem@gmail.com> | 2023-06-14 03:42:18 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 09:42:18 +0100 |
commit | 21fea6b7493533985f7fa14924949514b5a356e2 (patch) | |
tree | 757eb51f5248c1f87218fc20e578d35d4c57a151 /synapse/storage/databases | |
parent | Document `looping_call()` functionality that will wait for the given function... (diff) | |
download | synapse-21fea6b7493533985f7fa14924949514b5a356e2.tar.xz |
Prefill events after invalidate not before when persisting events (#15758)
Fixes #15757
Diffstat (limited to 'synapse/storage/databases')
-rw-r--r-- | synapse/storage/databases/main/events.py | 15 | ||||
-rw-r--r-- | synapse/storage/databases/main/events_worker.py | 2 |
2 files changed, 13 insertions, 4 deletions
diff --git a/synapse/storage/databases/main/events.py b/synapse/storage/databases/main/events.py index e2e6eb479f..44af3357af 100644 --- a/synapse/storage/databases/main/events.py +++ b/synapse/storage/databases/main/events.py @@ -1729,13 +1729,22 @@ class PersistEventsStore: if not row["rejects"] and not row["redacts"]: to_prefill.append(EventCacheEntry(event=event, redacted_event=None)) - async def prefill() -> None: + async def external_prefill() -> None: for cache_entry in to_prefill: - await self.store._get_event_cache.set( + await self.store._get_event_cache.set_external( (cache_entry.event.event_id,), cache_entry ) - txn.async_call_after(prefill) + def local_prefill() -> None: + for cache_entry in to_prefill: + self.store._get_event_cache.set_local( + (cache_entry.event.event_id,), cache_entry + ) + + # The order these are called here is not as important as knowing that after the + # transaction is finished, the async_call_after will run before the call_after. + txn.async_call_after(external_prefill) + txn.call_after(local_prefill) def _store_redaction(self, txn: LoggingTransaction, event: EventBase) -> None: assert event.redacts is not None diff --git a/synapse/storage/databases/main/events_worker.py b/synapse/storage/databases/main/events_worker.py index d93ffc4efa..7e7648c951 100644 --- a/synapse/storage/databases/main/events_worker.py +++ b/synapse/storage/databases/main/events_worker.py @@ -883,7 +883,7 @@ class EventsWorkerStore(SQLBaseStore): async def _invalidate_async_get_event_cache(self, event_id: str) -> None: """ - Invalidates an event in the asyncronous get event cache, which may be remote. + Invalidates an event in the asynchronous get event cache, which may be remote. Arguments: event_id: the event ID to invalidate |