summaryrefslogtreecommitdiff
path: root/vio
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2013-05-23 14:52:48 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2013-05-23 14:52:48 +0200
commit08ce9bfe057b6cd31e7fbca4e4e9e48edde242fb (patch)
tree3882462528dc16c79cb55a3528d2998997e7a320 /vio
parent52045d40d4fe0df0e60fa37eb35609fcb0fd857a (diff)
downloadmariadb-git-08ce9bfe057b6cd31e7fbca4e4e9e48edde242fb.tar.gz
MDEV-4566 : Failing DBUG_ASSERT() in SELECT SLEEP(), with threadpool.
This bug only happens with long sleep()s ( > 5 sec), and in debug version. Analysis: The assertion is caused by nested thd_wait_begin() calls, which is not an expected condition. - "outer" thd_wait_begin()) , in Item_func_sleep::val_int() - "inner" thd_wait_begin() in Interruptible_wait::wait(). This function periodically checks whether connection is still valid, via THD::is_connection(), which ends up calling vio_io_wait() with timeout parameter set to 0. Fix is not to call thd wait callback in vio_io_wait(), if timeout parameter is 0. There is no "waiting" in this case.
Diffstat (limited to 'vio')
-rw-r--r--vio/viosocket.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/vio/viosocket.c b/vio/viosocket.c
index f84d7e802be..da5f640fc62 100644
--- a/vio/viosocket.c
+++ b/vio/viosocket.c
@@ -42,21 +42,21 @@ static void (*before_io_wait)(void)= 0;
static void (*after_io_wait)(void)= 0;
/* Wait callback macros (both performance schema and threadpool */
-#define START_SOCKET_WAIT(locker, state_ptr, sock, which) \
+#define START_SOCKET_WAIT(locker, state_ptr, sock, which, timeout) \
do \
{ \
MYSQL_START_SOCKET_WAIT(locker, state_ptr, sock, \
which, 0); \
- if (before_io_wait) \
+ if (timeout && before_io_wait) \
before_io_wait(); \
} while(0)
-#define END_SOCKET_WAIT(locker) \
+#define END_SOCKET_WAIT(locker,timeout) \
do \
{ \
MYSQL_END_SOCKET_WAIT(locker, 0); \
- if (after_io_wait) \
+ if (timeout && after_io_wait) \
after_io_wait(); \
} while(0)
@@ -930,11 +930,11 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
if (timeout != 0 && vio->async_context && vio->async_context->active)
{
START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
- PSI_SOCKET_SELECT);
+ PSI_SOCKET_SELECT, timeout);
ret= my_io_wait_async(vio->async_context, event, timeout);
if (ret == 0)
errno= SOCKET_ETIMEDOUT;
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker,timeout);
DBUG_RETURN(ret);
}
@@ -959,7 +959,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
break;
}
- START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
+ START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, timeout);
/*
Wait for the I/O event and return early in case of
error or timeout.
@@ -982,7 +982,7 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
break;
}
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker, timeout);
DBUG_RETURN(ret);
}
@@ -1004,11 +1004,11 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
if (timeout != 0 && vio->async_context && vio->async_context->active)
{
START_SOCKET_WAIT(locker, &state, vio->mysql_socket,
- PSI_SOCKET_SELECT);
+ PSI_SOCKET_SELECT, timeout);
ret= my_io_wait_async(vio->async_context, event, timeout);
if (ret == 0)
WSASetLastError(SOCKET_ETIMEDOUT);
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker, timeout);
DBUG_RETURN(ret);
}
@@ -1039,12 +1039,12 @@ int vio_io_wait(Vio *vio, enum enum_vio_io_event event, int timeout)
break;
}
- START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT);
+ START_SOCKET_WAIT(locker, &state, vio->mysql_socket, PSI_SOCKET_SELECT, timeout);
/* The first argument is ignored on Windows. */
ret= select(0, &readfds, &writefds, &exceptfds, (timeout >= 0) ? &tm : NULL);
- END_SOCKET_WAIT(locker);
+ END_SOCKET_WAIT(locker, timeout);
/* Set error code to indicate a timeout error. */
if (ret == 0)