Bug #42187 Falcon reports all from StorageHandler::createTable as 'table exists' errors
Submitted: 18 Jan 2009 18:27 Modified: 26 May 2010 17:51
Reporter: Mark Callaghan Email Updates:
Status: Unsupported Impact on me:
None 
Category:MySQL Server: Falcon storage engine Severity:S3 (Non-critical)
Version:6.0.8 OS:Any
Assigned to: Lars-Erik Bjørk CPU Architecture:Any
Tags: error handling, exists, F_DDL, table

[18 Jan 2009 18:27] Mark Callaghan
Description:
Falcon reports TABLE EXISTS errors on all attempts to create a table, even for table names that have never been used. The problems are:

1) the error message is hard to figure out. If you grep the source code, 156 --> HA_ERR_TABLE_EXIST.

  mysql> CREATE TABLE k(i int) engine=falcon; ERROR 1005 (HY000): Can't create   table 'test.k' (errno: 156)

2) the error is incorrect as the table doesn't exist. I think the problem is that StorageHandler::createTable can fail for reasons other than the table exists, but in StorageInterface::create a return of NULL from StorageHandler::createTable results in a return value of HA_ERR_TABLE_EXIST.

3) Falcon reported no errors on mysqld startup (nothing in the *.err file) and SHOW ENGINES lists Falcon as available.

My guess is that Falcon on-disk structures are corrupt as there was an assert failure and crash during shutdown in Falcon code prior to this (separate bug filed for that). 

Removing all Falcon files and restarting the server fixed this.

How to repeat:
see above
[19 Jan 2009 7:18] Valeriy Kravchuk
Thank you for a problem report. Please, send that last part of the error log, with the assertion failure on shutdown. Send also your my.cnf file content.
[19 Jan 2009 17:16] Mark Callaghan
The crash on shutdown is http://bugs.mysql.com/?id=42184

This is for a new install with 6.0.8 and mysql_install_db. The only my.cnf variables set are falcon_page_cache_size and falcon_record_memory_max. They are both set to 500M, 1G or 2G.
[25 Jan 2009 20:23] Sveta Smirnova
Thank you for the feedback.

Is it possible what you created table 'k' during tests which lead to the crash, then t2.* files from the data directory were removed? Problem is easily repeatable if do so:

$./bin/mysql --socket=/tmp/mysql_ssmirnova.sock -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.10-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table t2(f1 int) engine=falcon;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye

Stop mysqld

$rm ./mysql-test/var/master-data/test/t2*

$ ./libexec/mysqld --defaults-file=support-files/my-small.cnf --basedir=. --datadir=./mysql-test/var/master-data/ --port=33050 --log-error --socket=/tmp/mysql_ssmirnova.sock &
[1] 32512

$./bin/mysql --socket=/tmp/mysql_ssmirnova.sock -uroot test
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 6.0.10-alpha-debug Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> create table t2(f1 int) engine=falcon;
ERROR 1005 (HY000): Can't create table 'test.t2' (errno: 156)
[25 Jan 2009 23:30] Mark Callaghan
No, the table did not exist prior to the error. The error repeated for any table name I used. Also, if you look at the code then you can spot the problem in the error reporting.
[27 Jan 2009 11:09] Sveta Smirnova
Thank you for the feedback.

If look into StorageHandler::createTable code I only see either table should not exist or

if (!dictionaryConnection)
		return NULL;

can cause such behavior. This is easy to repeat using gdb, but in this case exception should be thrown before and a message should be in the error log if this happens in real life.

I set status of the report to "Verified" and provide test case in the additional comment, but if you still have broken tablespace please attach it to the report, so we can create not so artificial example.
[27 Jan 2009 11:12] Sveta Smirnova
How to repeat.

$cat bug42187.test
create table t1 (f1 int) engine=falcon;

$./mtr --manual-gdb bug42187
Logging: ./mtr --manual-gdb bug42187
...

To start gdb for master_0, type in another window:
gdb -cd /users/ssmirnova/build/mysql-6.0/mysql-test -x /users/ssmirnova/build/mysql-6.0/mysql-test/var/tmp/gdbinit.master_0 /users/ssmirnova/build/mysql-6.0/libexec/mysqld

(gdb) b StorageHandler::createTable
Breakpoint 1 at 0x8565319: file StorageHandler.cpp, line 649.
(gdb) run
...
Breakpoint 1, StorageHandler::createTable (this=0xb72e2028, pathname=0xae66ae10 "./test/t1", tableSpaceName=0x0, tempTable=false) at StorageHandler.cpp:649
649             if (!defaultDatabase)
(gdb) set dictionaryConnection=0
(gdb) c
Continuing.
[Thread -1368995920 (LWP 29887) exited]

Test fails as below:

main.bug42187                  [ fail ]

mysqltest: At line 1: query 'create table t1 (f1 int) engine=falcon' failed: 1005: Can't create table 'test.t1' (errno: 156)
...