Skip to content

Conversation

devanbenz
Copy link

  • fix(tsm1): fix condition check for optimization of array cursor

The array ascending cursors do not check all the required conditions before doing an optimization to copy a full 1000 points of data from the tsm read buffer to the cursors response buffer. This can result in points from tsm files appearing in cursor output multiple times.

The conditions the bug appears are rare as it requires cache data that is older (or overlapping) with tsm data. The data must be in the same shard and must match for the same key.

This commit adds a test that verifies the duplicate data bug fix. It will fail without the previous commit. See the test for details; in short it sets up the right cache and tsm data to expose the bug which was occuring when the cache had older data than the tsm files and then the cache was exhausted while there were still more tsm values to include in more Next() calls.

  • chore(test): switch to using the testify library in the new test

The assert package is used for post conditions and the require package is used for pre-conditions in the test. The library provides clearer intent of conditions and better formatting of information (message and data) in the situation an assertion fails. It also makes it easier to read by reducing ifs but some lines are longer.

This commit addresses PR requests.

(cherry picked from commit 9d1e79d)

* fix(tsm1): fix condition check for optimization of array cursor

The array ascending cursors do not check all the required conditions
before doing an optimization to copy a full 1000 points of data from the
tsm read buffer to the cursors response buffer. This can result in
points from tsm files appearing in cursor output multiple times.

The conditions the bug appears are rare as it requires cache data that
is older (or overlapping) with tsm data. The data must be in the same
shard and must match for the same key.

* fixes #26690

* chore(tsm1): add test that covers array cursor bug

This commit adds a test that verifies the duplicate data bug fix. It
will fail without the previous commit. See the test for details; in
short it sets up the right cache and tsm data to expose the bug which
was occuring when the cache had older data than the tsm files and then
the cache was exhausted while there were still more tsm values to
include in more Next() calls.

* chore(test): switch to using the testify library in the new test

The assert package is used for post conditions and the require package
is used for pre-conditions in the test. The library provides clearer
intent of conditions and better formatting of information (message and
data) in the situation an assertion fails. It also makes it easier to
read by reducing ifs but some lines are longer.

This commit addresses PR requests.

(cherry picked from commit 9d1e79d)
Copy link
Contributor

@davidby-influx davidby-influx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devanbenz devanbenz merged commit 31cb61f into 1.12 Sep 30, 2025
9 checks passed
@devanbenz devanbenz deleted the db/cherrypick-9d1e7 branch September 30, 2025 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x area/flux Issues related to the Flux query engine kind/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[port to 1.12] [1.x oss]: Ascending key cursors may return same tsm values multiple times if merging with cache values
3 participants