Bug #8144 | Locking problem in TRUNCATE TABLE | ||
---|---|---|---|
Submitted: | 26 Jan 2005 13:49 | Modified: | 28 Jan 2005 11:39 |
Reporter: | Marko Mäkelä | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | 5.0.3-bk | OS: | Any (all) |
Assigned to: | Marko Mäkelä | CPU Architecture: | Any |
[26 Jan 2005 13:49]
Marko Mäkelä
[26 Jan 2005 20:44]
Marko Mäkelä
Here's a simple test case to repeat the problem. Run two connections in parallel, with these commands: create table t(a bigint primary key not null auto_increment)type=innodb; truncate table t; insert into t values(); truncate table t; insert into t values(); ...
[27 Jan 2005 0:23]
Heikki Tuuri
Marko, you should not set trx->dict_operation = TRUE in TRUNCATE. That flag is a hint that in crash recovery we may need to drop the table automatically. In the case of TRUNCATE we do not wish that. The error message has not surfaced before because DROP TABLE creates its own temporary transaction object. Regards, Heikki trx0trx.h: ibool dict_operation; /* TRUE if the trx is used to create a table, create an index, or drop a table */ lock0lock.c: if (trx->dict_operation) { ut_print_timestamp(stderr); fputs( " InnoDB: Error: a record lock wait happens in a dictionary operation!\n" "InnoDB: Table name ", stderr); ut_print_name(stderr, trx, index->table_name); fputs(".\n" "InnoDB: Submit a detailed bug report to http://bugs.mysql.com\n", stderr); }
[27 Jan 2005 16:03]
Marko Mäkelä
Thanks, Heikki. I removed the offending assignment. The code also complained "MySQL is trying to truncate table though there are still open handles to it". Per your instructions, I removed that check and made TRUNCATE TABLE acquire an exclusive write lock in InnoDB. Now concurrent TRUNCATE and INSERT on the same table seem to work flawlessly. I'll still run some more tests before committing the fixes.
[28 Jan 2005 11:39]
Marko Mäkelä
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