Skip to content

Commit 1c65ab2

Browse files
committed
Merge 10.4 into 10.5
2 parents a9550c4 + bd64c2e commit 1c65ab2

File tree

16 files changed

+51
-92
lines changed

16 files changed

+51
-92
lines changed

mysql-test/suite/innodb/r/foreign_key.result

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,20 @@ Opened_table_definitions 5
402402
Opened_tables 5
403403
drop function foo;
404404
drop table t2, t1;
405+
CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk)) ENGINE=InnoDB;
406+
XA START 'xid';
407+
INSERT INTO t1 VALUES (1,2);
408+
CREATE TABLE x AS SELECT * FROM t1;
409+
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the ACTIVE state
410+
connect con1,localhost,root,,test;
411+
SET foreign_key_checks= OFF, innodb_lock_wait_timeout= 1;
412+
ALTER TABLE t1 ADD FOREIGN KEY f (a) REFERENCES t1 (pk), LOCK=EXCLUSIVE;
413+
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
414+
disconnect con1;
415+
connection default;
416+
XA END 'xid';
417+
XA ROLLBACK 'xid';
418+
DROP TABLE t1;
405419
# Start of 10.2 tests
406420
#
407421
# MDEV-13246 Stale rows despite ON DELETE CASCADE constraint

mysql-test/suite/innodb/t/foreign_key.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,20 @@ show status like '%opened_tab%';
407407
drop function foo;
408408
drop table t2, t1;
409409

410+
CREATE TABLE t1 (pk INT, a INT, PRIMARY KEY (pk)) ENGINE=InnoDB;
411+
XA START 'xid';
412+
INSERT INTO t1 VALUES (1,2);
413+
--error ER_XAER_RMFAIL
414+
CREATE TABLE x AS SELECT * FROM t1;
415+
--connect (con1,localhost,root,,test)
416+
SET foreign_key_checks= OFF, innodb_lock_wait_timeout= 1;
417+
--error ER_LOCK_WAIT_TIMEOUT
418+
ALTER TABLE t1 ADD FOREIGN KEY f (a) REFERENCES t1 (pk), LOCK=EXCLUSIVE;# Cleanup
419+
--disconnect con1
420+
--connection default
421+
XA END 'xid';
422+
XA ROLLBACK 'xid';
423+
DROP TABLE t1;
410424
#
411425
# End of 10.1 tests
412426
#

