Skip to content

A fields projection that omits a filtered tag column silently returns no rows, and drops a different subset depending on whether the data is mutable, sealed SLOW_PATH or sealed FAST_PATH #7733

Closed

Description

@ruispereira

Summary

A fields projection that omits a column named in tags makes the query return nothing, with HTTP 200 and truncated:false. And which rows are dropped depends on where the data currently lives, so the same query gives different answers as compaction runs.

buildTagMatchers refuses any condition on a column outside the projection:

if (columnIndices != null && !isInArray(cond.columnIndex(), columnIndices))
  return null;

and both scan directions turn that into an empty result:

final TagMatcher[] matchers = tagFilter == null ? null : buildTagMatchers(tagFilter, columnIndices);
if (tagFilter != null && matchers == null)
  // A condition on a column the caller did not ask for: nothing can match.
  return new ArrayList<>();

The stated reason, in buildTagMatchers's javadoc, is that "a condition on a column that the caller did not request cannot be satisfied, because the row handed back would not carry it". The evaluation order in the same file says otherwise:

if (matchers != null && !matchesTagFilter(page, rowOffset, matchers))
  continue;

final Object[] materialized = readRow(page, rowOffset, columnIndices);

The filter is evaluated against the page, and the projection materialises the row afterwards. The row handed back not carrying the column is irrelevant, because the filter never reads the row handed back. The restriction is unnecessary rather than merely strict.

The layers then disagree with each other:

  • the mutable bucket returns nothing (the code above);
  • sealed SLOW_PATH blocks return nothing (TagFilter.matchesMapped applies the same rule);
  • sealed FAST_PATH blocks do return the matching rows.

So the answer to one unchanged query changes as data ages from mutable to sealed and as compaction promotes blocks between paths.

Where (HEAD 151799e)

  • engine/src/main/java/com/arcadedb/engine/timeseries/TimeSeriesBucket.java:673-681 (buildTagMatchers, the refusal and its javadoc)
  • :565-568 (scanRangeAscending) and :459-462 (scanRangeDescending), the two callers that return an empty list
  • :617-621 (the evaluation order: matchesTagFilter on the page, then readRow with the projection)
  • TagFilter.matchesMapped for the sealed SLOW_PATH half

Repro

POST /api/v1/ts/{database}/query
{"type":"cpu","fields":["value"],"tags":{"host":"web1"}}

with samples present for host=web1. Response is {"rows":[],"count":0,"truncated":false} and HTTP 200. Adding "host" to fields returns the rows. Waiting for the data to seal and compact into FAST_PATH blocks also returns them, without any change to the query.

Suggested fix

Drop the projection check from buildTagMatchers and let the matcher carry the real column index, since matchesTagFilter reads the page and does not need the column to be projected. The same applies to TagFilter.matchesMapped on the sealed SLOW_PATH.

If the restriction is wanted for some reason not visible here, it must at least be uniform across the three layers, and it should be a 400 naming the column rather than an empty 200: a filter the engine silently declines to apply is indistinguishable from a filter that matched nothing.

Scope / confidence

High confidence on the mechanism and the evaluation order, both read directly at 151799eda2. The FAST_PATH divergence comes from the same audit and is what makes this a correctness bug rather than a documentation one.

Pre-existing via scanRange, but #7336 copied the guard verbatim into the new scanRangeAscending and routed POST /ts/{database}/query through it, which is how it reached this surface.

Activity

  1. added
    audit
    engine
    timeseries
    on Sep 16, 2026
  2. added this to the 26.10.1 milestone on Sep 16, 2026
  3. added
    in progress
    on Sep 16, 2026
  4. self-assigned this
    on Sep 16, 2026
  5. added 4 commits that reference this issue on Sep 16, 2026
  6. added a commit that references this issue on Sep 17, 2026
  7. lvca commented on Sep 17, 2026

    @lvca
    Member

    Fixed in #7747, merged into main for 26.10.1.

    A query that asked for some columns and filtered on a tag column it did not ask for - for example {"fields":["value"],"tags":{"host":"web1"}} - came back empty with HTTP 200, as if nothing matched. Adding the tag to fields returned the rows, and so did waiting for the data to be compacted, so the same query could give you two different answers depending on how old the samples were.

    The filter is now applied before the columns are narrowed down, on every storage layer, so it no longer matters whether the column you filter on is one you asked to see. As a side effect these queries are also a little faster: a row that does not match is never built.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  8. removed
    in progress
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

auditbugenginetimeseries

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions