Try again

This commit is contained in:
Neil Alexander 2022-08-03 13:42:41 +01:00
parent 13ce67ecfe
commit ef4aa59fef
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
3 changed files with 12 additions and 6 deletions

View file

@ -233,7 +233,7 @@ func (r *Inputer) processRoomEvent(
var err error
softfail, err = helpers.CheckForSoftFail(ctx, roomInfo, r.DB, headered, input.StateEventIDs)
if err != nil {
logger.WithError(err).Warnf("Event %s rejected by current room state", event.EventID())
logger.WithError(err).Warnf("Event %s rejected by current room state (roominfo %+v)", event.EventID(), roomInfo)
rejectionErr = fmt.Errorf("rejected by current room state: %w", err)
}
}
@ -337,10 +337,12 @@ func (r *Inputer) processRoomEvent(
// Request the room info again — it's possible that the room has been
// created by now if it didn't exist already.
logrus.Printf("Room info before: %+v", roomInfo)
roomInfo, err = r.DB.RoomInfo(ctx, event.RoomID())
if err != nil {
return fmt.Errorf("updater.RoomInfo: %w", err)
}
logrus.Printf("Room info after: %+v", roomInfo)
if roomInfo == nil {
return fmt.Errorf("updater.RoomInfo missing for room %s", event.RoomID())
}

View file

@ -86,6 +86,15 @@ func (r *Inputer) updateLatestEvents(
return fmt.Errorf("u.doUpdateLatestEvents: %w", err)
}
// Since it's entirely possible that this types.RoomInfo came from the
// cache, we should make sure to update that entry so that the next run
// works from live data.
defer func() {
if succeeded {
u.roomInfo.Update(u.newStateNID, len(u.latest) == 0)
}
}()
succeeded = true
return
}

View file

@ -229,11 +229,6 @@ func (u *RoomUpdater) SetLatestEvents(
if err := u.d.RoomsTable.UpdateLatestEventNIDs(u.ctx, txn, roomNID, eventNIDs, lastEventNIDSent, currentStateSnapshotNID); err != nil {
return fmt.Errorf("u.d.RoomsTable.updateLatestEventNIDs: %w", err)
}
// Since it's entirely possible that this types.RoomInfo came from the
// cache, we should make sure to update that entry so that the next run
// works from live data.
u.roomInfo.Update(currentStateSnapshotNID, len(eventNIDs) == 0)
return nil
})
}