diff options
author | Erik Johnston <erik@matrix.org> | 2015-06-22 17:17:25 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-06-22 17:17:25 +0100 |
commit | a4ad9b95567cc821b493e4b73477ed9f7cba9932 (patch) | |
tree | cb32d84b49f9e747d9dc99a1291e1d77eebd432b | |
parent | Implement persist_event*s* (diff) | |
download | synapse-a4ad9b95567cc821b493e4b73477ed9f7cba9932.tar.xz |
Only persist a maximum of 100 events at a time
-rw-r--r-- | synapse/storage/events.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py index ec798704dc..f9984b7444 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -416,6 +416,19 @@ class EventsStore(SQLBaseStore): def _persist_events_txn(self, txn, events_and_contexts, backfilled, is_new_state=True): + if len(events_and_contexts) > 100: + chunks = [ + events_and_contexts[x:x+100] + for x in xrange(0, len(events_and_contexts), 100) + ] + + for chunk in chunks: + self._persist_events_txn( + txn, + chunk, backfilled, is_new_state, + ) + return + # Remove the any existing cache entries for the event_ids for event, _ in events_and_contexts: txn.call_after(self._invalidate_get_event_cache, event.event_id) |