storage/innobase/btr/btr0defragment.cc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ synchronized defragmentation. */
198198
os_event_t
199199
btr_defragment_add_index(
200200
dict_index_t* index, /*!< index to be added */
201-
bool async, /*!< whether this is an async
202-
defragmentation */
203201
dberr_t* err) /*!< out: error code */
204202
{
205203
mtr_t mtr;
@@ -228,10 +226,7 @@ btr_defragment_add_index(
228226
return NULL;
229227
}
230228
btr_pcur_t* pcur = btr_pcur_create_for_mysql();
231-
os_event_t event = NULL;
232-
if (!async) {
233-
event = os_event_create(0);
234-
}
229+
os_event_t event = os_event_create(0);
235230
btr_pcur_open_at_index_side(true, index, BTR_SEARCH_LEAF, pcur,
236231
true, 0, &mtr);
237232
btr_pcur_move_to_next(pcur, &mtr);

storage/innobase/fts/fts0fts.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ fts_cache_destroy(fts_cache_t* cache)
286286
{
287287
rw_lock_free(&cache->lock);
288288
rw_lock_free(&cache->init_lock);
289-
mutex_free(&cache->optimize_lock);
290289
mutex_free(&cache->deleted_lock);
291290
mutex_free(&cache->doc_id_lock);
292291
os_event_destroy(cache->sync->event);
@@ -622,8 +621,6 @@ fts_cache_create(
622621

623622
mutex_create(LATCH_ID_FTS_DELETE, &cache->deleted_lock);
624623

625-
mutex_create(LATCH_ID_FTS_OPTIMIZE, &cache->optimize_lock);
626-
627624
mutex_create(LATCH_ID_FTS_DOC_ID, &cache->doc_id_lock);
628625

629626
/* This is the heap used to create the cache itself. */

storage/innobase/fts/fts0opt.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,9 +2622,13 @@ fts_optimize_remove_table(
26222622

26232623
os_event_destroy(event);
26242624

2625-
ut_d(mutex_enter(&fts_optimize_wq->mutex));
2626-
ut_ad(!table->fts->in_queue);
2627-
ut_d(mutex_exit(&fts_optimize_wq->mutex));
2625+
#ifdef UNIV_DEBUG
2626+
if (!fts_opt_start_shutdown) {
2627+
mutex_enter(&fts_optimize_wq->mutex);
2628+
ut_ad(!table->fts->in_queue);
2629+
mutex_exit(&fts_optimize_wq->mutex);
2630+
}
2631+
#endif /* UNIV_DEBUG */
26282632
}
26292633

26302634
/** Send sync fts cache for the table.

storage/innobase/handler/ha_innodb.cc

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -509,15 +509,13 @@ performance schema instrumented if "UNIV_PFS_MUTEX"
509509
is defined */
510510
static PSI_mutex_info all_innodb_mutexes[] = {
511511
PSI_KEY(buf_pool_mutex),
512-
PSI_KEY(cache_last_read_mutex),
513512
PSI_KEY(dict_foreign_err_mutex),
514513
PSI_KEY(dict_sys_mutex),
515514
PSI_KEY(recalc_pool_mutex),
516515
PSI_KEY(fil_system_mutex),
517516
PSI_KEY(flush_list_mutex),
518517
PSI_KEY(fts_bg_threads_mutex),
519518
PSI_KEY(fts_delete_mutex),
520-
PSI_KEY(fts_optimize_mutex),
521519
PSI_KEY(fts_doc_id_mutex),
522520
PSI_KEY(log_flush_order_mutex),
523521
PSI_KEY(ibuf_bitmap_mutex),
@@ -14520,25 +14518,14 @@ ha_innobase::analyze(THD*, HA_CHECK_OPT*)
1452014518
/*****************************************************************//**
1452114519
Defragment table.
1452214520
@return error number */
14523-
UNIV_INTERN
14524-
int
14525-
ha_innobase::defragment_table(
14526-
/*==========================*/
14527-
const char* name, /*!< in: table name */
14528-
const char* index_name, /*!< in: index name */
14529-
bool async) /*!< in: whether to wait until finish */
14521+
inline int ha_innobase::defragment_table(const char *name)
1453014522
{
1453114523
char norm_name[FN_REFLEN];
1453214524
dict_table_t* table = NULL;
1453314525
dict_index_t* index = NULL;
14534-
ibool one_index = (index_name != 0);
1453514526
int ret = 0;
1453614527
dberr_t err = DB_SUCCESS;
1453714528

14538-
if (!srv_defragment) {
14539-
return ER_FEATURE_DISABLED;
14540-
}
14541-
1454214529
normalize_table_name(norm_name, name);
1454314530

1454414531
table = dict_table_open_on_name(norm_name, FALSE,
@@ -14566,10 +14553,6 @@ ha_innobase::defragment_table(
1456614553
continue;
1456714554
}
1456814555

14569-
if (one_index && strcasecmp(index_name, index->name) != 0) {
14570-
continue;
14571-
}
14572-
1457314556
if (btr_defragment_find_index(index)) {
1457414557
// We borrow this error code. When the same index is
1457514558
// already in the defragmentation queue, issue another
@@ -14585,7 +14568,7 @@ ha_innobase::defragment_table(
1458514568
break;
1458614569
}
1458714570

14588-
os_event_t event = btr_defragment_add_index(index, async, &err);
14571+
os_event_t event = btr_defragment_add_index(index, &err);
1458914572

1459014573
if (err != DB_SUCCESS) {
1459114574
push_warning_printf(
@@ -14601,7 +14584,7 @@ ha_innobase::defragment_table(
1460114584
break;
1460214585
}
1460314586

14604-
if (!async && event) {
14587+
if (event) {
1460514588
while(os_event_wait_time(event, 1000000)) {
1460614589
if (thd_killed(current_thd)) {
1460714590
btr_defragment_remove_index(index);
@@ -14615,19 +14598,9 @@ ha_innobase::defragment_table(
1461514598
if (ret) {
1461614599
break;
1461714600
}
14618-
14619-
if (one_index) {
14620-
one_index = FALSE;
14621-
break;
14622-
}
1462314601
}
1462414602

1462514603
dict_table_close(table, FALSE, FALSE);
14626-
14627-
if (ret == 0 && one_index) {
14628-
ret = ER_NO_SUCH_INDEX;
14629-
}
14630-
1463114604
return ret;
1463214605
}
1463314606

@@ -14653,8 +14626,7 @@ ha_innobase::optimize(
1465314626
bool try_alter = true;
1465414627

1465514628
if (!m_prebuilt->table->is_temporary() && srv_defragment) {
14656-
int err= defragment_table(
14657-
m_prebuilt->table->name.m_name, NULL, false);
14629+
int err = defragment_table(m_prebuilt->table->name.m_name);
1465814630

1465914631
if (err == 0) {
1466014632
try_alter = false;

storage/innobase/handler/ha_innodb.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ class ha_innobase final : public handler
212212
int delete_table(const char *name) override;
213213

214214
int rename_table(const char* from, const char* to) override;
215-
int defragment_table(const char* name, const char* index_name,
216-
bool async);
215+
inline int defragment_table(const char* name);
217216
int check(THD* thd, HA_CHECK_OPT* check_opt) override;
218217
char* update_table_comment(const char* comment) override;
219218

storage/innobase/handler/handler0alter.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7167,6 +7167,12 @@ prepare_inplace_alter_table_dict(
71677167
}
71687168
trx_commit_for_mysql(ctx->prebuilt->trx);
71697169

7170+
for (uint i = 0; i < ctx->num_to_add_fk; i++) {
7171+
if (ctx->add_fk[i]) {
7172+
dict_foreign_free(ctx->add_fk[i]);
7173+
}
7174+
}
7175+
71707176
delete ctx;
71717177
ha_alter_info->handler_ctx = NULL;
71727178

storage/innobase/include/btr0defragment.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ is a synchronized defragmentation. */
4949
os_event_t
5050
btr_defragment_add_index(
5151
dict_index_t* index, /*!< index to be added */
52-
bool async, /*!< whether this is an async
53-
defragmentation */
5452
dberr_t* err); /*!< out: error code */
5553
/******************************************************************//**
5654
When table is dropped, this function is called to mark a table as removed in

storage/innobase/include/fts0types.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ struct fts_cache_t {
131131
intialization, it has different
132132
SYNC level as above cache lock */
133133

134-
ib_mutex_t optimize_lock; /*!< Lock for OPTIMIZE */
135-
136134
ib_mutex_t deleted_lock; /*!< Lock covering deleted_doc_ids */
137135

138136
ib_mutex_t doc_id_lock; /*!< Lock covering Doc ID */

0 commit comments

Comments
 (0)