mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-09 07:03:10 -06:00
Return stubby caches anyway
This commit is contained in:
parent
ef4aa59fef
commit
18ddda3832
|
|
@ -337,12 +337,10 @@ 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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,11 +89,9 @@ func (r *Inputer) updateLatestEvents(
|
|||
// 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)
|
||||
}
|
||||
}()
|
||||
if u.newStateNID != u.oldStateNID {
|
||||
roomInfo.Update(u.newStateNID, len(u.latest) == 0)
|
||||
}
|
||||
|
||||
succeeded = true
|
||||
return
|
||||
|
|
@ -145,7 +143,7 @@ func (u *latestEventsUpdater) doUpdateLatestEvents() error {
|
|||
// that we knew about before matter anymore.
|
||||
u.oldLatest = types.StateAtEventAndReferences{}
|
||||
if !u.rewritesState {
|
||||
u.oldStateNID = u.updater.CurrentStateSnapshotNID()
|
||||
u.oldStateNID = u.roomInfo.StateSnapshotNID()
|
||||
u.oldLatest = u.updater.LatestEvents()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,12 +11,11 @@ import (
|
|||
|
||||
type RoomUpdater struct {
|
||||
transaction
|
||||
d *Database
|
||||
roomInfo *types.RoomInfo
|
||||
latestEvents []types.StateAtEventAndReference
|
||||
lastEventIDSent string
|
||||
currentStateSnapshotNID types.StateSnapshotNID
|
||||
roomExists bool
|
||||
d *Database
|
||||
roomInfo *types.RoomInfo
|
||||
latestEvents []types.StateAtEventAndReference
|
||||
lastEventIDSent string
|
||||
roomExists bool
|
||||
}
|
||||
|
||||
func rollback(txn *sql.Tx) {
|
||||
|
|
@ -34,11 +33,11 @@ func NewRoomUpdater(ctx context.Context, d *Database, txn *sql.Tx, roomInfo *typ
|
|||
// succeed, processing a create event which creates the room, or it won't.
|
||||
if roomInfo == nil {
|
||||
return &RoomUpdater{
|
||||
transaction{ctx, txn}, d, nil, nil, "", 0, false,
|
||||
transaction{ctx, txn}, d, nil, nil, "", false,
|
||||
}, nil
|
||||
}
|
||||
|
||||
eventNIDs, lastEventNIDSent, currentStateSnapshotNID, err :=
|
||||
eventNIDs, lastEventNIDSent, _, err :=
|
||||
d.RoomsTable.SelectLatestEventsNIDsForUpdate(ctx, txn, roomInfo.RoomNID)
|
||||
if err != nil {
|
||||
rollback(txn)
|
||||
|
|
@ -58,7 +57,7 @@ func NewRoomUpdater(ctx context.Context, d *Database, txn *sql.Tx, roomInfo *typ
|
|||
}
|
||||
}
|
||||
return &RoomUpdater{
|
||||
transaction{ctx, txn}, d, roomInfo, stateAndRefs, lastEventIDSent, currentStateSnapshotNID, true,
|
||||
transaction{ctx, txn}, d, roomInfo, stateAndRefs, lastEventIDSent, true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +99,7 @@ func (u *RoomUpdater) LastEventIDSent() string {
|
|||
|
||||
// CurrentStateSnapshotNID implements types.RoomRecentEventsUpdater
|
||||
func (u *RoomUpdater) CurrentStateSnapshotNID() types.StateSnapshotNID {
|
||||
return u.currentStateSnapshotNID
|
||||
return u.roomInfo.StateSnapshotNID()
|
||||
}
|
||||
|
||||
// StorePreviousEvents implements types.RoomRecentEventsUpdater - This must be called from a Writer
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ func (d *Database) RoomInfo(ctx context.Context, roomID string) (*types.RoomInfo
|
|||
|
||||
func (d *Database) roomInfo(ctx context.Context, txn *sql.Tx, roomID string) (*types.RoomInfo, error) {
|
||||
roomInfo, ok := d.Cache.GetRoomInfo(roomID)
|
||||
if ok && roomInfo != nil && !roomInfo.IsStub() && roomInfo.RoomNID != 0 {
|
||||
if ok && roomInfo != nil {
|
||||
// The data that's in the cache is not stubby, so return it.
|
||||
return roomInfo, nil
|
||||
}
|
||||
|
|
@ -694,7 +694,7 @@ func (d *Database) storeEvent(
|
|||
succeeded := false
|
||||
if updater == nil {
|
||||
var roomInfo *types.RoomInfo
|
||||
roomInfo, err = d.roomInfo(ctx, txn, event.RoomID())
|
||||
roomInfo, err = d.roomInfo(ctx, nil, event.RoomID())
|
||||
if err != nil {
|
||||
return 0, 0, types.StateAtEvent{}, nil, "", fmt.Errorf("d.RoomInfo: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,7 +302,6 @@ func (r *RoomInfo) IsStub() bool {
|
|||
func (r *RoomInfo) Update(nid StateSnapshotNID, isStub bool) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
r.stateSnapshotNID = nid
|
||||
r.isStub = isStub
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue