diff options
author | Erik Johnston <erikj@jki.re> | 2018-08-02 10:41:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-02 10:41:42 +0100 |
commit | 40c1c59cf427591237029a781f7ff9f7e41a2412 (patch) | |
tree | 299306281aa31697cc516526cd0b0e9ab923eab0 /synapse/storage | |
parent | Merge pull request #3630 from matrix-org/neilj/mau_sign_in_log_in_limits (diff) | |
parent | update docs (diff) | |
download | synapse-40c1c59cf427591237029a781f7ff9f7e41a2412.tar.xz |
Merge pull request #3621 from matrix-org/erikj/split_fed_store
Split out DB writes in federation handler
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/events.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 61223da1a5..e8e5a0fe44 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -241,12 +241,18 @@ class EventsStore(EventFederationStore, EventsWorkerStore, BackgroundUpdateStore self._state_resolution_handler = hs.get_state_resolution_handler() + @defer.inlineCallbacks def persist_events(self, events_and_contexts, backfilled=False): """ Write events to the database Args: events_and_contexts: list of tuples of (event, context) - backfilled: ? + backfilled (bool): Whether the results are retrieved from federation + via backfill or not. Used to determine if they're "new" events + which might update the current state etc. + + Returns: + Deferred[int]: the stream ordering of the latest persisted event """ partitioned = {} for event, ctx in events_and_contexts: @@ -263,10 +269,14 @@ class EventsStore(EventFederationStore, EventsWorkerStore, BackgroundUpdateStore for room_id in partitioned: self._maybe_start_persisting(room_id) - return make_deferred_yieldable( + yield make_deferred_yieldable( defer.gatherResults(deferreds, consumeErrors=True) ) + max_persisted_id = yield self._stream_id_gen.get_current_token() + + defer.returnValue(max_persisted_id) + @defer.inlineCallbacks @log_function def persist_event(self, event, context, backfilled=False): |