summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormithun <mithun.c.y@oracle.com>2013-11-18 18:12:01 +0530
committermithun <mithun.c.y@oracle.com>2013-11-18 18:12:01 +0530
commitf847e58869a20ed06a3fdd0171eda3d4e08ed0e2 (patch)
tree38573c23a2d8482a55f7e44cc806c40cfd8c84aa /sql
parent4f5eab3987bad2f56860acaa19916bccb5d9ed47 (diff)
downloadmariadb-git-f847e58869a20ed06a3fdd0171eda3d4e08ed0e2.tar.gz
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.
Diffstat (limited to 'sql')
-rw-r--r--sql/filesort.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 20a290d24a0..57070063e84 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -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)