Skip to content

MDEV-41243, MDEV-41273 Don't freeze mem_root after engine pushdown - #5783

Open
bsrikanth-mariadb wants to merge 1 commit into
13.2-MDEV-39226-direct-multi_table-update-deletefrom
13.2-MDEV-41243-fedx-pushdown-assert-for-upd-del-prepared-stmts
Open

bsrikanth-mariadb wants to merge 1 commit into
13.2-MDEV-39226-direct-multi_table-update-deletefrom
13.2-MDEV-41243-fedx-pushdown-assert-for-upd-del-prepared-stmts

Conversation

@bsrikanth-mariadb

@bsrikanth-mariadb bsrikanth-mariadb commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

When a statement is pushed down to an engine, the once-per-statement
part of the optimization (e.g. the first_cond_optimization part of
JOIN::optimize(), or the whole of JOIN::optimize() for a pushed down
UNION) is skipped. Re-executing the same prepared statement or stored
routine without pushdown then allocated from a mem_root already marked
ROOT_FLAG_READ_ONLY, hitting an assertion in alloc_root().

Add LEX::dont_freeze_mem_root, set by the pushdown_handler and
derived_handler constructors so it covers every engine implementing
them. Prepared_statement::execute_loop(), sp_head::execute() (through
sp_head::dont_freeze_mem_root) and the SP instruction reparse path no
longer freeze the mem_root of such statements. The flag is only
declared and used in PROTECT_STATEMENT_MEMROOT builds.

Note this disables the mem_root protection for the statement for good,
even if later executions are not pushed down. For a stored routine one
pushed down instruction disables it for the whole routine.

Add tests for prepared SELECT, UNION, UPDATE and DELETE, prepared EXPLAIN
of a pushed UNION, derived tables, stored procedures, functions,
triggers, cursors and metadata-invalidation reparse, with pushdown
switched on and off in either order. The routine and prepared statement
tests check the statements received by the remote server to verify that
pushdown actually happened.

@bsrikanth-mariadb
bsrikanth-mariadb force-pushed the 13.2-MDEV-41243-fedx-pushdown-assert-for-upd-del-prepared-stmts branch from 1a678a5 to 437d6a6 Compare October 5, 2026 02:48
When a statement is pushed down to an engine, the once-per-statement
part of the optimization (e.g. the first_cond_optimization part of
JOIN::optimize(), or the whole of JOIN::optimize() for a pushed down
UNION) is skipped. Re-executing the same prepared statement or stored
routine without pushdown then allocated from a mem_root already marked
ROOT_FLAG_READ_ONLY, hitting an assertion in alloc_root().

Add LEX::dont_freeze_mem_root, set by the pushdown_handler and
derived_handler constructors so it covers every engine implementing
them. Prepared_statement::execute_loop(), sp_head::execute() (through
sp_head::dont_freeze_mem_root) and the SP instruction reparse path no
longer freeze the mem_root of such statements. The flag is only
declared and used in PROTECT_STATEMENT_MEMROOT builds.

Note this disables the mem_root protection for the statement for good,
even if later executions are not pushed down. For a stored routine one
pushed down instruction disables it for the whole routine.

Add tests for prepared SELECT, UNION, UPDATE and DELETE, prepared EXPLAIN
of a pushed UNION, derived tables, stored procedures, functions,
triggers, cursors and metadata-invalidation reparse, with pushdown
switched on and off in either order. The routine and prepared statement
tests check the statements received by the remote server to verify that
pushdown actually happened.
@bsrikanth-mariadb
bsrikanth-mariadb force-pushed the 13.2-MDEV-41243-fedx-pushdown-assert-for-upd-del-prepared-stmts branch from 437d6a6 to 5072028 Compare October 5, 2026 04:45
@bsrikanth-mariadb bsrikanth-mariadb changed the title MDEV-41243, MDEV-41273: update, delete, select prepared statements assert with fedx_pushdown MDEV-41243, MDEV-41273 Don't freeze mem_root after engine pushdown Oct 5, 2026
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.

2 participants