fix(shadow): start queue cursor at database time

This commit is contained in:
zgw
2026-08-28 10:17:16 +08:00
parent cf0a98247e
commit 01c94663c2
3 changed files with 11 additions and 2 deletions

View File

@@ -69,7 +69,7 @@ public final class SqlServerShadowFactReader {
}
try {
ShadowFactBatch batch = sourceTransaction.execute(status ->
collect(cursor.withOverlap(CURSOR_OVERLAP), deadline));
collect(cursor, deadline));
if (batch == null) {
throw new ShadowFactReadException("SOURCE_EMPTY_BATCH",
Duration.ZERO);
@@ -94,7 +94,11 @@ public final class SqlServerShadowFactReader {
private ShadowFactBatch collect(ShadowReadCursor cursor, Instant deadline) {
ensureTime(deadline);
Instant databaseStartedAt = source.readDatabaseClock(deadline);
List<ShadowQueueFact> queues = immutable(source.readQueues(cursor, deadline));
ShadowReadCursor queryCursor = cursor.isInitial()
? new ShadowReadCursor(databaseStartedAt, "") : cursor;
queryCursor = queryCursor.withOverlap(CURSOR_OVERLAP);
List<ShadowQueueFact> queues = immutable(source.readQueues(
queryCursor, deadline));
requireLimit("QUEUE", queues.size(), QUEUE_LIMIT);
List<ShadowVehicleFact> vehicles =
immutable(source.readVehicles(deadline));