mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-18 12:23:09 -06:00
Further sync tweaks
This commit is contained in:
parent
37d117f2b7
commit
b3568a0763
|
|
@ -40,7 +40,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS syncapi_event_topological_position_idx ON sync
|
||||||
const insertEventInTopologySQL = "" +
|
const insertEventInTopologySQL = "" +
|
||||||
"INSERT INTO syncapi_output_room_events_topology (event_id, topological_position, room_id)" +
|
"INSERT INTO syncapi_output_room_events_topology (event_id, topological_position, room_id)" +
|
||||||
" VALUES ($1, $2, $3)" +
|
" VALUES ($1, $2, $3)" +
|
||||||
" ON CONFLICT DO NOTHING"
|
" ON CONFLICT (topological_position, room_id) DO UPDATE SET event_id = $1"
|
||||||
|
|
||||||
const selectEventIDsInRangeASCSQL = "" +
|
const selectEventIDsInRangeASCSQL = "" +
|
||||||
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
"SELECT event_id FROM syncapi_output_room_events_topology" +
|
||||||
|
|
|
||||||
|
|
@ -446,6 +446,7 @@ func (d *SyncServerDatasource) addPDUDeltaToResponse(
|
||||||
for _, delta := range deltas {
|
for _, delta := range deltas {
|
||||||
err = d.addRoomDeltaToResponse(ctx, &device, txn, fromPos, toPos, delta, numRecentEventsPerRoom, res)
|
err = d.addRoomDeltaToResponse(ctx, &device, txn, fromPos, toPos, delta, numRecentEventsPerRoom, res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -602,7 +603,6 @@ func (d *SyncServerDatasource) getResponseWithPDUsForCompleteSync(
|
||||||
recentStreamEvents, err = d.events.selectRecentEvents(
|
recentStreamEvents, err = d.events.selectRecentEvents(
|
||||||
ctx, txn, roomID, types.StreamPosition(0), toPos.PDUPosition,
|
ctx, txn, roomID, types.StreamPosition(0), toPos.PDUPosition,
|
||||||
numRecentEventsPerRoom, true, true,
|
numRecentEventsPerRoom, true, true,
|
||||||
//ctx, txn, roomID, 0, toPos.PDUPosition, numRecentEventsPerRoom,
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
@ -618,7 +618,7 @@ func (d *SyncServerDatasource) getResponseWithPDUsForCompleteSync(
|
||||||
if backwardTopologyPos-1 <= 0 {
|
if backwardTopologyPos-1 <= 0 {
|
||||||
backwardTopologyPos = types.StreamPosition(1)
|
backwardTopologyPos = types.StreamPosition(1)
|
||||||
} else {
|
} else {
|
||||||
backwardTopologyPos = backwardTopologyPos - 1
|
backwardTopologyPos--
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't include a device here as we don't need to send down
|
// We don't include a device here as we don't need to send down
|
||||||
|
|
@ -769,10 +769,7 @@ func (d *SyncServerDatasource) getBackwardTopologyPos(
|
||||||
events []types.StreamEvent,
|
events []types.StreamEvent,
|
||||||
) (pos types.StreamPosition, err error) {
|
) (pos types.StreamPosition, err error) {
|
||||||
if len(events) > 0 {
|
if len(events) > 0 {
|
||||||
pos, err = d.topology.selectPositionInTopology(ctx, events[0].EventID())
|
pos, _ = d.topology.selectPositionInTopology(ctx, events[0].EventID())
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if pos-1 <= 0 {
|
if pos-1 <= 0 {
|
||||||
pos = types.StreamPosition(1)
|
pos = types.StreamPosition(1)
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ func (rp *RequestPool) appendAccountData(
|
||||||
// Sync is not initial, get all account data since the latest sync
|
// Sync is not initial, get all account data since the latest sync
|
||||||
dataTypes, err := rp.db.GetAccountDataInRange(
|
dataTypes, err := rp.db.GetAccountDataInRange(
|
||||||
req.ctx, userID,
|
req.ctx, userID,
|
||||||
types.StreamPosition(req.since.PDUPosition), types.StreamPosition(currentPos),
|
types.StreamPosition(currentPos), types.StreamPosition(req.since.PDUPosition),
|
||||||
accountDataFilter,
|
accountDataFilter,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue