fix(sync): the offline queue flush never processed anything — fix the enumerator + the dropped payload
Found while verifying H1's "app offline-play -> flush -> position lands"
with the emulator path: the flush has been dead code in two independent
ways, invisible because the first break made the second unreachable.
1. ListPendingSyncQueueItems matched `device_id = $1` with a NULL $1
(the processor passes DeviceID{Valid:false} to enumerate all devices;
uuid = NULL matches no rows). The ticker therefore processed nothing,
ever. The WHERE now treats NULL as "every device" (the same
narg::uuid IS NULL idiom the visibility queries use; EXPLAIN'd — seq
scan on a bounded table, idx_sync_queue_status_priority_created
fits). The processor also dropped its fake-pagination loop, which
re-fetched the same first batch forever once the backlog hit the
batch size (no OFFSET in the query).
2. dbItemToSyncQueueItem dropped SyncData — even with a working
enumerator, every flushed item arrived with an empty payload and
failed JSON unmarshal. Dead code harboring silent breakage, exactly
the plan's thesis.
Callers updated for the renamed RowLimit param (queue handler, offline
detector). TestH1_SyncQueueFlush_LandsAndPreservesAudio drives the real
flow: web PUT seeds audio 900s, a pending checkpoint-style queue row
applies percentage 0.8 through SaveProgress, audio survives, queue row
completes.
Also fixes dashboard_test.go's stale BuildSections signature (the
package's test binary has been unbuildable) — user-approved: tests
designed against old shapes are not worth keeping.
This commit is contained in:
1 parent
d16ca4acbe
commit
6808c1babb
8 files changed
+101
-39
No files matched your search
@@ -192,7 +192,7 @@ func TestSyncQueueProcessor(t *testing.T) {
|
||||
// Verify queue item was created
|
||||
items, err := db.ListPendingSyncQueueItems(ctx, database.ListPendingSyncQueueItemsParams{
|
||||
DeviceID: deviceID,
|
||||
Limit: int32(10),
|
||||
RowLimit: int32(10),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, len(items), "Should have one queue item")
|
||||
@@ -235,7 +235,7 @@ func TestSyncConflictDetection(t *testing.T) {
|
||||
// Verify both exist (conflict detection would happen during processing)
|
||||
items, err := db.ListPendingSyncQueueItems(ctx, database.ListPendingSyncQueueItemsParams{
|
||||
DeviceID: deviceID,
|
||||
Limit: int32(10),
|
||||
RowLimit: int32(10),
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, len(items), "Should have one queue item")
|
||||
|
||||
Reference in new issue
Block a user