mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 03:52:35 +01:00
Bug #17708621 : EXCEEDING SORT_BUFFER_SIZE (FILE SORT)
WITH SORT ABORTED LEAKS FILE DESCRIPTORS ISSUE : IO_CACHE used for index_merge quick select is freed only on successful retrieval of all rows from index merge. Suppose if there is a interrupt( or failure) to this operation of row retrieval (let it be a KILL_QUERY signal) then we are not freeing the IO_CACHE resources allocated by index_merge quick select. And hence temp file associated with it is also not closed. This lead to a file descriptor leak. SOLUTION : As part of file sort operation now we always free the IO_CACHE allocated by index_merge quick select. sql/filesort.cc: In filesort function we try to free if any IO_CACHE allocated by index_merge quick select and if it is not yet freed.
This commit is contained in:
parent
19f00f6d17
commit
020edb1cab
1 changed files with 14 additions and 0 deletions
|
@ -34,6 +34,7 @@
|
|||
#include "sql_test.h" // TEST_filesort
|
||||
#include "opt_range.h" // SQL_SELECT
|
||||
#include "debug_sync.h"
|
||||
#include "sql_base.h"
|
||||
|
||||
/// How to write record_ref.
|
||||
#define WRITE_REF(file,from) \
|
||||
|
@ -337,6 +338,14 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
|||
{
|
||||
int kill_errno= thd->killed_errno();
|
||||
DBUG_ASSERT(thd->is_error() || kill_errno);
|
||||
|
||||
/*
|
||||
We replace the table->sort at the end.
|
||||
Hence calling free_io_cache to make sure table->sort.io_cache
|
||||
used for QUICK_INDEX_MERGE_SELECT is free.
|
||||
*/
|
||||
free_io_cache(table);
|
||||
|
||||
my_printf_error(ER_FILSORT_ABORT,
|
||||
"%s: %s",
|
||||
MYF(ME_ERROR + ME_WAITTANG),
|
||||
|
@ -363,6 +372,10 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length,
|
|||
#ifdef SKIP_DBUG_IN_FILESORT
|
||||
DBUG_POP(); /* Ok to DBUG */
|
||||
#endif
|
||||
|
||||
/* table->sort.io_cache should be free by this time */
|
||||
DBUG_ASSERT(NULL == table->sort.io_cache);
|
||||
|
||||
memcpy(&table->sort, &table_sort, sizeof(FILESORT_INFO));
|
||||
DBUG_PRINT("exit",("num_rows: %ld", (long) num_rows));
|
||||
MYSQL_FILESORT_DONE(error, num_rows);
|
||||
|
@ -602,6 +615,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
|
|||
(uchar*) sort_form);
|
||||
sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set);
|
||||
|
||||
DEBUG_SYNC(thd, "after_index_merge_phase1");
|
||||
for (;;)
|
||||
{
|
||||
if (quick_select)
|
||||
|
|
Loading…
Reference in a new issue