2717 Dmitry Lenev 2008-10-01
Fix for bug#37961 "'Trying to destroy unitialized mutex' when
--datadir does not exist".
Attempt to start server with non-existing data directory led to
destroying of uninitialized Backup_restore_ctx::run_lock mutex
and assertion failure. The problem was that unireg_abort()
function, which is called in case of error during server
start-up and which assumes that it can be called even for
partially initialized server, has called backup_shutdown()
function which assumed that backup_init() was successfully
performed prior to its call.
This patch solves problem by ensuring that backup_shutdown()
can be safely called without prior call to backup_init() and
thus satisfying assumption made by unireg_abort().
Note that similar problem with LOCK_mdl has been already
solved by Monty's patch from 2008-08-13 in similar fashion.
No test case is provided since such situation can't be easily
covered by our test suite.
modified:
sql/backup/backup_kernel.h
sql/backup/kernel.cc
2716 Alexander Nozdrin 2008-09-16
Revert .bzr-mysql/default.conf changes
modified:
.bzr-mysql/default.conf
=== modified file 'sql/backup/backup_kernel.h'
--- a/sql/backup/backup_kernel.h 2008-08-08 17:21:31 +0000
+++ b/sql/backup/backup_kernel.h 2008-10-01 10:14:28 +0000
@@ -87,6 +87,11 @@ class Backup_restore_ctx: public backup:
ongoing backup/restore operation. If pointer is null, no
operation is currently running. */
static Backup_restore_ctx *current_op;
+ /**
+ Indicates if @c run_lock mutex was initialized and thus it should
+ be properly destroyed during shutdown. @sa backup_shutdown().
+ */
+ static bool run_lock_initialized;
static pthread_mutex_t run_lock; ///< To guard @c current_op.
/**
=== modified file 'sql/backup/kernel.cc'
--- a/sql/backup/kernel.cc 2008-09-05 14:16:07 +0000
+++ b/sql/backup/kernel.cc 2008-10-01 10:14:28 +0000
@@ -96,6 +96,7 @@
int backup_init()
{
pthread_mutex_init(&Backup_restore_ctx::run_lock, MY_MUTEX_INIT_FAST);
+ Backup_restore_ctx::run_lock_initialized= TRUE;
return 0;
}
@@ -104,10 +105,18 @@ int backup_init()
@note This function is called in the server shut-down sequences, just before
it shuts-down all its plugins.
+
+ @note Due to way in which server's code is organized this function might be
+ called and should work normally even in situation when backup_init() was not
+ called at all.
*/
void backup_shutdown()
{
- pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+ if (Backup_restore_ctx::run_lock_initialized)
+ {
+ pthread_mutex_destroy(&Backup_restore_ctx::run_lock);
+ Backup_restore_ctx::run_lock_initialized= FALSE;
+ }
}
/*
@@ -362,6 +371,7 @@ class Mem_allocator
// static members
Backup_restore_ctx *Backup_restore_ctx::current_op= NULL;
+bool Backup_restore_ctx::run_lock_initialized= FALSE;
pthread_mutex_t Backup_restore_ctx::run_lock;
| Thread |
|---|
| • bzr push into mysql-6.0 branch (dlenev:2716 to 2717) Bug#37961 | Dmitry Lenev | 1 Oct |