mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-08-02 06:12:45 +00:00
Fix ordering when backfilling (#1000)
* Fix ordering when backfilling The problem was that we weren't sorting the returned events by depth when sending them back to the caller, instead we were sorting by prev_events which is not the same thing. * Fixup tests
This commit is contained in:
parent
f7cfa75886
commit
36bbb25561
3 changed files with 110 additions and 10 deletions
|
@ -434,6 +434,7 @@ func (d *SyncServerDatasource) syncPositionTx(
|
|||
}
|
||||
sp.PDUPosition = types.StreamPosition(maxEventID)
|
||||
sp.EDUTypingPosition = types.StreamPosition(d.eduCache.GetLatestSyncPosition())
|
||||
sp.Type = types.PaginationTokenTypeStream
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -658,6 +659,7 @@ func (d *SyncServerDatasource) getResponseWithPDUsForCompleteSync(
|
|||
backwardTopologyPos = types.StreamPosition(1)
|
||||
} else {
|
||||
backwardTopologyPos--
|
||||
backwardTopologyStreamPos += 1000 // this has to be bigger than the number of events we backfill per request
|
||||
}
|
||||
|
||||
// We don't include a device here as we don't need to send down
|
||||
|
@ -817,11 +819,13 @@ func (d *SyncServerDatasource) getBackwardTopologyPos(
|
|||
if len(events) > 0 {
|
||||
pos, spos, _ = d.topology.selectPositionInTopology(ctx, txn, events[0].EventID())
|
||||
}
|
||||
// TODO: I have no idea what this is doing.
|
||||
// go to the previous position so we don't pull out the same event twice
|
||||
// FIXME: This could be done more nicely by being explicit with inclusive/exclusive rules
|
||||
if pos-1 <= 0 {
|
||||
pos = types.StreamPosition(1)
|
||||
} else {
|
||||
pos = pos - 1
|
||||
spos += 1000 // this has to be bigger than the number of events we backfill per request
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue