summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2018-03-05 11:53:39 +0000
committerRichard van der Hoff <richard@matrix.org>2018-03-05 11:53:39 +0000
commit06a14876e5d78891a5b3ae6c0f454faefd696e79 (patch)
tree515ee0fe0035b511760ab98fc726243d08656906
parentMerge pull request #2927 from matrix-org/erikj/read_marker_caches (diff)
downloadsynapse-06a14876e5d78891a5b3ae6c0f454faefd696e79.tar.xz
Add find_first_stream_ordering_after_ts
Expose this as a public function which can be called outside a txn
-rw-r--r--synapse/storage/event_push_actions.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/synapse/storage/event_push_actions.py b/synapse/storage/event_push_actions.py

index 7164293568..54b54dcc6a 100644 --- a/synapse/storage/event_push_actions.py +++ b/synapse/storage/event_push_actions.py
@@ -489,6 +489,27 @@ class EventPushActionsWorkerStore(SQLBaseStore): self.stream_ordering_day_ago ) + def find_first_stream_ordering_after_ts(self, ts): + """Gets the stream ordering corresponding to a given timestamp. + + Specifically, finds the stream_ordering of the first event that was + received after the timestamp. This is done by a binary search on the + events table, since there is no index on received_ts, so is + relatively slow. + + Args: + ts (int): timestamp in millis + + Returns: + Deferred[int]: stream ordering of the first event received after + the timestamp + """ + return self.runInteraction( + "_find_first_stream_ordering_after_ts_txn", + self._find_first_stream_ordering_after_ts_txn, + ts, + ) + def _find_first_stream_ordering_after_ts_txn(self, txn, ts): """ Find the stream_ordering of the first event that was received after