summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Malyavin <nikitamalyavin@gmail.com>2020-05-22 13:28:04 +1000
committerNikita Malyavin <nikitamalyavin@gmail.com>2020-09-30 22:32:35 +1000
commitcc06db8ec3e71eb98c83b014069588344a2156eb (patch)
tree6f5f85602e3c86cf31e81733d5784bacd59632b2
parent6f86387ac8cd3390925d96f5995dc30d9a53ca7e (diff)
downloadmariadb-git-cc06db8ec3e71eb98c83b014069588344a2156eb.tar.gz
fix rollback
-rw-r--r--mysql-test/suite/binlog/t/online_alter.test54
-rw-r--r--sql/log.cc2
-rw-r--r--sql/sql_table.cc10
3 files changed, 41 insertions, 25 deletions
diff --git a/mysql-test/suite/binlog/t/online_alter.test b/mysql-test/suite/binlog/t/online_alter.test
index d13c91e0ffa..2cd45a019b5 100644
--- a/mysql-test/suite/binlog/t/online_alter.test
+++ b/mysql-test/suite/binlog/t/online_alter.test
@@ -214,10 +214,20 @@ update t1 set b= 5005 where a = 5;
set autocommit = 0;
start transaction;
-update t1 set b= 6006 where a = 6; ## TODO bug
+update t1 set b= 6006 where a = 6;
rollback;
set autocommit = 1;
+--echo # Second execution in transaction fails
+
+set autocommit = 0;
+start transaction;
+update t1 set b= 7007 where a = 7;
+--error ER_DUP_ENTRY
+update t1 set a= 8 where a = 8 or a = 9;
+commit;
+set autocommit = 1;
+
set debug_sync= 'now SIGNAL end';
--connection default
@@ -225,24 +235,38 @@ set debug_sync= 'now SIGNAL end';
--sorted_result
select * from t1;
+
+--echo #
+--echo # test primary key change
+--echo #
+
create or replace table t1 (a int primary key, b int) engine=innodb;
insert t1 values (1, 11);
insert t1 values (2, 22);
-insert t1 values (3, 33);
-insert t1 values (4, 44);
-insert t1 values (5, 55);
-insert t1 values (6, 66);
-insert t1 values (7, 77);
-insert t1 values (8, 88);
-insert t1 values (9, 99);
-set autocommit = 0;
-start transaction;
-update t1 set b= 7007 where a = 7;
---error ER_DUPP_KEY
-update t1 set b= 8008 where a = 8 or a = 9;
-commit;
-set autocommit = 1;
+
+--connection con2
+--send
+set debug_sync= 'now WAIT_FOR ended';
+
+--connection default
+
+set debug_sync= 'alter_table_copy_end SIGNAL ended WAIT_FOR end';
+
+--send
+alter table t1 drop primary key, add primary key(b),
+ algorithm= copy, lock= none;
+
+--connection con2
+--reap
+
+
+set debug_sync= 'now SIGNAL end';
+
+--connection default
+--reap
select * from t1;
+
--echo # Cleanup
+set debug_sync= 'reset';
drop table t1, t2;
diff --git a/sql/log.cc b/sql/log.cc
index a00cc1430b1..7e14d61ae53 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2251,6 +2251,8 @@ static int binlog_rollback(handlerton *hton, THD *thd, bool all)
for (TABLE *table= thd->open_tables; table; table= table->next)
{
+ if (!table->online_alter_cache)
+ continue;
table->online_alter_cache->reset();
delete table->online_alter_cache;
table->online_alter_cache= NULL;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 02aec8c8544..a294a2eb77c 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -11365,11 +11365,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
uint online_alter_sync_period= 0;
if (online)
{
- // MDL_ticket *mdl_ticket= from->mdl_ticket;
- // if (thd->mdl_context.upgrade_shared_lock(mdl_ticket, MDL_EXCLUSIVE,
- // thd->variables.lock_wait_timeout))
- // DBUG_RETURN(1);
-
from->s->online_ater_binlog= new (alloc_root(thd->mem_root,
sizeof (MYSQL_BIN_LOG)))
MYSQL_BIN_LOG(&online_alter_sync_period);
@@ -11398,11 +11393,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
DBUG_RETURN(1);
from->mdl_ticket->downgrade_lock(MDL_SHARED_UPGRADABLE);
-
- // if (thd->mdl_context.upgrade_shared_lock(mdl_ticket, MDL_SHARED_READ,
- // thd->variables.lock_wait_timeout,
- // true))
- // DBUG_RETURN(1);
}
if (!(copy= new (thd->mem_root) Copy_field[to->s->fields]))