Prevent monitor deadlocks with repeated restarts
If a monitor is started and stopped before the external monitoring thread has had time to start, a deadlock will occur. The first thing that the monitoring threads do is read the monitor handle from the monitor object. This handle is given as the return value of startMonitor and it is stored in the monitor object. As this can still be NULL when the monitor thread starts, the threads use locks to prevent this. The correct way to prevent this is to pass the handle as the thread parameter so that no locks are required.
This commit is contained in:
@ -57,7 +57,6 @@ MXS_BEGIN_DECLS
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
SPINLOCK lock; /**< The monitor spinlock */
|
||||
THREAD thread; /**< Monitor thread */
|
||||
int shutdown; /**< Flag to shutdown the monitor thread */
|
||||
int status; /**< Monitor status */
|
||||
@ -81,6 +80,7 @@ typedef struct
|
||||
bool warn_failover; /**< Log a warning when failover happens */
|
||||
bool load_journal; /**< Whether journal file should be loaded */
|
||||
time_t journal_max_age; /**< Maximum age of journal file */
|
||||
MXS_MONITOR* monitor;
|
||||
} MYSQL_MONITOR;
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user