Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Ordered include windows load children for a parent row the top-K holds only while refilling

Aperta
#2,151 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
18/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
data

Direzione di ricerca

Start with the includes-work oracle in packages/db/tests/query/includes-work-counter-oracle.test.ts, which pins the three overshoot replays. The change belongs in the demand plane: packages/db/src/query/live/collection-config-builder.ts and the subset demand controller. Done means the replays no longer exceed the work bound, the work-bound exclusion is removed from the generated campaigns, and the readiness and demand oracles still pass.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Problem

An ordered live query with an index-backed parent window can load child rows for a parent row that its settled window does not show. The parent's ordered loader refills the window within one graph run. Until the refill completes, the top-K briefly holds a row outside the settled window, and the include routes that row. The child source then loads that row's children.

The published rows stay correct. The extra work is the children of one parent row for each such checkpoint.

Traces

The includes-work oracle (packages/db/tests/query/includes-work-counter-oracle.test.ts) pins these traces as replays. Each replay loads one child row more than the bound.

  1. A held row moves out. The parent query has orderBy(rank), offset 1 and limit 1. A step moves the parent row at position 0 past every other rank. The top-K briefly shows the moved row before its loader refills the slot. That row's children load.
  2. A tie at the window edge during preload. Two parent rows have the same rank at the window edge. The loader loads the tie after the first prefix. The window first shows one tied row, then the other row, and both rows load their children.
  3. A window move while the loader refills. A step moves a parent row, and a second step inserts a parent row with a copied rank. Then setWindow moves the window. The top-K briefly shows a row outside the moved window.

Why the published rows stay correct

The graph publishes only after the loader settles. The top-K retracts the transient row in the same graph run, so no subscriber receives it. Only the child demand sees the transient row, because setDemand takes effect when the include's parent keys change.

How the oracle observes it

The harness counts the change batches that the parent Collection delivers to the query. At preload, more batches than the initial load show that the ordered loader acquired more rows. After a step, more batches than the step's own parent write show the same. The generated campaigns skip the work bound at those checkpoints only (about 2.5% of them).

Proposed change

Hold include demand until the ordered loader settles. The include records demand changes during a graph run. When the live query's graph loop has no pending work and its loaders are idle, the include sends one net demand change. If that change loads child rows, the graph loop runs again. A transient parent row then adds and removes its key in the same loop, and the child source does not load it.

This change is in the demand plane (packages/db/src/query/live/collection-config-builder.ts and the subset demand controller). It can change when demand starts within a sync turn. The readiness and demand oracles must show that readiness stays correct.

After this change, remove the overshoot from the replays and the work-bound exclusion from the generated campaigns.

This issue was written by Isaac.

Lingua principale
TypeScript
Stelle
3.9k
Fork
272
Merge medio
1g 21m
PR unite (30g)
241

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TanStack/db

Tutte le issue di TanStack/db

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.