Skip to content

Conversation

@spetrunia
Copy link
Member

@spetrunia spetrunia commented Oct 24, 2025

  • The Jira issue number for this PR is: MDEV-37913

Description

MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs

(Variant 2)
SEL_TREE* tree_or(SEL_TREE *X, SEL_TREE *Y) tries to conserve memory by
reusing object *X for the return value when possible.

MDEV-34620 has added logic to disable construction of index_merge plans
for N-way ORs with large N. That logic interfered with object reuse logic:

for the parameters of:
X = SEL_TREE{ trees=[key1_treeA, key2_treeB]}
Y = SEL_TREE{ trees=[key1_treeC]}

we would decide to reuse object X.
For key1, we would produce key_or(key1_treeA, key1_treeC)
but key2_treeB would be just left there.
Then, we would construct a range scan from key2_treeB.

Fixed by moving the "disable building index_merge plans" logic into a
location where it would not interfere with object reuse logic.
  • This is a bug fix, and the PR is based against the earliest maintained branch in which the bug can be reproduced.

…re than 100 ORs

(Variant 2)
SEL_TREE* tree_or(SEL_TREE *X, SEL_TREE *Y) tries to conserve memory by
reusing object *X for the return value when possible.

MDEV-34620 has added logic to disable construction of index_merge plans
for N-way ORs with large N. That logic interfered with object reuse logic:

for the parameters of:
X = SEL_TREE{ trees=[key1_treeA, key2_treeB]}
Y = SEL_TREE{ trees=[key1_treeC]}

we would decide to reuse object X.
For key1, we would produce key_or(key1_treeA, key1_treeC)
but key2_treeB would be just left there.
Then, we would construct a range scan from key2_treeB.

Fixed by moving the "disable building index_merge plans" logic into a
location where it would not interfere with object reuse logic.
@spetrunia spetrunia changed the title DRAFT: MDEV-37913 MDEV-37913 : disable_index_merge_plans causes SELECT data loss when more than 100 ORs Oct 28, 2025
@spetrunia spetrunia changed the title MDEV-37913 : disable_index_merge_plans causes SELECT data loss when more than 100 ORs MDEV-37913: disable_index_merge_plans causes SELECT data loss when more than 100 ORs Oct 28, 2025
Copy link
Member

@DaveGosselin-MariaDB DaveGosselin-MariaDB left a comment

Choose a reason for hiding this comment

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

Verified that new return codepath is executed by new test case.
Verified that the tests from related MDEV-34620 pass and exercise the new return codepath.
Verified that the test fails without the fix because the prior logic could force tree1's key map to be empty incorrectly.
Checked code coverage results.
Ran complete regression suite.

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

Development

Successfully merging this pull request may close these issues.

4 participants