Bug #13228 open table cache not flushed when table schema changed
Submitted: 15 Sep 2005 15:46 Modified: 11 Apr 2006 23:15
Reporter: Tomas Ulin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:4.1.15,5.0.12 and earlier OS:
Assigned to: Magnus Blåudd CPU Architecture:Any

[15 Sep 2005 15:46] Tomas Ulin
Description:
see testcase

How to repeat:
make sure to set DeadlockTimeout to 20 secs or more...

the selects in the end will only show 2 columns... a and b,  hence server has not received the new frm with column c

-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/not_embedded.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

connect (con1,localhost,root,,test);
connect (con2,localhost,root,,test);
connect (con3,localhost,root,,test);
connect (con4,localhost,root,,test);
connect (con5,localhost,root,,test);
connect (con6,localhost,root,,test);

CREATE TABLE t1 (
  a INT NOT NULL PRIMARY KEY,
  b INT NOT NULL
) ENGINE=ndbcluster;

connection con1;
BEGIN;
INSERT INTO t1 VALUES (9410,9412);
connection con2;
BEGIN;
--send
INSERT INTO t1 VALUES (9410,9412);
sleep 1;
connection con3;
BEGIN;
--send
INSERT INTO t1 VALUES (9410,9412);
sleep 1;
connection con4;
BEGIN;
--send
INSERT INTO t1 VALUES (9410,9412);
sleep 1;
connection con5;
BEGIN;
--send
INSERT INTO t1 VALUES (9410,9412);
sleep 1;
connection con6;
BEGIN;
--send
INSERT INTO t1 VALUES (9410,9412);
sleep 1;
connection con1;
ROLLBACK;
connection con2;
reap;
ROLLBACK;
connection con3;
reap;
ROLLBACK;
connection con4;
reap;
ROLLBACK;
connection con5;
reap;
ROLLBACK;
connection con6;
reap;
ROLLBACK;

connection server2;

drop table t1;
CREATE TABLE t1 (
  a INT NOT NULL PRIMARY KEY,
  b INT NOT NULL,
  c INT NOT NULL
) ENGINE=ndbcluster;

connection server1;

--error 1296
select * from t1;
select * from t1;
select * from t1;
select * from t1;
select * from t1;
select * from t1;
[19 Sep 2005 14:10] Magnus Blåudd
The table is not properly removed from the table cache. Thus mysql server will not see the new column.

To flag that the table should be closed, removed from cache etc. is signalled by the following line in ha_ndbcluster.cc
>>
  table->s->version=0L;			/* Free when thread is ready */

It seems lilke this does no longer make the "trick", could be because other threads are also using the table?
[19 Sep 2005 14:10] Magnus Blåudd
Smaller test case

-- source include/have_ndb.inc
-- source include/have_multi_ndb.inc
-- source include/not_embedded.inc

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

connect (con1,localhost,root,,test);

CREATE TABLE t1 (
  a INT
) ENGINE=ndbcluster;
select * from t1;
connection con1;
select * from t1;
connection server2;

drop table t1;
CREATE TABLE t1 (
  a INT NOT NULL,
  b INT NOT NULL
) ENGINE=ndbcluster;

connection server1;

--error 1296
select * from t1;
select * from t1;
[4 Jan 2006 15:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/33331
[10 Jan 2006 9:56] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/841
[10 Jan 2006 10:36] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/845
[17 Mar 2006 17:09] Magnus Blåudd
Approved by Tomas
[7 Apr 2006 9:19] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/4607
[11 Apr 2006 9:55] Magnus Blåudd
Pushed to 5.0.21 and 5.1.10 a fix that closes all unused open handlers for the table which metadata had changed.
[11 Apr 2006 23:15] Jon Stephens
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Documented bugfix in 5.0.21 and 5.1.10 changelogs. Closed.