Skip to content

Commit 4c21c36

Browse files
committed
Merge InnoDB MySQL 5.6.41 to 10.0
2 parents 91181b2 + 29ddc6e commit 4c21c36

File tree

5 files changed

+117
-73
lines changed

5 files changed

+117
-73
lines changed

storage/innobase/fts/fts0fts.cc

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2016, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -869,37 +869,28 @@ fts_drop_index(
869869

870870
err = fts_drop_index_tables(trx, index);
871871

872-
for(;;) {
873-
bool retry = false;
874-
if (index->index_fts_syncing) {
875-
retry = true;
876-
}
877-
if (!retry){
878-
fts_free(table);
879-
break;
880-
}
872+
while (index->index_fts_syncing
873+
&& !trx_is_interrupted(trx)) {
881874
DICT_BG_YIELD(trx);
882875
}
876+
877+
fts_free(table);
878+
883879
return(err);
884880
}
885881

886-
for(;;) {
887-
bool retry = false;
888-
if (index->index_fts_syncing) {
889-
retry = true;
890-
}
891-
if (!retry){
892-
current_doc_id = table->fts->cache->next_doc_id;
893-
first_doc_id = table->fts->cache->first_doc_id;
894-
fts_cache_clear(table->fts->cache);
895-
fts_cache_destroy(table->fts->cache);
896-
table->fts->cache = fts_cache_create(table);
897-
table->fts->cache->next_doc_id = current_doc_id;
898-
table->fts->cache->first_doc_id = first_doc_id;
899-
break;
900-
}
882+
while (index->index_fts_syncing
883+
&& !trx_is_interrupted(trx)) {
901884
DICT_BG_YIELD(trx);
902885
}
886+
887+
current_doc_id = table->fts->cache->next_doc_id;
888+
first_doc_id = table->fts->cache->first_doc_id;
889+
fts_cache_clear(table->fts->cache);
890+
fts_cache_destroy(table->fts->cache);
891+
table->fts->cache = fts_cache_create(table);
892+
table->fts->cache->next_doc_id = current_doc_id;
893+
table->fts->cache->first_doc_id = first_doc_id;
903894
} else {
904895
fts_cache_t* cache = table->fts->cache;
905896
fts_index_cache_t* index_cache;
@@ -909,18 +900,14 @@ fts_drop_index(
909900
index_cache = fts_find_index_cache(cache, index);
910901

911902
if (index_cache != NULL) {
912-
for(;;) {
913-
bool retry = false;
914-
if (index->index_fts_syncing) {
915-
retry = true;
916-
}
917-
if (!retry && index_cache->words) {
918-
fts_words_free(index_cache->words);
919-
rbt_free(index_cache->words);
920-
break;
921-
}
903+
while (index->index_fts_syncing
904+
&& !trx_is_interrupted(trx)) {
922905
DICT_BG_YIELD(trx);
923906
}
907+
if (index_cache->words) {
908+
fts_words_free(index_cache->words);
909+
rbt_free(index_cache->words);
910+
}
924911

925912
ib_vector_remove(cache->indexes, *(void**) index_cache);
926913
}

storage/innobase/handler/ha_innodb.cc

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10877,6 +10877,7 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result))
1087710877
dberr_t
1087810878
innobase_rename_table(
1087910879
/*==================*/
10880+
THD* thd, /*!< Connection thread handle */
1088010881
trx_t* trx, /*!< in: transaction */
1088110882
const char* from, /*!< in: old name of the table */
1088210883
const char* to) /*!< in: new name of the table */
@@ -10902,6 +10903,36 @@ innobase_rename_table(
1090210903

1090310904
row_mysql_lock_data_dictionary(trx);
1090410905

10906+
dict_table_t* table = dict_table_open_on_name(norm_from, TRUE, FALSE,
10907+
DICT_ERR_IGNORE_NONE);
10908+
10909+
/* Since DICT_BG_YIELD has sleep for 250 milliseconds,
10910+
Convert lock_wait_timeout unit from second to 250 milliseconds */
10911+
long int lock_wait_timeout = thd_lock_wait_timeout(thd) * 4;
10912+
if (table != NULL) {
10913+
for (dict_index_t* index = dict_table_get_first_index(table);
10914+
index != NULL;
10915+
index = dict_table_get_next_index(index)) {
10916+
10917+
if (index->type & DICT_FTS) {
10918+
/* Found */
10919+
while (index->index_fts_syncing
10920+
&& !trx_is_interrupted(trx)
10921+
&& (lock_wait_timeout--) > 0) {
10922+
DICT_BG_YIELD(trx);
10923+
}
10924+
}
10925+
}
10926+
dict_table_close(table, TRUE, FALSE);
10927+
}
10928+
10929+
/* FTS sync is in progress. We shall timeout this operation */
10930+
if (lock_wait_timeout < 0) {
10931+
error = DB_LOCK_WAIT_TIMEOUT;
10932+
row_mysql_unlock_data_dictionary(trx);
10933+
DBUG_RETURN(error);
10934+
}
10935+
1090510936
/* Transaction must be flagged as a locking transaction or it hasn't
1090610937
been started yet. */
1090710938

@@ -11011,7 +11042,7 @@ ha_innobase::rename_table(
1101111042
++trx->will_lock;
1101211043
trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
1101311044

11014-
error = innobase_rename_table(trx, from, to);
11045+
error = innobase_rename_table(thd, trx, from, to);
1101511046

1101611047
DEBUG_SYNC(thd, "after_innobase_rename_table");
1101711048

@@ -11055,6 +11086,10 @@ ha_innobase::rename_table(
1105511086
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to);
1105611087

1105711088
error = DB_ERROR;
11089+
} else if (error == DB_LOCK_WAIT_TIMEOUT) {
11090+
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0), to);
11091+
11092+
error = DB_LOCK_WAIT;
1105811093
}
1105911094

1106011095
DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));

storage/innobase/include/univ.i

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Created 1/20/1994 Heikki Tuuri
4545

4646
#define INNODB_VERSION_MAJOR5
4747
#define INNODB_VERSION_MINOR6
48-
#define INNODB_VERSION_BUGFIX40
48+
#define INNODB_VERSION_BUGFIX41
4949

5050
/* The following is the InnoDB version as shown in
5151
SELECT plugin_version FROM information_schema.plugins;

storage/xtradb/fts/fts0fts.cc

Lines changed: 22 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved.
44
Copyright (c) 2016, 2018, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
@@ -869,37 +869,28 @@ fts_drop_index(
869869

870870
err = fts_drop_index_tables(trx, index);
871871

872-
for(;;) {
873-
bool retry = false;
874-
if (index->index_fts_syncing) {
875-
retry = true;
876-
}
877-
if (!retry){
878-
fts_free(table);
879-
break;
880-
}
872+
while (index->index_fts_syncing
873+
&& !trx_is_interrupted(trx)) {
881874
DICT_BG_YIELD(trx);
882875
}
876+
877+
fts_free(table);
878+
883879
return(err);
884880
}
885881

886-
for(;;) {
887-
bool retry = false;
888-
if (index->index_fts_syncing) {
889-
retry = true;
890-
}
891-
if (!retry){
892-
current_doc_id = table->fts->cache->next_doc_id;
893-
first_doc_id = table->fts->cache->first_doc_id;
894-
fts_cache_clear(table->fts->cache);
895-
fts_cache_destroy(table->fts->cache);
896-
table->fts->cache = fts_cache_create(table);
897-
table->fts->cache->next_doc_id = current_doc_id;
898-
table->fts->cache->first_doc_id = first_doc_id;
899-
break;
900-
}
882+
while (index->index_fts_syncing
883+
&& !trx_is_interrupted(trx)) {
901884
DICT_BG_YIELD(trx);
902885
}
886+
887+
current_doc_id = table->fts->cache->next_doc_id;
888+
first_doc_id = table->fts->cache->first_doc_id;
889+
fts_cache_clear(table->fts->cache);
890+
fts_cache_destroy(table->fts->cache);
891+
table->fts->cache = fts_cache_create(table);
892+
table->fts->cache->next_doc_id = current_doc_id;
893+
table->fts->cache->first_doc_id = first_doc_id;
903894
} else {
904895
fts_cache_t* cache = table->fts->cache;
905896
fts_index_cache_t* index_cache;
@@ -909,18 +900,14 @@ fts_drop_index(
909900
index_cache = fts_find_index_cache(cache, index);
910901

911902
if (index_cache != NULL) {
912-
for(;;) {
913-
bool retry = false;
914-
if (index->index_fts_syncing) {
915-
retry = true;
916-
}
917-
if (!retry && index_cache->words) {
918-
fts_words_free(index_cache->words);
919-
rbt_free(index_cache->words);
920-
break;
921-
}
903+
while (index->index_fts_syncing
904+
&& !trx_is_interrupted(trx)) {
922905
DICT_BG_YIELD(trx);
923906
}
907+
if (index_cache->words) {
908+
fts_words_free(index_cache->words);
909+
rbt_free(index_cache->words);
910+
}
924911

925912
ib_vector_remove(cache->indexes, *(void**) index_cache);
926913
}

storage/xtradb/handler/ha_innodb.cc

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11695,6 +11695,7 @@ static MY_ATTRIBUTE((nonnull, warn_unused_result))
1169511695
dberr_t
1169611696
innobase_rename_table(
1169711697
/*==================*/
11698+
THD* thd, /*!< Connection thread handle */
1169811699
trx_t* trx, /*!< in: transaction */
1169911700
const char* from, /*!< in: old name of the table */
1170011701
const char* to) /*!< in: new name of the table */
@@ -11720,6 +11721,36 @@ innobase_rename_table(
1172011721

1172111722
row_mysql_lock_data_dictionary(trx);
1172211723

11724+
dict_table_t* table = dict_table_open_on_name(norm_from, TRUE, FALSE,
11725+
DICT_ERR_IGNORE_NONE);
11726+
11727+
/* Since DICT_BG_YIELD has sleep for 250 milliseconds,
11728+
Convert lock_wait_timeout unit from second to 250 milliseconds */
11729+
long int lock_wait_timeout = thd_lock_wait_timeout(thd) * 4;
11730+
if (table != NULL) {
11731+
for (dict_index_t* index = dict_table_get_first_index(table);
11732+
index != NULL;
11733+
index = dict_table_get_next_index(index)) {
11734+
11735+
if (index->type & DICT_FTS) {
11736+
/* Found */
11737+
while (index->index_fts_syncing
11738+
&& !trx_is_interrupted(trx)
11739+
&& (lock_wait_timeout--) > 0) {
11740+
DICT_BG_YIELD(trx);
11741+
}
11742+
}
11743+
}
11744+
dict_table_close(table, TRUE, FALSE);
11745+
}
11746+
11747+
/* FTS sync is in progress. We shall timeout this operation */
11748+
if (lock_wait_timeout < 0) {
11749+
error = DB_LOCK_WAIT_TIMEOUT;
11750+
row_mysql_unlock_data_dictionary(trx);
11751+
DBUG_RETURN(error);
11752+
}
11753+
1172311754
/* Transaction must be flagged as a locking transaction or it hasn't
1172411755
been started yet. */
1172511756

@@ -11834,7 +11865,7 @@ ha_innobase::rename_table(
1183411865
++trx->will_lock;
1183511866
trx_set_dict_operation(trx, TRX_DICT_OP_INDEX);
1183611867

11837-
error = innobase_rename_table(trx, from, to);
11868+
error = innobase_rename_table(thd, trx, from, to);
1183811869

1183911870
DEBUG_SYNC(thd, "after_innobase_rename_table");
1184011871

@@ -11878,6 +11909,10 @@ ha_innobase::rename_table(
1187811909
my_error(ER_TABLE_EXISTS_ERROR, MYF(0), to);
1187911910

1188011911
error = DB_ERROR;
11912+
} else if (error == DB_LOCK_WAIT_TIMEOUT) {
11913+
my_error(ER_LOCK_WAIT_TIMEOUT, MYF(0), to);
11914+
11915+
error = DB_LOCK_WAIT;
1188111916
}
1188211917

1188311918
DBUG_RETURN(convert_error_code_to_mysql(error, 0, NULL));

0 commit comments

Comments
 (0)