Commit 3fc78478 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

wrk: Track workers to dump them during a panic

In the most common case of a VCL transaction panicking this should only
result in an extra "Already dumped, see above" message, but it may give
more insights for other kinds of tasks.
parent 343e680a
......@@ -76,6 +76,7 @@ cache_vrnd_unlock(void)
static pthread_key_t req_key;
static pthread_key_t bo_key;
static pthread_key_t wrk_key;
pthread_key_t witness_key;
void
......@@ -106,6 +107,20 @@ THR_GetRequest(void)
return (pthread_getspecific(req_key));
}
void
THR_SetWorker(const struct worker *wrk)
{
AZ(pthread_setspecific(wrk_key, wrk));
}
struct worker *
THR_GetWorker(void)
{
return (pthread_getspecific(wrk_key));
}
/*--------------------------------------------------------------------
* Name threads if our pthreads implementation supports it.
*/
......@@ -351,6 +366,7 @@ child_main(int sigmagic, size_t altstksz)
AZ(pthread_key_create(&req_key, NULL));
AZ(pthread_key_create(&bo_key, NULL));
AZ(pthread_key_create(&wrk_key, NULL));
AZ(pthread_key_create(&witness_key, free));
AZ(pthread_key_create(&name_key, NULL));
......
......@@ -712,6 +712,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
const char *q;
struct req *req;
struct busyobj *bo;
struct worker *wrk;
struct sigaction sa;
int err = errno;
......@@ -794,6 +795,9 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
pan_busyobj(pan_vsb, bo);
if (bo != NULL)
VSL_Flush(bo->vsl, 0);
wrk = THR_GetWorker();
VSB_cat(pan_vsb, "thr.");
pan_wrk(pan_vsb, wrk);
VMOD_Panic(pan_vsb);
pan_pool(pan_vsb);
} else {
......
......@@ -309,6 +309,8 @@ void THR_SetBusyobj(const struct busyobj *);
struct busyobj * THR_GetBusyobj(void);
void THR_SetRequest(const struct req *);
struct req * THR_GetRequest(void);
void THR_SetWorker(const struct worker *);
struct worker * THR_GetWorker(void);
void THR_Init(void);
/* cache_lck.c */
......
......@@ -145,6 +145,7 @@ WRK_Thread(struct pool *qp, size_t stacksize, unsigned thread_workspace)
w->lastused = NAN;
memset(&ds, 0, sizeof ds);
w->stats = &ds;
THR_SetWorker(w);
AZ(pthread_cond_init(&w->cond, NULL));
WS_Init(w->aws, "wrk", ws, thread_workspace);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment