diff --git a/mysql-test/r/ndb_lock.result b/mysql-test/r/ndb_lock.result index b8c2c58aac4..180a90fff29 100644 --- a/mysql-test/r/ndb_lock.result +++ b/mysql-test/r/ndb_lock.result @@ -63,3 +63,15 @@ pk u o 5 5 5 insert into t1 values (1,1,1); drop table t1; +create table t3 (id2 int) engine=ndb; +lock tables t3 write; +unlock tables; +id2 +drop table t3; +create table t2 (id int, j int) engine=ndb; +insert into t2 values (2, 2); +create table t3 (id int) engine=ndb; +lock tables t3 read; +delete t2 from t2, t3 where t2.id = t3.id; +unlock tables; +drop table t2, t3; diff --git a/mysql-test/t/ndb_lock.test b/mysql-test/t/ndb_lock.test index 6945f91ee39..3d8597dcc45 100644 --- a/mysql-test/t/ndb_lock.test +++ b/mysql-test/t/ndb_lock.test @@ -70,3 +70,39 @@ insert into t1 values (1,1,1); drop table t1; # End of 4.1 tests + +# +# Bug #17812 Previous lock table for write causes "stray" lock +# although table is recreated +# +# this creating, locking, and dropping causes a subsequent hang +# on the delete below waiting for table t2 the locking in the +# "other" connection is relevant, as without it there is no problem +# +connection con1; +create table t3 (id2 int) engine=ndb; + +connection con2; +lock tables t3 write; +unlock tables; + +connection con1; +drop table t3; + +connection con1; +create table t2 (id int, j int) engine=ndb; +insert into t2 values (2, 2); +create table t3 (id int) engine=ndb; + +connection con2; +lock tables t3 read; + +connection con1; +# here we get a hang before bugfix although we shouldn't +delete t2 from t2, t3 where t2.id = t3.id; + +connection con2; +unlock tables; + +connection con1; +drop table t2, t3; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 6e01330a85e..d49eca4f103 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -502,10 +502,10 @@ ha_ndbcluster::invalidate_dictionary_cache(TABLE_SHARE *share, Ndb *ndb, } else dict->invalidateTable(tabname); + share->version=0L; /* Free when thread is ready */ } else dict->removeCachedTable(tabname); - share->version=0L; /* Free when thread is ready */ DBUG_RETURN(0); }