Bug #13228 open table cache not flushed when table schema changed
Submitted: 15 Sep 2005 17:46 Modified: 12 Apr 2006 1:15
Reporter: Tomas Ulin
Status: Closed
Category:Server: Cluster Severity:S3 (Non-critical)
Version:4.1.15,5.0.12 and earlier OS:
Assigned to: Magnus Blaudd Target Version:

[15 Sep 2005 17: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 16:10] Magnus Blaudd
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 16:10] Magnus Blaudd
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 16: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 10: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 11: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 18:09] Magnus Blaudd
Approved by Tomas
[7 Apr 2006 11: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 11:55] Magnus Blaudd
Pushed to 5.0.21 and 5.1.10 a fix that closes all unused open handlers for the table which
metadata had changed.
[12 Apr 2006 1: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.