Repository navigation
Conversation
gkodinov
requested changes
Sep 28, 2026
gkodinov
left a comment
Member
There was a problem hiding this comment.
Thank you for your contribution! This is a preliminary review.
DerZc
force-pushed
the
fix-mdev-39644
branch
from
September 29, 2026 03:11
ba93d34 to
a52c1e9
Compare
gkodinov
approved these changes
Sep 29, 2026
gkodinov
left a comment
Member
There was a problem hiding this comment.
Thanks! LGTM. Please stand by for the final review.
gkodinov
requested review from
mariadb-YuchenPei
and removed request for
holyfoot
September 29, 2026 10:01
DaveGosselin-MariaDB
left a comment
Member
There was a problem hiding this comment.
Recommend adding this to keep the queue buffer unchanged on a failed read:
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index bc5ccf1bfdc..342643a8618 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -104,7 +104,8 @@ static int read_with_icp(TABLE* table,
return func(record_buf);
int error= func(table->record[0]);
- memcpy(record_buf, table->record[0], record_buf_len);
+ if (likely(!error))
+ memcpy(record_buf, table->record[0], record_buf_len);
return error;
}
DaveGosselin-MariaDB
requested review from
spetrunia
and removed request for
mariadb-YuchenPei
October 19, 2026 15:37
DaveGosselin-MariaDB
left a comment
Member
There was a problem hiding this comment.
LGTM and passing to @spetrunia for final review.
Member
|
The patch looks generally good.
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index 342643a8618..ca3d6211e1e 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -8209,6 +8209,11 @@ int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order)
/* Caller has specified reverse_order */
break;
case partition_index_first:
+ /*
+ We don't call read_with_icp() here as full index scans are not done
+ with ICP.
+ */
+ DBUG_ASSERT(!pushed_idx_cond);
error= file->ha_index_first(rec_buf_ptr);
reverse_order= FALSE;
break;Running it in CI now... |
Ordered partition scans keep one row per partition in queue buffers. However, pushed index conditions use Field objects bound to table->record[0]. Reading directly into a queue buffer can therefore evaluate the condition against a different row and skip matching rows. Route ha_index_last() and ha_index_prev() through read_with_icp(), as already done for forward ordered reads. With ICP, read into table->record[0] and copy the row to the queue buffer only on success. Preserve the queue buffer when a read returns EOF or another error. Full forward index scans do not use ICP. Assert this invariant before calling ha_index_first() directly. Add a minimal MyISAM regression with matching and rejected rows in two partitions. Bug report: https://jira.mariadb.org/browse/MDEV-39644
Member
|
... CI didn't show any issues. |
spetrunia
enabled auto-merge (rebase)
October 20, 2026 15:31
Member
|
The failures are unrelated spurious errors, trying the other way. |
spetrunia
disabled auto-merge
October 21, 2026 07:14
Member
|
After some fight with unrelated CI failures, pushed this: @DerZc , thanks for the contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ordered partition scans keep one row per partition in queue buffers, while pushed index conditions use Field objects bound to
table->record[0]. Reading directly into a queue buffer can therefore evaluate a condition against a different row and skip matching rows.Route
ha_index_last()andha_index_prev()through the existingread_with_icp()helper, as already done for forward ordered reads. With ICP, read intotable->record[0]and copy the row to the queue buffer only on success. EOF and other read errors leave the queue buffer unchanged.Full forward index scans do not use ICP. Document and assert this invariant before calling
ha_index_first()directly.The minimal regression uses four rows in two MyISAM partitions, including matching rows and a row that the pushed condition must reject. The expected c1 values are 1, 2 and 4 in descending c2 order.
Bug report: https://jira.mariadb.org/browse/MDEV-39644
Validation
Based on
12.3at30728cb6725e793076a91d1b72865acb07a15bdf:main.partition_ordermatch. Fixing only the initial reverse read incorrectly returns(3,2,0), confirming coverage of subsequent reads.main.partition_order,main.partition_index_scan(asc/desc), andmain.select, in both ordinary and prepared-statement protocols on both builds: 16 successful combinations, without skips, retries, mismatches or cleanup failures.read_with_icp()helper covered 72 buffer/error scenarios under AddressSanitizer and UndefinedBehaviorSanitizer. The unguarded helper failed 18 preservation cases; the guarded helper passed all 72. No new sanitizer build was run for this assertion-only revision.