Bug #33607 Falcon allows two mysqld instances to share a tablespace
Submitted: 1 Jan 2008 18:24 Modified: 5 Oct 2008 16:32
Reporter: Philip Stoev
Status: Closed
Category:Server: Falcon Severity:S2 (Serious)
Version:6.0.4 OS:Any (linux)
Assigned to: Sergey Vojtovich Target Version:
Triage: D3 (Medium) / R2 (Low) / E2 (Low)

[1 Jan 2008 18:24] Philip Stoev
Description:
Two mysqld instances can be started, pointing to the same datadir, and falcon will not
complain. This opens up the opportunity for table corruption -- after repeated queries
and a few restarts, a phantom Falcon table appears, which is present in SHOW TABLES,
however can not be DESCRIBE-d.

This is in contrast with Innodb, which will refuse to start in such circumstances.

How to repeat:
1. Start server #1 ./mysqld --datadir=/build/testdata --port=1234 --skip-innodb
--skip-grant-tables

2. create a falcon table on server #1

3. Start server #2 ./mysqld --datadir=/build/testdata --port=1234 --skip-innodb
--skip-grant-tables

4. The falcon table is now accessible via both servers. This can't be good.

Suggested fix:
It appears that in MySQL every engine is responsible for the protection of its own files.
Innodb takes the opportunity to examine its data files on startup and a conflict results
in a:

InnoDB: Unable to lock ./ibdata1, error: 11
InnoDB: Check that you do not already have another mysqld process
InnoDB: using the same InnoDB data or log files.
080101 18:14:29  InnoDB: Retrying to lock the first data file
[2 Jan 2008 16:37] Miguel Solorzano
Thank you for the bug report. I was able to repeat changing the below as
repeat step:

3. Start server #2 ./mysqld --datadir=/build/testdata --port=1234 --skip-innodb
--skip-grant-tables

using a --port=1235 which is different than the first instance server port.
[23 Apr 2008 8:25] 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/45863

ChangeSet@1.2634, 2008-04-23 10:22:32+05:00, svoj@mysql.com +1 -0
  BUG#33607 - Falcon allows two mysqld instances to share a tablespace
  
  It was possible to start two (or more) mysqld instances using
  the same falcon tablespace/metadata files. As a result
  tablespace/metadata files may get corrupt.
  
  Fixed by enabling advisory file locks.
[25 Apr 2008 14:14] 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/46017

ChangeSet@1.2635, 2008-04-25 16:11:20+05:00, svoj@mysql.com +1 -0
  BUG#33607 - Falcon allows two mysqld instances to share a tablespace
  
  This is an addition to original bugfix.
  Use fcntl() instead of flock() for file locking.
[5 Aug 2008 18:46] Sergey Vojtovich
Was pushed to 6.0.6.
[5 Oct 2008 16:32] Jon Stephens
Documented in the 6.0.6 changelog as follows:

        It was possible for multiple mysqld instances to use
        the same Falcon tablespace and metadata files, which could lead to
        corruption of the tablespace files, metadata files, or both.