Bug #99100 GROUP BY will throw table is full when temptable memory allocation exceed limit
Submitted: 27 Mar 2020 13:22 Modified: 6 Apr 2020 14:58
Reporter: Dean Zhou Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: 1114, table is full, temptable

[27 Mar 2020 13:22] Dean Zhou
Description:
Running a query that is using a temporary table for GROUP BY will throw "the table is XXXXX full" .

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
ERROR 1114 (HY000): The table '/data/mysql5858/tmp/#sql639b7_13_4' is ful

How to repeat:
1. test environment
sysbench insert  10000 into sbtest1
alter table sbtest1 modify pad varchar(60) NOT NULL DEFAULT '';
set global temptable_max_ram = 2097152;
set global temptable_use_mmap = 0;

2. execute sql

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;  // Execute twice

mysql> update sbtest1 set pad =  '69934613059-88090326252-43723189827-95836596353-21488500475' where id = 1;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

//  id = 3549 row is an experience value, When processing this row, temptable will be converted to a disk temporary table, You can get the exact row by printing the log before create_ondisk_from_heap is executed

mysql> update sbtest1 set pad =  '69934613059-88090326252-43723189827-95836596353-21488500475' where id = 3549; 
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
ERROR 1114 (HY000): The table '/data/mysql5858/tmp/#sql639b7_13_4' is full
mysql> 

Suggested fix:

the gdb stack:
temptable::Memory<(temptable::Source)0>::allocate (bytes=<optimized out>) at /data/mysql-8.0.19-official/storage/temptable/include/temptable/memutils.h:132
132         if (!temptable_use_mmap) {
(gdb) p temptable_use_mmap
$2 = false
(gdb) n
133           throw Result::RECORD_FILE_FULL;
(gdb) bt
#0  temptable::Memory<(temptable::Source)0>::allocate (bytes=<optimized out>) at /data/mysql-8.0.19-official/storage/temptable/include/temptable/memutils.h:133
#1  temptable::allocate_from (size=<optimized out>, src=<optimized out>) at /data/mysql-8.0.19-official/storage/temptable/include/temptable/block.h:282
#2  temptable::Block::Block (memory_source=<optimized out>, size=<optimized out>, this=<optimized out>) at /data/mysql-8.0.19-official/storage/temptable/include/temptable/block.h:307
#3  temptable::Allocator<unsigned char, temptable::AllocationScheme::Exponential>::allocate (n_elements=128, this=0x7fa7ec0a7f80) at /data/mysql-8.0.19-official/storage/temptable/include/temptable/allocator.h:371
#4  temptable::Row::copy_to_own_memory (this=this@entry=0x7fadc47e8320, columns=std::vector of length 3, capacity 3 = {...}, mysql_row_length=<optimized out>) at /data/mysql-8.0.19-official/storage/temptable/src/row.cc:74
#5  0x00000000023bc4cf in temptable::Table::update (this=0x7fa7ec0a7f80, mysql_row_old=<optimized out>, mysql_row_new=0x7fa7ec1197f8 "", target_row=0x7fa7e69129c8) at /data/mysql-8.0.19-official/storage/temptable/src/table.cc:194
#6  0x0000000001026a77 in handler::ha_update_row (this=0x7fa7ec118168, old_data=0x7fa7ec11a008 "", new_data=0x7fa7ec1197f8 "") at /data/mysql-8.0.19-official/sql/handler.cc:7889
#7  0x0000000000fd01bd in TemptableAggregateIterator::Init (this=0x7fa7ec05c5e0) at /data/mysql-8.0.19-official/sql/composite_iterators.cc:1408
#8  0x0000000001009de3 in filesort (thd=0x7fa7ec000d70, filesort=0x7fa7ec05c3f0, source_iterator=0x7fa7ec05c5e0, fs_info=fs_info@entry=0x7fa7ec05c680, sort_result=sort_result@entry=0x7fa7ec05c708, found_rows=found_rows@entry=0x7fadc47e89f8)
    at /data/mysql-8.0.19-official/sql/filesort.cc:416
#9  0x0000000000d519f5 in SortingIterator::DoSort (this=this@entry=0x7fa7ec05c640, qep_tab=qep_tab@entry=0x7fa7ec05bb40) at /data/mysql-8.0.19-official/sql/sorting_iterator.cc:636
#10 0x0000000000d51b02 in SortingIterator::Init (this=0x7fa7ec05c640) at /data/mysql-8.0.19-official/sql/sorting_iterator.cc:498
#11 0x0000000000fcc286 in LimitOffsetIterator::Init (this=0x7fa7ec05c7c8) at /data/mysql-8.0.19-official/sql/composite_iterators.cc:102
#12 0x0000000000e99ae8 in SELECT_LEX_UNIT::ExecuteIteratorQuery (this=this@entry=0x7fa7ec00a278, thd=thd@entry=0x7fa7ec000d70) at /data/mysql-8.0.19-official/sql/sql_union.cc:1498
#13 0x0000000000e9bdd9 in SELECT_LEX_UNIT::execute (this=this@entry=0x7fa7ec00a278, thd=thd@entry=0x7fa7ec000d70) at /data/mysql-8.0.19-official/sql/sql_union.cc:1588
#14 0x0000000000e2f5db in Sql_cmd_dml::execute_inner (this=0x7fa7ec05ae88, thd=0x7fa7ec000d70) at /data/mysql-8.0.19-official/sql/sql_select.cc:910
#15 0x0000000000e38a38 in Sql_cmd_dml::execute (this=0x7fa7ec05ae88, thd=0x7fa7ec000d70) at /data/mysql-8.0.19-official/sql/sql_select.cc:715
#16 0x0000000000deb1b8 in mysql_execute_command (thd=thd@entry=0x7fa7ec000d70, first_level=first_level@entry=true) at /data/mysql-8.0.19-official/sql/sql_parse.cc:4478
#17 0x0000000000ded605 in mysql_parse (thd=thd@entry=0x7fa7ec000d70, parser_state=parser_state@entry=0x7fadc47ea4d0) at /data/mysql-8.0.19-official/sql/sql_parse.cc:5288
#18 0x0000000000dee819 in dispatch_command (thd=thd@entry=0x7fa7ec000d70, com_data=com_data@entry=0x7fadc47eabc0, command=COM_QUERY) at /data/mysql-8.0.19-official/sql/sql_parse.cc:1777
#19 0x0000000000df065c in do_command (thd=thd@entry=0x7fa7ec000d70) at /data/mysql-8.0.19-official/sql/sql_parse.cc:1275
#20 0x0000000000effa68 in handle_connection (arg=arg@entry=0x4fe3c40) at /data/mysql-8.0.19-official/sql/conn_handler/connection_handler_per_thread.cc:302
#21 0x00000000023355c9 in pfs_spawn_thread (arg=0x526a530) at /data/mysql-8.0.19-official/storage/perfschema/pfs.cc:2854
#22 0x00007fade24cadd5 in start_thread () from /lib64/libpthread.so.0
#23 0x00007fade063f02d in clone () from /lib64/libc.so.6

table()->file->ha_update_row will throw HA_ERR_RECORD_FILE_FULL when temptable consumed memory exceed temptable_max_ram, see the gdb stack for details on memory allocation failure. The correct
 way is that if error code is HA_ERR_RECORD_FILE_FULL, then TemptableAggregateIterator::Init add create_ondisk_from_heap function, convert temptable to innodb disk temp table, then call table()->file->ha_index_read_map position cursor, finally execute table()->file->ha_update_row again

bool TemptableAggregateIterator::Init() { 

...
    } else {
      for (ORDER *group = table()->group; group; group = group->next) {
        Item *item = *group->item;
        item->save_org_in_field(group->field_in_tmp_table);
        /* Store in the used key if the field was 0 */
        if (item->maybe_null)
          group->buff[-1] = (char)group->field_in_tmp_table->is_null();
      }
      const uchar *key = m_temp_table_param->group_buff;
      group_found = !table()->file->ha_index_read_map(
          table()->record[1], key, HA_WHOLE_KEY, HA_READ_KEY_EXACT);
    }
    if (group_found) {
      // Update the existing record. (If it's unchanged, that's a
      // nonfatal error.)
      restore_record(table(), record[1]);
      update_tmptable_sum_func(m_join->sum_funcs, table());
      int error =
          table()->file->ha_update_row(table()->record[1], table()->record[0]);   
      if (error != 0 && error != HA_ERR_RECORD_IS_THE_SAME) {
        PrintError(error);
        return true;
      }
      continue;
    }

...	

}
[30 Mar 2020 13:36] MySQL Verification Team
Hi Mr. Zhou,

Thank you for your bug report.

Your report looks very interesting. With settings that you used, if internal in-memory TempTable overflows your setting of 2 Mb, it would be converted into InnoDB table.

Hence, we would very much like to repeat this behaviour. For that purpose we need a dump of your table in question. You can make a smaller table then the one you use, but it is important that we repeat the behaviour that you are reporting.

Thank you very much in advance.
[31 Mar 2020 9:29] Dean Zhou
test data

Attachment: sbtest1.sql (application/octet-stream, text), 1.87 MiB.

[31 Mar 2020 9:39] Dean Zhou
Hi Sinisa Milivojevic:

My test data have been uploaded. The repeat operation as follows:
1. restart mysqld

2.  load data
mysql -S /data/mysql5858/mysql.sock  test < sbtest1

3. execute sql
mysql> set global temptable_max_ram = 2097152;
Query OK, 0 rows affected (0.00 sec)

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
| cnt | pad                                                         | c                                                                                                                       |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
|   2 | 69934613059-88090326252-43723189827-95836596353-21488500475 | 50739423477-59896895752-91121550334-25071371310-03454727381-25307272676-12883025003-48844794346-97662793974-67443907837 |
|   1 | 00008932442-46813404728-01940988773-52841132560-83229624724 | 39545630315-26642029789-33173101198-03433120718-18245412627-25499335728-86684299507-68747727553-68821166586-23320828147 |

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
ERROR 1114 (HY000): The table '/data/mysql5858/tmp/#sql6d02f_9_3' is full

--------------------------

Only when the table()->file->ha_update_row() is executed, a temptable memory overflow can trigger an error, You have to construct this scene. 

In my case, the row id = 1 and the row id = 3549 has same pad value '69934613059-88090326252-43723189827-95836596353-21488500475', the row id = 1 first processed, then when the row id = 3549 iterate, it find duplicate pad value in temptable, so call table()->file->ha_update_row(), if temptable memory overflow happen, an error may throw. 

If you still not repeat ,you can position the row that trigger temptable memory overflow as follows:

edit sql/composite_iterators.cc

// add function
static std::string buf_to_raw(const uchar *buf, uint buf_size_bytes) {
  std::string r;
  r.reserve(buf_size_bytes);
  for (uint i = 0; i < buf_size_bytes; ++i) {
    const uchar c = buf[i];
    r += static_cast<char>(isprint(c) ? c : '.');
  }
  return r;
}

bool TemptableAggregateIterator::Init() { 
...

// print the row,  When this row was process, a temptable memory overflow  was triggered, causing the convert to disk table.  Then update this row pad value, make pad value duplicate.

fprintf(stderr, "dean begin create_ondisk_from_heap: %s\n", buf_to_raw(table()->record[0], table()->s->reclength).c_str());
if (create_ondisk_from_heap(thd(), table(), error, false, NULL)) {
 	end_unique_index.commit();
 	return true;  // Not a table_is_full error.
}
...

}
[31 Mar 2020 14:38] MySQL Verification Team
Hi Mr. Zhou,

I have tried to repeat your test case.

In your steps you omitted two details. First, ONLY_FULL_GROUP_BY should not be set in the sql_mode.

Second, temptable_use_mmap=0 should be set as well.

However, I tried three times and could not repeat the behaviour:

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc limit 0,10;
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
| cnt | pad                                                         | c                                                                                                                       |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
|   2 | 69934613059-88090326252-43723189827-95836596353-21488500475 | 50739423477-59896895752-91121550334-25071371310-03454727381-25307272676-12883025003-48844794346-97662793974-67443907837 |
|   1 | 00008932442-46813404728-01940988773-52841132560-83229624724 | 39545630315-26642029789-33173101198-03433120718-18245412627-25499335728-86684299507-68747727553-68821166586-23320828147 |
|   1 | 00012121473-99340742818-65645218245-24672190492-91206300763 | 10551337033-35012101948-10777343612-40342522882-55133369504-03274346501-88550763035-44986334365-50440772271-05209617886 |
|   1 | 00014707131-35961550937-96740474351-20764844506-51790117327 | 65909732174-08915122040-84703019410-88540499992-36625696192-56977236518-37644208706-63093978941-41930549832-33750809425 |
|   1 | 00015972636-12938797184-51480469689-95438959539-49609260223 | 25223568049-11393603278-58393229064-23925481880-78860656214-64411479937-22473237394-93102487604-86556078208-89998390593 |
|   1 | 00025657405-89720992240-75705004494-59945544768-03922509539 | 22255864436-61183834403-74800947466-54206596558-28113794942-84230886096-95282314842-38929134176-64704205104-61809024504 |
|   1 | 00031797732-28539023142-12749859403-49115835313-49859166692 | 67668351388-27412243714-36400684636-76684336020-09618768230-20100590242-56285492525-81444741143-27857444804-76698775731 |
|   1 | 00040693668-14897682639-78422250679-07899532961-01913290396 | 33496983956-04778812647-96555973965-53303752721-42532112217-28755536610-90515137014-56475965986-12380271982-81588142687 |
|   1 | 00052612811-83871450789-38629549990-99368533768-69494881700 | 92736175277-32828338665-47548678925-35112523595-99270925935-50009548284-07458205883-48817201800-26127652859-35595913518 |
|   1 | 00059584344-80865914534-06944141263-71034194819-41225372610 | 10605791058-03493906918-64934487291-20725760796-45864390924-78283400000-05423546275-70094329459-55378101721-04884213222 |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
10 rows in set (0.90 sec)

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc limit 0,10;
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
| cnt | pad                                                         | c                                                                                                                       |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
|   2 | 69934613059-88090326252-43723189827-95836596353-21488500475 | 50739423477-59896895752-91121550334-25071371310-03454727381-25307272676-12883025003-48844794346-97662793974-67443907837 |
|   1 | 00008932442-46813404728-01940988773-52841132560-83229624724 | 39545630315-26642029789-33173101198-03433120718-18245412627-25499335728-86684299507-68747727553-68821166586-23320828147 |
|   1 | 00012121473-99340742818-65645218245-24672190492-91206300763 | 10551337033-35012101948-10777343612-40342522882-55133369504-03274346501-88550763035-44986334365-50440772271-05209617886 |
|   1 | 00014707131-35961550937-96740474351-20764844506-51790117327 | 65909732174-08915122040-84703019410-88540499992-36625696192-56977236518-37644208706-63093978941-41930549832-33750809425 |
|   1 | 00015972636-12938797184-51480469689-95438959539-49609260223 | 25223568049-11393603278-58393229064-23925481880-78860656214-64411479937-22473237394-93102487604-86556078208-89998390593 |
|   1 | 00025657405-89720992240-75705004494-59945544768-03922509539 | 22255864436-61183834403-74800947466-54206596558-28113794942-84230886096-95282314842-38929134176-64704205104-61809024504 |
|   1 | 00031797732-28539023142-12749859403-49115835313-49859166692 | 67668351388-27412243714-36400684636-76684336020-09618768230-20100590242-56285492525-81444741143-27857444804-76698775731 |
|   1 | 00040693668-14897682639-78422250679-07899532961-01913290396 | 33496983956-04778812647-96555973965-53303752721-42532112217-28755536610-90515137014-56475965986-12380271982-81588142687 |
|   1 | 00052612811-83871450789-38629549990-99368533768-69494881700 | 92736175277-32828338665-47548678925-35112523595-99270925935-50009548284-07458205883-48817201800-26127652859-35595913518 |
|   1 | 00059584344-80865914534-06944141263-71034194819-41225372610 | 10605791058-03493906918-64934487291-20725760796-45864390924-78283400000-05423546275-70094329459-55378101721-04884213222 |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
10 rows in set (0.90 sec)

Are there any settings that should be used ?????
[1 Apr 2020 3:37] Dean Zhou
Hi, Sinisa Milivojevic:

Yes, I have set sql_mode='' and temptable_use_mmap=0.  

Because the memory consumption of each environment is different,  Trigger conditions are very strict,  temptable memory overflow must happen in table()->file->ha_update_row().

In my case, the trigger row is the row with id = 3549, It could be other row in your environmen, As I said above, I suggest you add log info to print the row that trigger temptable memory overflow, then update pad value of the row, make pad value duplicate with row id = 1, and then you can repeat "the table is full" error.
[2 Apr 2020 12:14] MySQL Verification Team
Hi Mr. Zhou,

I have ran several more tests and I managed to repeat the behaviour:

mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
| cnt | pad                                                         | c                                                                                                                       |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
|   2 | 69934613059-88090326252-43723189827-95836596353-21488500475 | 50739423477-59896895752-91121550334-25071371310-03454727381-25307272676-12883025003-48844794346-97662793974-67443907837 |
|   1 | 00008932442-46813404728-01940988773-52841132560-83229624724 | 39545630315-26642029789-33173101198-03433120718-18245412627-25499335728-86684299507-68747727553-68821166586-23320828147 |
|   1 | 00012121473-99340742818-65645218245-24672190492-91206300763 | 10551337033-35012101948-10777343612-40342522882-55133369504-03274346501-88550763035-44986334365-50440772271-05209617886 |
|   1 | 00014707131-35961550937-96740474351-20764844506-51790117327 | 65909732174-08915122040-84703019410-88540499992-36625696192-56977236518-37644208706-63093978941-41930549832-33750809425 |
|   1 | 00015972636-12938797184-51480469689-95438959539-49609260223 | 25223568049-11393603278-58393229064-23925481880-78860656214-64411479937-22473237394-93102487604-86556078208-89998390593 |
|   1 | 00025657405-89720992240-75705004494-59945544768-03922509539 | 22255864436-61183834403-74800947466-54206596558-28113794942-84230886096-95282314842-38929134176-64704205104-61809024504 |
|   1 | 00031797732-28539023142-12749859403-49115835313-49859166692 | 67668351388-27412243714-36400684636-76684336020-09618768230-20100590242-56285492525-81444741143-27857444804-76698775731 |
|   1 | 00040693668-14897682639-78422250679-07899532961-01913290396 | 33496983956-04778812647-96555973965-53303752721-42532112217-28755536610-90515137014-56475965986-12380271982-81588142687 |
|   1 | 00052612811-83871450789-38629549990-99368533768-69494881700 | 92736175277-32828338665-47548678925-35112523595-99270925935-50009548284-07458205883-48817201800-26127652859-35595913518 |
|   1 | 00059584344-80865914534-06944141263-71034194819-41225372610 | 10605791058-03493906918-64934487291-20725760796-45864390924-78283400000-05423546275-70094329459-55378101721-04884213222 |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
10 rows in set (0.11 sec)

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
ERROR 1114 (HY000): The table '/tmp/#sql1967_9_3' is full
mysql>
mysql>
mysql> use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
| cnt | pad                                                         | c                                                                                                                       |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
|   2 | 69934613059-88090326252-43723189827-95836596353-21488500475 | 50739423477-59896895752-91121550334-25071371310-03454727381-25307272676-12883025003-48844794346-97662793974-67443907837 |
|   1 | 00008932442-46813404728-01940988773-52841132560-83229624724 | 39545630315-26642029789-33173101198-03433120718-18245412627-25499335728-86684299507-68747727553-68821166586-23320828147 |
|   1 | 00012121473-99340742818-65645218245-24672190492-91206300763 | 10551337033-35012101948-10777343612-40342522882-55133369504-03274346501-88550763035-44986334365-50440772271-05209617886 |
|   1 | 00014707131-35961550937-96740474351-20764844506-51790117327 | 65909732174-08915122040-84703019410-88540499992-36625696192-56977236518-37644208706-63093978941-41930549832-33750809425 |
|   1 | 00015972636-12938797184-51480469689-95438959539-49609260223 | 25223568049-11393603278-58393229064-23925481880-78860656214-64411479937-22473237394-93102487604-86556078208-89998390593 |
|   1 | 00025657405-89720992240-75705004494-59945544768-03922509539 | 22255864436-61183834403-74800947466-54206596558-28113794942-84230886096-95282314842-38929134176-64704205104-61809024504 |
|   1 | 00031797732-28539023142-12749859403-49115835313-49859166692 | 67668351388-27412243714-36400684636-76684336020-09618768230-20100590242-56285492525-81444741143-27857444804-76698775731 |
|   1 | 00040693668-14897682639-78422250679-07899532961-01913290396 | 33496983956-04778812647-96555973965-53303752721-42532112217-28755536610-90515137014-56475965986-12380271982-81588142687 |
|   1 | 00052612811-83871450789-38629549990-99368533768-69494881700 | 92736175277-32828338665-47548678925-35112523595-99270925935-50009548284-07458205883-48817201800-26127652859-35595913518 |
|   1 | 00059584344-80865914534-06944141263-71034194819-41225372610 | 10605791058-03493906918-64934487291-20725760796-45864390924-78283400000-05423546275-70094329459-55378101721-04884213222 |
+-----+-------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------+
10 rows in set (0.11 sec)

mysql> select count(*) cnt, pad, c from sbtest1 group by pad order by cnt desc  limit 0, 10;
ERROR 1114 (HY000): The table '/tmp/#sql1967_9_3' is full
mysql>
mysql>

I have checked and 8.0.18 does not have the same behaviour. That means that this is a regression bug in 8.0.19 and so, it should get a severity of S2.

Verified as reported.
[6 Apr 2020 14:58] Dean Zhou
Hi, Sinisa Milivojevic:

Thank you for verification, I can reproduce in 8.0.16, 8.0.18, 8.0.19. The temptable_use_mmap variable introduced by 8.0.16.

// 8.0.16 source code
template <class T> inline void *Allocator<T>::mem_fetch(size_t bytes) {
...
  if (t == Mem_type::RAM) {
    ptr = mem_fetch_from_ram(bytes);
    if (ptr == nullptr) {
      throw Result::OUT_OF_MEM;
    }
  } else {
    DBUG_ASSERT(t == Mem_type::DISK);
    if (!temptable_use_mmap) {						// if temptable_use_mmap = 0, it will throw RECORD_FILE_FULL
      throw Result::RECORD_FILE_FULL;
    }
    ptr = mem_fetch_from_disk(bytes);
    if (ptr == nullptr) {
      throw Result::RECORD_FILE_FULL;
    }
  }

...

}

I found that the TemptableAggregateIterator::Init() and end_update() did not catch the RECORD_FILE_FULL error returned by table()->file->ha_update_row();	
We shoud catch RECORD_FILE_FULL error, then convert temptable to disk table.
[7 Apr 2020 12:11] MySQL Verification Team
Thank you, Mr. Zhou.

We shall make your findings available to our developers.
[21 Apr 13:32] MySQL Verification Team
Setting the correct severity.
[27 Apr 7:22] Simon Mudd
Seen up to 8.0.23 with sys queries as simple as:

user@host [(none)]> select user, current_memory from sys.user_summary where user="some_username";
ERROR 1114 (HY000): The table '../tmp/#sqlfe4_b9deb6_6' is full
user@host [(none)]>

This is a surprising error for such a query and if it's expected (I guess now it is) then a comment on how to work around it or what is going on would be useful in the docs.
[6 May 8:21] MySQL Verification Team
Workaround:

set session internal_tmp_mem_storage_engine=Memory;
[10 Jun 11:41] Todd McGuinness
Any updates on this?  We are still experiencing this on version 8.0.25...
[10 Jun 12:39] MySQL Verification Team
Hi Mr. Zhou,

Thank you for your enquiry. 

MySQL Verification team is not informed on the scheduling or any progress in relation to the verified bugs, so we are not able to update this page. When the bug is fixed, then another department will close this report with a comment on which MySQL version will contain the fix.

Meanwhile, you have an easy workaround for the problem.