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

Improve log messages for stream ids #11536

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11536.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improvements to log messages around handling stream ids.
4 changes: 3 additions & 1 deletion synapse/storage/databases/main/state_deltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ async def get_current_state_deltas(
prev_stream_id = int(prev_stream_id)

# check we're not going backwards
assert prev_stream_id <= max_stream_id
assert (
prev_stream_id <= max_stream_id
), f"New stream id {max_stream_id} is smaller than prev stream id {prev_stream_id}"

if not self._curr_state_delta_stream_cache.has_any_entity_changed(
prev_stream_id
Expand Down
6 changes: 3 additions & 3 deletions synapse/storage/util/id_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ def get_next(self) -> int:
def _load_current_id(
db_conn: LoggingDatabaseConnection, table: str, column: str, step: int = 1
) -> int:
# debug logging for https://github.com/matrix-org/synapse/issues/7968
logger.info("initialising stream generator for %s(%s)", table, column)
cur = db_conn.cursor(txn_name="_load_current_id")
if step == 1:
cur.execute("SELECT MAX(%s) FROM %s" % (column, table))
Expand All @@ -86,7 +84,9 @@ def _load_current_id(
(val,) = result
cur.close()
current_id = int(val) if val else step
return (max if step > 0 else min)(current_id, step)
res = (max if step > 0 else min)(current_id, step)
logger.info("Initialising stream generator for %s(%s): %i", table, column, res)
return res


class AbstractStreamIdTracker(metaclass=abc.ABCMeta):
Expand Down