mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-22 11:44:57 -05:00
Improve log messages for stream ids (#11536)
Somehow I'd managed to get my database in a pickle with stream ids. These changes were useful to debug.
This commit is contained in:
parent
8541809cb9
commit
ff7cc17b57
1
changelog.d/11536.misc
Normal file
1
changelog.d/11536.misc
Normal file
@ -0,0 +1 @@
|
|||||||
|
Improvements to log messages around handling stream ids.
|
@ -56,7 +56,9 @@ class StateDeltasStore(SQLBaseStore):
|
|||||||
prev_stream_id = int(prev_stream_id)
|
prev_stream_id = int(prev_stream_id)
|
||||||
|
|
||||||
# check we're not going backwards
|
# 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(
|
if not self._curr_state_delta_stream_cache.has_any_entity_changed(
|
||||||
prev_stream_id
|
prev_stream_id
|
||||||
|
@ -74,8 +74,6 @@ class IdGenerator:
|
|||||||
def _load_current_id(
|
def _load_current_id(
|
||||||
db_conn: LoggingDatabaseConnection, table: str, column: str, step: int = 1
|
db_conn: LoggingDatabaseConnection, table: str, column: str, step: int = 1
|
||||||
) -> int:
|
) -> 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")
|
cur = db_conn.cursor(txn_name="_load_current_id")
|
||||||
if step == 1:
|
if step == 1:
|
||||||
cur.execute("SELECT MAX(%s) FROM %s" % (column, table))
|
cur.execute("SELECT MAX(%s) FROM %s" % (column, table))
|
||||||
@ -86,7 +84,9 @@ def _load_current_id(
|
|||||||
(val,) = result
|
(val,) = result
|
||||||
cur.close()
|
cur.close()
|
||||||
current_id = int(val) if val else step
|
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):
|
class AbstractStreamIdTracker(metaclass=abc.ABCMeta):
|
||||||
|
Loading…
Reference in New Issue
Block a user