Bug #29155 | Innodb "Parallel recovery" is not prevented | ||
---|---|---|---|
Submitted: | 16 Jun 2007 13:53 | Modified: | 19 Jun 2010 17:45 |
Reporter: | Peter Zaitsev (Basic Quality Contributor) | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: InnoDB storage engine | Severity: | S2 (Serious) |
Version: | 5.0, 5.1 | OS: | FreeBSD |
Assigned to: | Vasil Dimov | CPU Architecture: | Any |
Tags: | qc |
[16 Jun 2007 13:53]
Peter Zaitsev
[16 Jun 2007 14:33]
Valeriy Kravchuk
Thank you for a problem report. While the problem is obvious from the logs, can you explain in more details how to repeat it? When I just tried to start another mysqld process I've got: openxs@suse:~/dbs/5.0> 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.
[16 Jun 2007 17:59]
Peter Zaitsev
Right I know this is especially why I mentioned this is FreeBSD system. Possibly it is platform specific bug or there is race condition. I have no way to play with MySQL as this is customers production system. I have however seen this on multiple instances.
[17 Jun 2007 4:15]
Mark Callaghan
There was a related bug where '/etc/init.d/mysql restart' would leave two instances of MySQL running because it only waited for 30 seconds for mysqld to stop and then it would timeout and start a new mysqld process. I think that has been fixed by 5.0.41.
[17 Jun 2007 11:09]
Peter Zaitsev
Mark, This is not exactly the same. Even if mysqld_safe tries to start second mysqld instance it should safely fail... Either on Innodb trying to lock data file or on MySQL binding to the same port. However this attempt by mysqld_safe may be nasty - I've seen socket file and pid file being removed in such case for example.
[18 Jun 2007 13:18]
Heikki Tuuri
Hmm... looks like 'advisory file locking' does not work on FreeBSD. Assigning this to Marko.
[19 Jun 2007 6:01]
Vasil Dimov
I am able to start 2 mysql instances on FreeBSD 7-CURRENT (from May 27) when I use --skip-networking option: $ ./libexec/mysqld --skip-networking 070619 8:53:49 InnoDB: Started; log sequence number 0 46409 070619 8:53:50 [Note] Event Scheduler: Loaded 0 events 070619 8:53:50 [Note] ./libexec/mysqld: ready for connections. Version: '5.1.20-beta-debug' socket: '/tmp/mysql.sock' port: 0 Source distribution $ ./libexec/mysqld --skip-networking 070619 8:53:58 InnoDB: Started; log sequence number 0 46409 070619 8:53:59 [Note] Event Scheduler: Loaded 0 events 070619 8:53:59 [Note] ./libexec/mysqld: ready for connections. Version: '5.1.20-beta-debug' socket: '/tmp/mysql.sock' port: 0 Source distribution $ ps -ax |grep mysql 81972 p4 I+ 0:00.43 ./libexec/mysqld --skip-networking 81992 pa I+ 0:00.43 ./libexec/mysqld --skip-networking
[19 Jun 2007 13:12]
Peter Zaitsev
Vasil, Thank you for confirming the bug. The good question is actually if this is Innodb problem when. I guess you can replace Innodb with any other storage engine here and results can always be pretty bad. May be MySQL should have its build in prevention of second start which is not storage engine dependent ?
[25 Jun 2007 13:55]
Heikki Tuuri
Vasil, does FreeBSD have any file locking mechanism that we could use here? Regards, Heikki
[27 Jun 2007 8:40]
Vasil Dimov
Peter, > The good question is actually if this is Innodb problem when. I guess you can replace > Innodb with any other storage engine here and results can always be pretty bad. > > May be MySQL should have its build in prevention of second start which is not storage > engine dependent ? Indeed. MySQL should protect its resources from another instances. For example: * The TCP port need no protection, "bind(): address already in use" * The /tmp/mysql.sock file should be protected by /tmp/mysql.sock.lock dummy file (for example) being flock(2)'d * The data directory should be protected in a similar way Actually, if InnoDB is enabled, MySQL won't start a second instance because InnoDB cannot lock it's files, but this is disabled on FreeBSD: os0file.c: 457 #undef USE_FILE_LOCK 458 #define USE_FILE_LOCK 459 #if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__FreeBSD__) || defined(__NETWARE__) 460 /* InnoDB Hot Backup does not lock the data files. 461 * On Windows, mandatory locking is used. 462 * On FreeBSD with LinuxThreads, advisory locking does not work properly. 463 */ 464 # undef USE_FILE_LOCK 465 #endif 466 #ifdef USE_FILE_LOCK 467 /******************************************************************** 468 Obtain an exclusive lock on a file. */ 469 static 470 int 471 os_file_lock( So InnoDB behavior differs from Linux to FreeBSD, I am going to check what has been the problem with FreeBSD & LinuxThreads and if it has not been fixed already...
[27 Jun 2007 9:04]
Peter Zaitsev
There is another question, The build I was using was not LinuxThreads FreeBSD it was normal FreeBSD build so may be this check needs to have further clarification and only apply to LinuxThreads on FreeBSD case ?
[27 Jun 2007 10:00]
Vasil Dimov
Yes, it is overdoing to always disable locking on FreeBSD. I think that LinuxThreads can be distinguished because they define the symbol __LT_SPINLOCK_INIT, so we can disable locking like this: #if defined(__FreeBSD__) && defined(__LT_SPINLOCK_INIT) Or even better: #define is_linuxthreads defined(__LT_SPINLOCK_INIT) #if defined(__FreeBSD__) && is_linuxthreads ... disable locking ...
[27 Jun 2007 15:31]
Heikki Tuuri
Vasil intends to remove the whole FreeBSD special define. File locking seems to work on a modern FreeBSD, regardless of LinuxThreads.
[27 Jun 2007 17:03]
Vasil Dimov
Fix which enables locking on FreeBSD has been committed into the InnoDB 5.0 SVN tree under r1615 and into the 5.1 SVN tree under r1613. Peter, here is the patch in case you want to test it before it goes into official MySQL releases (which may take months): Index: os/os0file.c =================================================================== --- os/os0file.c (revision 1614) +++ os/os0file.c (revision 1615) @@ -436,10 +436,9 @@ #undef USE_FILE_LOCK #define USE_FILE_LOCK -#if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__FreeBSD__) || defined(__NETWARE__) +#if defined(UNIV_HOTBACKUP) || defined(__WIN__) || defined(__NETWARE__) /* InnoDB Hot Backup does not lock the data files. * On Windows, mandatory locking is used. - * On FreeBSD with LinuxThreads, advisory locking does not work properly. */ # undef USE_FILE_LOCK #endif Also notice that there _is_ a MySQL problem that it starts twice over the same unix domain socket and data directory if InnoDB is disabled. You may want to open another bug report for that.
[27 Jun 2007 18:28]
Peter Zaitsev
Thanks Vasil for prompt fix. I trust you it works I will not be testing it myself but will let customer know.
[25 Jul 2007 1:37]
Timothy Smith
Queued to 5.1-maint
[2 Aug 2007 19:13]
Bugs System
Pushed into 5.1.21-beta
[16 Aug 2007 0:56]
Timothy Smith
Queued to 5.0-maint
[20 Aug 2007 10:05]
Bugs System
Pushed into 5.0.48
[20 Aug 2007 10:20]
Bugs System
Pushed into 5.1.22-beta
[25 Aug 2007 14:34]
Paul DuBois
Noted in 5.0.48, 5.1.21 changelogs. InnoDB refused to start on some versions of FreeBSD with LinuxThreads. This is fixed by enabling file locking on FreeBSD.
[5 May 2010 15:16]
Bugs System
Pushed into 5.1.47 (revid:joro@sun.com-20100505145753-ivlt4hclbrjy8eye) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[6 May 2010 2:58]
Paul DuBois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug. Re-closing.
[28 May 2010 5:56]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100524190136-egaq7e8zgkwb9aqi) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (pib:16)
[28 May 2010 6:25]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100524190941-nuudpx60if25wsvx) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[28 May 2010 6:53]
Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100524185725-c8k5q7v60i5nix3t) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[29 May 2010 22:34]
Paul DuBois
Push resulted from incorporation of InnoDB tree. No changes pertinent to this bug. Re-closing.
[17 Jun 2010 11:58]
Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:37]
Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:24]
Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)