#At file:///usr/home/serg/Abk/mysql/6.0-maria/
2707 Sergei Golubchik 2008-12-22
Bug#40990 Maria: failure of maria.test & maria_notemebedded in deadlock
detection
detect a case when a blocker has removed itself and signalled after the condition
timed out
but before it (cond_wait) acquired the mutex back
modified:
include/waiting_threads.h
mysys/waiting_threads.c
=== modified file 'include/waiting_threads.h'
--- a/include/waiting_threads.h 2008-11-04 13:09:32 +0000
+++ b/include/waiting_threads.h 2008-12-22 18:04:24 +0000
@@ -182,6 +182,7 @@ typedef struct st_wt_thd {
} WT_THD;
#define WT_TIMEOUT ETIMEDOUT
+#define WT_FREE_TO_GO 1
#define WT_OK 0
#define WT_DEADLOCK -1
#define WT_DEPTH_EXCEEDED -2
=== modified file 'mysys/waiting_threads.c'
--- a/mysys/waiting_threads.c 2008-11-10 19:11:27 +0000
+++ b/mysys/waiting_threads.c 2008-12-22 18:04:24 +0000
@@ -613,7 +613,16 @@ static int deadlock(WT_THD *thd, WT_THD
if (ret == WT_DEADLOCK && depth)
change_victim(blocker, &arg);
if (arg.rc)
+ {
+ /* special return code if there's nobody to wait for */
+ if (depth == 0 && ret == WT_OK && arg.rc->owners.elements == 0)
+ {
+ DBUG_ASSERT(thd == blocker);
+ DBUG_ASSERT(arg.rc == thd->waiting_for);
+ ret= WT_FREE_TO_GO;
+ }
rc_unlock(arg.rc);
+ }
/* notify the victim, if appropriate */
if (ret == WT_DEADLOCK && arg.victim != thd)
{
@@ -888,7 +897,10 @@ int wt_thd_cond_timedwait(WT_THD *thd, p
ret= pthread_cond_timedwait(&rc->cond, mutex, &timeout);
if (ret == WT_TIMEOUT)
{
- if (deadlock(thd, thd, 0, *thd->deadlock_search_depth_long))
+ int r= deadlock(thd, thd, 0, *thd->deadlock_search_depth_long);
+ if (r == WT_FREE_TO_GO)
+ ret= WT_OK;
+ else if (r != WT_OK)
ret= WT_DEADLOCK;
else if (*thd->timeout_long > *thd->timeout_short)
{