Make logging output for state deletions a bit better
MODIFY
roomserver/internal/input/input_latest_events.go
roomserver/internal/input/input_latest_events.go
@@ -102,8 +102,8 @@ type latestEventsUpdater struct {
// The eventID of the event that was processed before this one.
lastEventIDSent string
// The latest events in the room after processing this event.
- oldLatest []types.StateAtEventAndReference
- latest []types.StateAtEventAndReference
+ oldLatest types.StateAtEventAndReferences
+ latest types.StateAtEventAndReferences
// The state entries removed from and added to the current state of the
// room as a result of processing this event. They are sorted lists.
removed []types.StateEntry
@@ -126,7 +126,7 @@ func (u *latestEventsUpdater) doUpdateLatestEvents() error {
// state snapshot from somewhere else, e.g. a federated room join,
// then start with an empty set - none of the forward extremities
// that we knew about before matter anymore.
- u.oldLatest = []types.StateAtEventAndReference{}
+ u.oldLatest = types.StateAtEventAndReferences{}
if !u.rewritesState {
u.oldStateNID = u.updater.CurrentStateSnapshotNID()
u.oldLatest = u.updater.LatestEvents()
@@ -277,8 +277,8 @@ func (u *latestEventsUpdater) latestState() error {
"room_id": u.event.RoomID(),
"old_state_nid": u.oldStateNID,
"new_state_nid": u.newStateNID,
- "old_latest": u.oldLatest,
- "new_latest": u.latest,
+ "old_latest": u.oldLatest.EventIDs(),
+ "new_latest": u.latest.EventIDs(),
}).Errorf("Unexpected state deletion (removing %d events)", removed)
}

MODIFY
roomserver/types/types.go
roomserver/types/types.go
@@ -210,6 +210,14 @@ func (s StateAtEventAndReferences) Swap(a, b int) {
s[a], s[b] = s[b], s[a]
}
+func (s StateAtEventAndReferences) EventIDs() string {
+ strs := make([]string, 0, len(s))
+ for _, r := range s {
+ strs = append(strs, r.EventID)
+ }
+ return "[" + strings.Join(strs, " ") + "]"
+}
+
// An Event is a gomatrixserverlib.Event with the numeric event ID attached.
// It is when performing bulk event lookup in the database.
type Event struct {

Make logging output for state deletions a bit better