mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-09 15:13:12 -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
|
// Request the room info again — it's possible that the room has been
|
||||||
// created by now if it didn't exist already.
|
// created by now if it didn't exist already.
|
||||||
logrus.Printf("Room info before: %+v", roomInfo)
|
|
||||||
roomInfo, err = r.DB.RoomInfo(ctx, event.RoomID())
|
roomInfo, err = r.DB.RoomInfo(ctx, event.RoomID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("updater.RoomInfo: %w", err)
|
return fmt.Errorf("updater.RoomInfo: %w", err)
|
||||||
}
|
}
|
||||||
logrus.Printf("Room info after: %+v", roomInfo)
|
|
||||||
if roomInfo == nil {
|
if roomInfo == nil {
|
||||||
return fmt.Errorf("updater.RoomInfo missing for room %s", event.RoomID())
|
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
|
// 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
|
// cache, we should make sure to update that entry so that the next run
|
||||||
// works from live data.
|
// works from live data.
|
||||||
defer func() {
|
if u.newStateNID != u.oldStateNID {
|
||||||
if succeeded {
|
roomInfo.Update(u.newStateNID, len(u.latest) == 0)
|
||||||
u.roomInfo.Update(u.newStateNID, len(u.latest) == 0)
|
}
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
succeeded = true
|
succeeded = true
|
||||||
return
|
return
|
||||||
|
|
@ -145,7 +143,7 @@ func (u *latestEventsUpdater) doUpdateLatestEvents() error {
|
||||||
// that we knew about before matter anymore.
|
// that we knew about before matter anymore.
|
||||||
u.oldLatest = types.StateAtEventAndReferences{}
|
u.oldLatest = types.StateAtEventAndReferences{}
|
||||||
if !u.rewritesState {
|
if !u.rewritesState {
|
||||||
u.oldStateNID = u.updater.CurrentStateSnapshotNID()
|
u.oldStateNID = u.roomInfo.StateSnapshotNID()
|
||||||
u.oldLatest = u.updater.LatestEvents()
|
u.oldLatest = u.updater.LatestEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,11 @@ import (
|
||||||
|
|
||||||
type RoomUpdater struct {
|
type RoomUpdater struct {
|
||||||
transaction
|
transaction
|
||||||
d *Database
|
d *Database
|
||||||
roomInfo *types.RoomInfo
|
roomInfo *types.RoomInfo
|
||||||
latestEvents []types.StateAtEventAndReference
|
latestEvents []types.StateAtEventAndReference
|
||||||
lastEventIDSent string
|
lastEventIDSent string
|
||||||
currentStateSnapshotNID types.StateSnapshotNID
|
roomExists bool
|
||||||
roomExists bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func rollback(txn *sql.Tx) {
|
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.
|
// succeed, processing a create event which creates the room, or it won't.
|
||||||
if roomInfo == nil {
|
if roomInfo == nil {
|
||||||
return &RoomUpdater{
|
return &RoomUpdater{
|
||||||
transaction{ctx, txn}, d, nil, nil, "", 0, false,
|
transaction{ctx, txn}, d, nil, nil, "", false,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
eventNIDs, lastEventNIDSent, currentStateSnapshotNID, err :=
|
eventNIDs, lastEventNIDSent, _, err :=
|
||||||
d.RoomsTable.SelectLatestEventsNIDsForUpdate(ctx, txn, roomInfo.RoomNID)
|
d.RoomsTable.SelectLatestEventsNIDsForUpdate(ctx, txn, roomInfo.RoomNID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rollback(txn)
|
rollback(txn)
|
||||||
|
|
@ -58,7 +57,7 @@ func NewRoomUpdater(ctx context.Context, d *Database, txn *sql.Tx, roomInfo *typ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return &RoomUpdater{
|
return &RoomUpdater{
|
||||||
transaction{ctx, txn}, d, roomInfo, stateAndRefs, lastEventIDSent, currentStateSnapshotNID, true,
|
transaction{ctx, txn}, d, roomInfo, stateAndRefs, lastEventIDSent, true,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +99,7 @@ func (u *RoomUpdater) LastEventIDSent() string {
|
||||||
|
|
||||||
// CurrentStateSnapshotNID implements types.RoomRecentEventsUpdater
|
// CurrentStateSnapshotNID implements types.RoomRecentEventsUpdater
|
||||||
func (u *RoomUpdater) CurrentStateSnapshotNID() types.StateSnapshotNID {
|
func (u *RoomUpdater) CurrentStateSnapshotNID() types.StateSnapshotNID {
|
||||||
return u.currentStateSnapshotNID
|
return u.roomInfo.StateSnapshotNID()
|
||||||
}
|
}
|
||||||
|
|
||||||
// StorePreviousEvents implements types.RoomRecentEventsUpdater - This must be called from a Writer
|
// 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) {
|
func (d *Database) roomInfo(ctx context.Context, txn *sql.Tx, roomID string) (*types.RoomInfo, error) {
|
||||||
roomInfo, ok := d.Cache.GetRoomInfo(roomID)
|
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.
|
// The data that's in the cache is not stubby, so return it.
|
||||||
return roomInfo, nil
|
return roomInfo, nil
|
||||||
}
|
}
|
||||||
|
|
@ -694,7 +694,7 @@ func (d *Database) storeEvent(
|
||||||
succeeded := false
|
succeeded := false
|
||||||
if updater == nil {
|
if updater == nil {
|
||||||
var roomInfo *types.RoomInfo
|
var roomInfo *types.RoomInfo
|
||||||
roomInfo, err = d.roomInfo(ctx, txn, event.RoomID())
|
roomInfo, err = d.roomInfo(ctx, nil, event.RoomID())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, 0, types.StateAtEvent{}, nil, "", fmt.Errorf("d.RoomInfo: %w", err)
|
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) {
|
func (r *RoomInfo) Update(nid StateSnapshotNID, isStub bool) {
|
||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
defer r.mu.Unlock()
|
defer r.mu.Unlock()
|
||||||
|
|
||||||
r.stateSnapshotNID = nid
|
r.stateSnapshotNID = nid
|
||||||
r.isStub = isStub
|
r.isStub = isStub
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue