Skip to content

Query DB refetch oracle: row inside the window is missing from the source Collection after refetch (cursor, two order terms) #2335

Open

Description

@KyleAMathews

Summary

A random campaign of packages/query-db-collection/tests/refetch-ordered-prefix-oracle.test.ts found a counterexample in CI. It reproduces on main at a2c3854c3. It still reproduces after a merge of 9be51e037 (#2333). It also fails with main's ordered source loader in a tree that only adds the test changes of PR #2302. This report does not establish whether production or the oracle's model is wrong.

Counterexample

CI run: https://github.com/TanStack/db/actions/runs/41516335355/job/125520732875

{ seed: 1114808614, path: "22:0:3:5:5:1:8:10:9:10:1:4:5:4:7:7:8:6:8:8:8:8:8:8", endOnFailure: true }
Counterexample: [{"scenario":{"encoding":"cursor","functionKey":false,"terms":2,"orderKey":"rank","pageCap":undefined,"limit":1,"offset":0},"initial":[{"id":1,"rank":0,"marked":false},{"id":0,"rank":0,"marked":false}],"history":[{"type":"delete","id":1},{"type":"upsert","id":0,"rank":1},{"type":"invalidate"},{"type":"upsert","id":2,"rank":0},{"type":"upsert","id":1,"rank":0},{"type":"refetch"},{"type":"upsert","id":0,"rank":0},{"type":"refetch"}]}]
Got error: coverage after refetch at step 5: rows [{"id":2,"rank":0,"label":"a"}] sort at or before the window's end but are [null] in the source Collection

The scenario uses cursor pages, two order terms, limit 1 and offset 0. After the first refetch, backend row 2 sorts at or before the window's end, but the source Collection does not hold it. The coverage law requires every backend row through the window's last row to be in the source Collection with its current values.

Reproduce

From packages/query-db-collection, after a build of its dependencies (pnpm --filter "@tanstack/query-db-collection^..." build):

TANSTACK_DB_ORACLE_SEED=1114808614 TANSTACK_DB_ORACLE_PATH="22:0:3:5:5:1:8:10:9:10:1:4:5:4:7:7:8:6:8:8:8:8:8:8" TANSTACK_DB_ORACLE_PROPERTY=query-db.refetch-ordered-prefix pnpm exec vitest run tests/refetch-ordered-prefix-oracle.test.ts --coverage.enabled=false --typecheck.enabled=false -t "generated refetch histories"

Next step

Determine which account fails: Query DB's refetch report or core's ordered repair for this two-term tie history, or the model's coverage expectation. Keep the trace as a replay of the shared model and comparison.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions