Skip to content

Commit

Permalink
MDEV-24975 Server consumes extra 4G memory upon querying INFORMATION_…
Browse files Browse the repository at this point in the history
…SCHEMA.OPTIIMIZER_TRACE

if a query used no fields from an I_S table, we were creating a temp
table with one, first, field (as a table cannot have zero fields),
with its length truncated to 1.

Now - force also this dummy field to be a normal field, not a BLOB
  • Loading branch information
vuvova committed Mar 8, 2021
1 parent f24038b commit 01a0d73
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mysql-test/main/opt_trace.result
Original file line number Diff line number Diff line change
Expand Up @@ -8591,4 +8591,13 @@ JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives'))
]
DROP TABLE t1;
set optimizer_trace='enabled=off';
#
# MDEV-24975 Server consumes extra 4G memory upon querying INFORMATION_SCHEMA.OPTIIMIZER_TRACE
#
set max_session_mem_used=1024*1024*1024;
select count(*) from information_schema.optimizer_trace;
select * from information_schema.optimizer_trace;
set max_session_mem_used=default;
#
# End of 10.4 tests
#
13 changes: 13 additions & 0 deletions mysql-test/main/opt_trace.test
Original file line number Diff line number Diff line change
Expand Up @@ -623,4 +623,17 @@ SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.range_scan_alternatives')) from IN
DROP TABLE t1;

set optimizer_trace='enabled=off';

--echo #
--echo # MDEV-24975 Server consumes extra 4G memory upon querying INFORMATION_SCHEMA.OPTIIMIZER_TRACE
--echo #
set max_session_mem_used=1024*1024*1024;
--disable_result_log
select count(*) from information_schema.optimizer_trace;
select * from information_schema.optimizer_trace;
--enable_result_log
set max_session_mem_used=default;

--echo #
--echo # End of 10.4 tests
--echo #
1 change: 1 addition & 0 deletions sql/sql_show.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8767,6 +8767,7 @@ bool optimize_schema_tables_memory_usage(List<TABLE_LIST> &tables)
{
/* all fields were optimized away. Force a non-0-length row */
table->s->reclength= to_recinfo->length= 1;
to_recinfo->type= FIELD_NORMAL;
to_recinfo++;
}
p->recinfo= to_recinfo;
Expand Down

0 comments on commit 01a0d73

Please sign in to comment.