Skip to content

Commit

Permalink
History query ordering fix
Browse files Browse the repository at this point in the history
CRDT only bundles should be last when considering bundles with the same
last_serial. Otherwise the compactor will detect a discontinuity.
  • Loading branch information
raimohanska committed Apr 15, 2024
1 parent 58c4be6 commit 8fb6e62
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions backend/src/board-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ export function getFullBoardHistory(id: Id, client: PoolClient, cb: StreamingBoa
SELECT events
FROM board_event
WHERE board_id=$1
ORDER BY last_serial
ORDER BY last_serial, first_serial
`,
[id],
client,
Expand All @@ -244,7 +244,7 @@ export async function getBoardHistory(id: Id, afterSerial: Serial, cb: Streaming
SELECT events
FROM board_event
WHERE board_id=$1 AND last_serial >= $2
ORDER BY last_serial
ORDER BY last_serial, first_serial
`,
[id, afterSerial],
client,
Expand Down Expand Up @@ -409,7 +409,7 @@ export async function getBoardHistoryBundlesWithLastSerialsBetween(
SELECT board_id, last_serial, events, crdt_update
FROM board_event
WHERE board_id=$1 AND last_serial >= $2 AND last_serial <= $3
ORDER BY last_serial
ORDER BY last_serial, first_serial
`,
[id, lsMin, lsMax],
)
Expand All @@ -423,7 +423,7 @@ export async function getBoardHistoryCrdtUpdates(client: PoolClient, id: Id): Pr
SELECT crdt_update
FROM board_event
WHERE board_id=$1 AND crdt_update IS NOT NULL
ORDER BY last_serial
ORDER BY last_serial, first_serial
`,
[id],
)
Expand All @@ -448,7 +448,7 @@ export async function getBoardHistoryBundleMetas(client: PoolClient, id: Id): Pr
SELECT board_id, last_serial, first_serial, saved_at
FROM board_event
WHERE board_id=$1
ORDER BY last_serial
ORDER BY last_serial, first_serial
`,
[id],
)
Expand Down

0 comments on commit 8fb6e62

Please sign in to comment.