Created
June 14, 2016 19:08
-
-
Save nirbhayc/892aa2e667012b072c67d81cc69364b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 0da548438fbf7dd399a2a73d4fcc7ddf7b9d8472 Mon Sep 17 00:00:00 2001 | |
From: Nirbhay Choubey <[email protected]> | |
Date: Mon, 13 Jun 2016 16:21:41 -0400 | |
Subject: [PATCH] MDEV-10216: Assertion | |
`strcmp(share->unique_file_name,filename) || | |
.. share->last_version' failed in myisam/mi_open.c:67: test_if_reopen | |
During the RENAME operation since the renamed temporary table | |
is also opened and added to myisam_open_list/ maria_open_list, | |
resetting the last_version at the end of operation will cause | |
an assertion failure when a subsequent query tries to reuse a | |
table instance from the list. | |
--- | |
mysql-test/r/reopen_temp_table.result | 18 ++++++++++++++++++ | |
mysql-test/t/reopen_temp_table.test | 16 ++++++++++++++++ | |
storage/maria/ma_extra.c | 7 ++++++- | |
storage/myisam/mi_extra.c | 7 ++++++- | |
4 files changed, 46 insertions(+), 2 deletions(-) | |
diff --git a/mysql-test/r/reopen_temp_table.result b/mysql-test/r/reopen_temp_table.result | |
index 08affaa..e63a21e 100644 | |
--- a/mysql-test/r/reopen_temp_table.result | |
+++ b/mysql-test/r/reopen_temp_table.result | |
@@ -164,5 +164,23 @@ SELECT COUNT(*)=4 FROM t6; | |
COUNT(*)=4 | |
1 | |
DROP TABLE t5, t6; | |
+# | |
+# MDEV-10216: Assertion `strcmp(share->unique_file_name,filename) || | |
+# share->last_version' failed in myisam/mi_open.c:67: test_if_reopen | |
+# | |
+CREATE TEMPORARY TABLE t7 (i INT) ENGINE=MYISAM; | |
+INSERT INTO t7 VALUES(1); | |
+ALTER TABLE t7 RENAME TO t; | |
+SELECT * FROM t a, t b; | |
+i i | |
+1 1 | |
+DROP TABLE t; | |
+CREATE TEMPORARY TABLE t7 (i INT) ENGINE=ARIA; | |
+INSERT INTO t7 VALUES(1); | |
+ALTER TABLE t7 RENAME TO t; | |
+SELECT * FROM t a, t b; | |
+i i | |
+1 1 | |
+DROP TABLE t; | |
# Cleanup | |
DROP DATABASE temp_db; | |
diff --git a/mysql-test/t/reopen_temp_table.test b/mysql-test/t/reopen_temp_table.test | |
index 98de983..83a5bbc 100644 | |
--- a/mysql-test/t/reopen_temp_table.test | |
+++ b/mysql-test/t/reopen_temp_table.test | |
@@ -159,5 +159,21 @@ SELECT COUNT(*)=6 FROM t5; | |
SELECT COUNT(*)=4 FROM t6; | |
DROP TABLE t5, t6; | |
+--echo # | |
+--echo # MDEV-10216: Assertion `strcmp(share->unique_file_name,filename) || | |
+--echo # share->last_version' failed in myisam/mi_open.c:67: test_if_reopen | |
+--echo # | |
+CREATE TEMPORARY TABLE t7 (i INT) ENGINE=MYISAM; | |
+INSERT INTO t7 VALUES(1); | |
+ALTER TABLE t7 RENAME TO t; | |
+SELECT * FROM t a, t b; | |
+DROP TABLE t; | |
+ | |
+CREATE TEMPORARY TABLE t7 (i INT) ENGINE=ARIA; | |
+INSERT INTO t7 VALUES(1); | |
+ALTER TABLE t7 RENAME TO t; | |
+SELECT * FROM t a, t b; | |
+DROP TABLE t; | |
+ | |
--echo # Cleanup | |
DROP DATABASE temp_db; | |
diff --git a/storage/maria/ma_extra.c b/storage/maria/ma_extra.c | |
index fd21d28..5b33ad6 100644 | |
--- a/storage/maria/ma_extra.c | |
+++ b/storage/maria/ma_extra.c | |
@@ -399,7 +399,12 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, | |
share->bitmap.changed_not_flushed= 0; | |
} | |
/* last_version must be protected by intern_lock; See collect_tables() */ | |
- share->last_version= 0L; /* Impossible version */ | |
+ /* | |
+ Temporary table has already been added to maria_open_list, so | |
+ lets not reset the last_version. | |
+ */ | |
+ if (!share->temporary) | |
+ share->last_version= 0L; /* Impossible version */ | |
mysql_mutex_unlock(&share->intern_lock); | |
break; | |
} | |
diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c | |
index a47c198..bc5705a 100644 | |
--- a/storage/myisam/mi_extra.c | |
+++ b/storage/myisam/mi_extra.c | |
@@ -265,7 +265,12 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) | |
/* Fall trough */ | |
case HA_EXTRA_PREPARE_FOR_RENAME: | |
mysql_mutex_lock(&THR_LOCK_myisam); | |
- share->last_version= 0L; /* Impossible version */ | |
+ /* | |
+ Temporary table has already been added to myisam_open_list, so | |
+ lets not reset the last_version. | |
+ */ | |
+ if (!share->temporary) | |
+ share->last_version= 0L; /* Impossible version */ | |
mysql_mutex_lock(&share->intern_lock); | |
/* Flush pages that we don't need anymore */ | |
if (flush_key_blocks(share->key_cache, share->kfile, | |
-- | |
1.9.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment