summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorEric Eastwood <erice@element.io>2022-09-28 21:22:33 -0500
committerEric Eastwood <erice@element.io>2022-09-28 21:22:33 -0500
commit50b11cb5383d244ca1c7db6f0b93f1f7385217cd (patch)
tree5e92fe236d72abda5deec4eeae88b14f8cba7be3 /synapse
parentAlign more to Complement test which does pass (diff)
downloadsynapse-50b11cb5383d244ca1c7db6f0b93f1f7385217cd.tar.xz
I think working same as Complement reverse_chronological, only the insertion event rejected
Diffstat (limited to 'synapse')
-rw-r--r--synapse/handlers/federation_event.py43
-rw-r--r--synapse/storage/databases/main/event_federation.py2
2 files changed, 28 insertions, 17 deletions
diff --git a/synapse/handlers/federation_event.py b/synapse/handlers/federation_event.py
index d4dfdc9929..118aaca01d 100644
--- a/synapse/handlers/federation_event.py
+++ b/synapse/handlers/federation_event.py
@@ -14,6 +14,7 @@
 
 import collections
 import itertools
+import json
 import logging
 from http import HTTPStatus
 from typing import (
@@ -659,7 +660,7 @@ class FederationEventHandler:
             # thrashing.
             reverse_chronological_events = events
             # `[::-1]` is just syntax to reverse the list and give us a copy
-            chronological_events = reverse_chronological_events[::-1]
+            # chronological_events = reverse_chronological_events[::-1]
 
             logger.info(
                 "backfill assumed reverse_chronological_events=%s",
@@ -715,8 +716,8 @@ class FederationEventHandler:
                 # Expecting to persist in chronological order here (oldest ->
                 # newest) so that events are persisted before they're referenced
                 # as a `prev_event`.
-                chronological_events,
-                # reverse_chronological_events,
+                # chronological_events,
+                reverse_chronological_events,
                 backfilled=True,
             )
 
@@ -869,17 +870,20 @@ class FederationEventHandler:
 
         logger.info(
             "backfill sorted_events=%s",
-            [
-                "event_id=%s,depth=%d,body=%s(%s),prevs=%s\n"
-                % (
-                    event.event_id,
-                    event.depth,
-                    event.content.get("body", event.type),
-                    getattr(event, "state_key", None),
-                    event.prev_event_ids(),
-                )
-                for event in sorted_events
-            ],
+            json.dumps(
+                [
+                    "event_id=%s,depth=%d,body=%s(%s),prevs=%s\n"
+                    % (
+                        event.event_id,
+                        event.depth,
+                        event.content.get("body", event.type),
+                        getattr(event, "state_key", None),
+                        event.prev_event_ids(),
+                    )
+                    for event in sorted_events
+                ],
+                indent=4,
+            ),
         )
 
         for ev in sorted_events:
@@ -1160,11 +1164,18 @@ class FederationEventHandler:
             destination, room_id, event_id=event_id
         )
 
-        logger.debug(
-            "state_ids returned %i state events, %i auth events",
+        logger.info(
+            "_get_state_ids_after_missing_prev_event(event_id=%s): state_ids returned %i state events, %i auth events",
+            event_id,
             len(state_event_ids),
             len(auth_event_ids),
         )
+        logger.info(
+            "_get_state_ids_after_missing_prev_event(event_id=%s): state_event_ids=%s auth_event_ids=%s",
+            event_id,
+            state_event_ids,
+            auth_event_ids,
+        )
 
         # Start by checking events we already have in the DB
         desired_events = set(state_event_ids)
diff --git a/synapse/storage/databases/main/event_federation.py b/synapse/storage/databases/main/event_federation.py
index 6df15c1c8f..b8c26adb7b 100644
--- a/synapse/storage/databases/main/event_federation.py
+++ b/synapse/storage/databases/main/event_federation.py
@@ -972,7 +972,7 @@ class EventFederationWorkerStore(SignatureWorkerStore, EventsWorkerStore, SQLBas
                     1000 * BACKFILL_EVENT_BACKOFF_UPPER_BOUND_SECONDS,
                 ),
             )
-            return cast(List[Tuple[str, int]], txn.fetchall())
+            return cast(List[Tuple[str, int, int]], txn.fetchall())
 
         return await self.db_pool.runInteraction(
             "get_insertion_event_backward_extremities_in_room",