Commit c2e0a0b1 authored by Monty's avatar Monty

Server crashes with BACKUP STAGE and FLUSH TABLE table_name

Fixes MDEV-18067, MDEV-18068 and MDEV-18069

The problem was that FLUSH TABLES table_name combined with UNLOCK TABLES
calls MDL_context::set_transaction_duration_for_all_locks(), which
changed backup_locks from MDL_EXPLICT to MDL_TRANSACTION.

Fixed by ensuring that set_transaction_duration_for_all_locks() doesn't
touch BACKUP locks.
parent 5b6b1663
......@@ -518,3 +518,29 @@ TRUNCATE t_temporary_innodb;
ALTER TABLE t_temporary_innodb ADD COLUMN col2 INT;
ALTER TABLE t_temporary_innodb ADD KEY idx(col2);
BACKUP STAGE END;
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, f INT);
BACKUP STAGE START;
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
BACKUP STAGE END;
DROP TABLE t1;
CREATE TABLE t1 (a INT);
BACKUP STAGE START;
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
connect con1,localhost,root,,test;
BACKUP STAGE START;
connection default;
BACKUP STAGE END;
connection con1;
BACKUP STAGE END;
disconnect con1;
connection default;
DROP TABLE t1;
CREATE TABLE t1 (a INT);
BACKUP STAGE START;
FLUSH TABLES t1 WITH READ LOCK;
UNLOCK TABLES;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
DROP TABLE t1;
......@@ -501,3 +501,38 @@ TRUNCATE t_temporary_innodb;
ALTER TABLE t_temporary_innodb ADD COLUMN col2 INT;
ALTER TABLE t_temporary_innodb ADD KEY idx(col2);
BACKUP STAGE END;
#
# MDEV-18067, MDEV-18068 and MDEV-18069
# Server crashes with BACKUP STAGE and FLUSH TABLE table_name
#
CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, f INT);
BACKUP STAGE START;
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
BACKUP STAGE END;
DROP TABLE t1;
CREATE TABLE t1 (a INT);
BACKUP STAGE START;
FLUSH TABLE t1 FOR EXPORT;
UNLOCK TABLES;
--connect (con1,localhost,root,,test)
--send BACKUP STAGE START
--connection default
BACKUP STAGE END;
--connection con1
reap;
BACKUP STAGE END;
--disconnect con1
--connection default
DROP TABLE t1;
CREATE TABLE t1 (a INT);
BACKUP STAGE START;
FLUSH TABLES t1 WITH READ LOCK;
UNLOCK TABLES;
BACKUP STAGE BLOCK_COMMIT;
BACKUP STAGE END;
DROP TABLE t1;
......@@ -3166,14 +3166,19 @@ void MDL_context::set_transaction_duration_for_all_locks()
DBUG_ASSERT(m_tickets[MDL_STATEMENT].is_empty());
m_tickets[MDL_TRANSACTION].swap(m_tickets[MDL_EXPLICIT]);
/* Don't swap locks if this thread is running backup stages */
if (current_thd->current_backup_stage == BACKUP_FINISHED)
m_tickets[MDL_TRANSACTION].swap(m_tickets[MDL_EXPLICIT]);
Ticket_iterator it_ticket(m_tickets[MDL_EXPLICIT]);
while ((ticket= it_ticket++))
{
m_tickets[MDL_EXPLICIT].remove(ticket);
m_tickets[MDL_TRANSACTION].push_front(ticket);
if (ticket->get_key()->mdl_namespace() != MDL_key::BACKUP)
{
m_tickets[MDL_EXPLICIT].remove(ticket);
m_tickets[MDL_TRANSACTION].push_front(ticket);
}
}
#ifndef DBUG_OFF
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment