diff options
author | Kentoku SHIBA <kentokushiba@gmail.com> | 2019-07-30 06:16:48 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-30 06:16:48 +0900 |
commit | 6dfa085fd5cfa9f4edd91b2a02ebeb8bd71d4966 (patch) | |
tree | 84ef3642467bc00327d08a16700eb9f0fb9343e5 | |
parent | 7221b9ef520a18bb834855fe0deb37e4a390ec14 (diff) | |
download | mariadb-git-6dfa085fd5cfa9f4edd91b2a02ebeb8bd71d4966.tar.gz |
MDEV-20179 Server hangs on shutdown during installation of Spider (#1368)
-rw-r--r-- | storage/spider/spd_include.h | 1 | ||||
-rw-r--r-- | storage/spider/spd_malloc.h | 5 | ||||
-rw-r--r-- | storage/spider/spd_table.cc | 28 |
3 files changed, 23 insertions, 11 deletions
diff --git a/storage/spider/spd_include.h b/storage/spider/spd_include.h index 8b0581b9bd9..6cd7ddfa181 100644 --- a/storage/spider/spd_include.h +++ b/storage/spider/spd_include.h @@ -293,6 +293,7 @@ typedef struct st_spider_thread volatile bool thd_wait; volatile bool first_free_wait; volatile bool init_command; + volatile int error; pthread_t thread; pthread_cond_t cond; pthread_mutex_t mutex; diff --git a/storage/spider/spd_malloc.h b/storage/spider/spd_malloc.h index abbeb58d71c..9e97e039e04 100644 --- a/storage/spider/spd_malloc.h +++ b/storage/spider/spd_malloc.h @@ -1,4 +1,5 @@ -/* Copyright (C) 2012-2014 Kentoku Shiba +/* Copyright (C) 2012-2019 Kentoku Shiba + Copyright (C) 2019 MariaDB corp This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -19,7 +20,7 @@ #define spider_bulk_malloc(A,B,C,...) \ spider_bulk_alloc_mem(A,B,__func__,__FILE__,__LINE__,C,__VA_ARGS__) #define spider_current_trx \ - (current_thd ? ((SPIDER_TRX *) thd_get_ha_data(current_thd, spider_hton_ptr)) : NULL) + (current_thd && spider_hton_ptr->slot != HA_SLOT_UNDEF ? ((SPIDER_TRX *) thd_get_ha_data(current_thd, spider_hton_ptr)) : NULL) #define init_calc_mem(A) init_mem_calc(A,__func__,__FILE__,__LINE__) diff --git a/storage/spider/spd_table.cc b/storage/spider/spd_table.cc index 718591fc7cf..bc788d3e168 100644 --- a/storage/spider/spd_table.cc +++ b/storage/spider/spd_table.cc @@ -7380,10 +7380,16 @@ int spider_db_init( DBUG_PRINT("info",("spider before releasing mutex")); pthread_mutex_unlock(&spider_table_sts_threads[0].mutex); DBUG_PRINT("info",("spider after releasing mutex")); + if (spider_table_sts_threads[0].error) + { + error_num = spider_table_sts_threads[0].error; + goto error_init_sql; + } #endif DBUG_RETURN(0); #ifndef WITHOUT_SPIDER_BG_SEARCH +error_init_sql: error_init_dbton: for (roop_count--; roop_count >= 0; roop_count--) { @@ -10033,7 +10039,8 @@ void *spider_table_bg_sts_action( (uint) spider_init_queries[i].length, FALSE, FALSE); if (unlikely(thd->is_error())) { - fprintf(stderr, "[ERROR] %s\n", thd->get_stmt_da()->message()); + thread->error = spider_stmt_da_sql_errno(thd); + fprintf(stderr, "[ERROR] %s\n", spider_stmt_da_message(thd)); thd->clear_error(); break; } @@ -10057,17 +10064,20 @@ void *spider_table_bg_sts_action( pthread_cond_wait(&thread->cond, &thread->mutex); thread->thd_wait = FALSE; } - while (spider_init_queries[i].length && !thd->killed) + if (likely(!thread->error)) { - dispatch_command(COM_QUERY, thd, spider_init_queries[i].str, - (uint) spider_init_queries[i].length, FALSE, FALSE); - if (unlikely(thd->is_error())) + while (spider_init_queries[i].length && !thd->killed) { - fprintf(stderr, "[ERROR] %s\n", thd->get_stmt_da()->message()); - thd->clear_error(); - break; + dispatch_command(COM_QUERY, thd, spider_init_queries[i].str, + (uint) spider_init_queries[i].length, FALSE, FALSE); + if (unlikely(thd->is_error())) + { + fprintf(stderr, "[ERROR] %s\n", spider_stmt_da_message(thd)); + thd->clear_error(); + break; + } + ++i; } - ++i; } thd->mysys_var->current_cond = &thread->cond; thd->mysys_var->current_mutex = &thread->mutex; |