Repository navigation
AS OF SYSTEM TIME NULL combined with any WHERE predicate returns zero rows #170
Description
Activity
- addedtype:bugA defect — broken, incorrect, or lost dataA defect — broken, incorrect, or lost datasev:2-highMajor functionality broken; no acceptable workaroundMajor functionality broken; no acceptable workaroundengine:documentDocument engine (schemaless + strict)Document engine (schemaless + strict)area:bitemporalSystem/valid time, AS OF queriesSystem/valid time, AS OF queriesregressionWorked on an earlier build; broke sinceWorked on an earlier build; broke since
on Jul 8, 2026 Fixed on
main(commitc2dbbd30), shipping in v0.4.0.Root cause: the
AS OF SYSTEM TIME NULLaudit-scan path applied theWHEREpredicate against the raw stored body using the MessagePack matcher. For adocument_strictcollection that body is a Binary Tuple, which the MessagePack matcher silently never matches — so every version was filtered out (0 rows, and the placeholderresultcolumn because there were no rows to derive real columns from). The sibling point-in-timeAS OFarm already used the schema-aware matcher; the all-versions arm missed it during the shared-pipeline unification.Fix: the all-versions predicate path now uses
matches_with_resolved_schema, identical to theAS OFpath — it decodes the Binary Tuple via the schema before matching. Schemaless behaviour is unchanged.Regression test: added to
nodedb/tests/bitemporal_asof_scan_parity.rs(strict bitemporal collection;AS OF SYSTEM TIME NULL WHERE id='a'returns the matching versions with real columns). Verified green.- added a commit that references this issue
on Jul 19, 2026
Tested against:
origin/main @ 8e84501a(post-v0.3.0 main head, 2026-07-07)Severity: High — per-record history reads are the primary query shape on
a BITEMPORAL collection; every such read silently returns empty, making the
audit surface unusable while writes keep succeeding.
Summary
On a BITEMPORAL
document_strictcollection, a version-history scan(
AS OF SYSTEM TIME NULL) that also carries aWHEREpredicatereturns 0 rows silently. The bare
AS OF SYSTEM TIME NULLscan onthe same collection returns the full version set with correct
_ts_system/_ts_valid_from/_ts_valid_untilprojections, so theversioned store itself is intact — only the predicate-carrying scan
path drops everything.
ORDER BYmakes no difference. The result alsocomes back with a placeholder
resultcolumn header instead of thecollection's columns, suggesting the query resolves to an empty
synthetic result rather than a filtered scan.
Regression relative to
67c4572d, whereAS OF SYSTEM TIME NULL WHERE id = ...returned that record's versions; plausibly fallout of therecent unification of bitemporal document scans onto a shared pipeline.
Repro
Expected
AS OF SYSTEM TIME NULL+WHEREreturns the version rows matchingthe predicate — filtering a history scan must not differ semantically
from filtering a plain scan.
scan already does), not a placeholder
resultcolumn.Files (best-guess)
nodedb/src/data/executor/handlers/document/read/fetch.rs— newshared fetch pipeline; the predicate path appears not to be wired for
all-versions scans.
nodedb/src/data/executor/dispatch/document.rs— dispatch may routepredicate-carrying AS OF reads to a path that ignores the version
store.
Operational context
The whole point of a BITEMPORAL collection is answering "what did this
record look like over time" — i.e.
AS OF SYSTEM TIME NULL WHERE <key>.With that shape returning empty, audit-trail consumers must scan the
entire history of every record and filter client-side, which is
unbounded on a growing audit log.