Description:
When using "WITH CONSISTENT SNAPSHOT".. if a table is for example renamed.. you can no longer read the table. And the table rename is not blocked. You read the new table (and get no new rows presumably because the innodb versions are newer)
How to repeat:
Test Case:
[in customer case was done with Master/Slave but has nothing to do with Master/Slave.. need second session so the DDL happens outside the transaction scope.]
== SESSION 1 ==
CREATE DATABASE IF NOT EXISTS `test`;
USE `test`;
DROP TABLE IF EXISTS `t1_30138`;
DROP TABLE IF EXISTS `t1_30138_old`;
DROP TABLE IF EXISTS `t1_30138_new`;
CREATE TABLE `t1_30138` (id INT) ENGINE=InnoDB;
INSERT INTO `t1_30138` VALUES (1),(2),(3);
SET AUTOCOMMIT=0;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
SELECT COUNT(*) FROM `t1_30138`;
== SESSION 2 ==
USE `test`;
CREATE TABLE `t1_30138_new` (id INT) ENGINE=InnoDB;
INSERT INTO `t1_30138_new` VALUES (4),(5),(6),(7);
INSERT INTO `t1_30138` VALUES(8);
RENAME TABLE `t1_30138` TO `t1_30138_old`, `t1_30138_new` TO `t1_30138`;
== SESSION 1 ==
SELECT COUNT(*) FROM `t1_30138`;
SELECT COUNT(*) FROM `t1_30138_old`;
== CLEANUP ==
COMMIT;
DROP TABLE IF EXISTS `t1_30138`;
DROP TABLE IF EXISTS `t1_30138_old`;
DROP TABLE IF EXISTS `t1_30138_new`;
Suggested fix:
This seems like quite a complex issue to fix I suspect.
Only "easy-out" I see would be to prevent DDL during CONSISTENT SNAPSHOT.