This commit is contained in:
Neil Alexander 2021-07-27 14:03:08 +01:00
parent 0769412df5
commit f2f094e7f0
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 10 additions and 3 deletions

View file

@ -134,7 +134,7 @@ func (d *Database) addRoomDeltaToResponse(
}
recentEvents := d.StreamEventsToEvents(device, recentStreamEvents)
delta.StateEvents = removeDuplicates(delta.StateEvents, recentEvents) // roll back
prevBatch, err := d.GetBackwardTopologyPos(ctx, recentStreamEvents)
prevBatch, err := d.getBackwardTopologyPos(ctx, txn, recentStreamEvents)
if err != nil {
return err
}
@ -246,7 +246,7 @@ func (d *Database) getJoinResponseForCompleteSync(
var prevBatch *types.TopologyToken
if len(recentStreamEvents) > 0 {
var backwardTopologyPos, backwardStreamPos types.StreamPosition
backwardTopologyPos, backwardStreamPos, err = d.PositionInTopology(ctx, recentStreamEvents[0].EventID())
backwardTopologyPos, backwardStreamPos, err = d.Topology.SelectPositionInTopology(ctx, txn, recentStreamEvents[0].EventID())
if err != nil {
return
}

View file

@ -551,12 +551,19 @@ func (d *Database) RedactEvent(ctx context.Context, redactedEventID string, reda
func (d *Database) GetBackwardTopologyPos(
ctx context.Context,
events []types.StreamEvent,
) (types.TopologyToken, error) {
return d.getBackwardTopologyPos(ctx, nil, events)
}
func (d *Database) getBackwardTopologyPos(
ctx context.Context, txn *sql.Tx,
events []types.StreamEvent,
) (types.TopologyToken, error) {
zeroToken := types.TopologyToken{}
if len(events) == 0 {
return zeroToken, nil
}
pos, spos, err := d.Topology.SelectPositionInTopology(ctx, nil, events[0].EventID())
pos, spos, err := d.Topology.SelectPositionInTopology(ctx, txn, events[0].EventID())
if err != nil {
return zeroToken, err
}