From 25d245fbe1623c743c7d5450163c379a12ae3744 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Tue, 4 Jun 2024 14:14:40 +0100 Subject: [PATCH 1/2] Add logging for whether room keys are replaced This is motivated by the Crypto team who need to diagnose crypto issues. The existing opentracing logging is not enough because it is not enabled for all users. --- synapse/handlers/e2e_room_keys.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/synapse/handlers/e2e_room_keys.py b/synapse/handlers/e2e_room_keys.py index e76a51ba308..99f9f6e64a7 100644 --- a/synapse/handlers/e2e_room_keys.py +++ b/synapse/handlers/e2e_room_keys.py @@ -247,6 +247,12 @@ async def upload_room_keys( if current_room_key: if self._should_replace_room_key(current_room_key, room_key): log_kv({"message": "Replacing room key."}) + logger.debug( + "Replacing room key. room=%s session=%s user=%s", + room_id, + session_id, + user_id, + ) # updates are done one at a time in the DB, so send # updates right away rather than batching them up, # like we do with the inserts @@ -256,6 +262,12 @@ async def upload_room_keys( changed = True else: log_kv({"message": "Not replacing room_key."}) + logger.debug( + "Not replacing room key. room=%s session=%s user=%s", + room_id, + session_id, + user_id, + ) else: log_kv( { @@ -265,6 +277,12 @@ async def upload_room_keys( } ) log_kv({"message": "Replacing room key."}) + logger.debug( + "Inserting new room key. room=%s session=%s user=%s", + room_id, + session_id, + user_id, + ) to_insert.append((room_id, session_id, room_key)) changed = True From 3666c93bf2455811ee9f74d9783ed09b2eb67200 Mon Sep 17 00:00:00 2001 From: Olivier 'reivilibre Date: Tue, 4 Jun 2024 14:15:51 +0100 Subject: [PATCH 2/2] Newsfile Signed-off-by: Olivier 'reivilibre --- changelog.d/17266.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17266.misc diff --git a/changelog.d/17266.misc b/changelog.d/17266.misc new file mode 100644 index 00000000000..ce8c4ab0869 --- /dev/null +++ b/changelog.d/17266.misc @@ -0,0 +1 @@ +Add debug logging for when room keys are uploaded, including whether they are replacing other room keys. \ No newline at end of file