static THREAD_POOL thread_pool;
static int pool_initialized = FALSE;
static time_t last_cleaned = 0;
+static time_t almost_now = 0;
static void thread_pool_manage(time_t now);
/*
* Mark the request as done.
*/
- radlog(L_ERR, "!!! ERROR !!! The server is blocked: discarding new request %d", request->number);
+ radlog(L_ERR, "Something is blocking the server. There are %d packets in the queue, waiting to be processed. Ignoring the new request.", thread_pool.max_queue_size);
request->child_state = REQUEST_DONE;
return 0;
}
+ request->child_state = REQUEST_QUEUED;
+ request->component = "<queue>";
entry = rad_malloc(sizeof(*entry));
entry->request = request;
*/
static int request_dequeue(REQUEST **request, RAD_REQUEST_FUNP *fun)
{
+ int blocked;
RAD_LISTEN_TYPE i, start;
request_queue_t *entry;
rad_assert((*request)->magic == REQUEST_MAGIC);
rad_assert(*fun != NULL);
+ (*request)->component = "";
+
/*
* If the request has sat in the queue for too long,
* kill it.
}
/*
+ * Produce messages for people who have 10 million rows
+ * in a database, without indexes.
+ */
+ rad_assert(almost_now != 0);
+ blocked = almost_now - (*request)->timestamp;
+ if (blocked < 5) {
+ blocked = 0;
+ } else {
+ static time_t last_complained = 0;
+
+ if (last_complained != almost_now) {
+ last_complained = almost_now;
+ } else {
+ blocked = 0;
+ }
+ }
+
+ /*
* The thread is currently processing a request.
*/
thread_pool.active_threads++;
pthread_mutex_unlock(&thread_pool.queue_mutex);
+ if (blocked) {
+ radlog(L_ERR, "Request %u has been waiting in the processing queue for %d seconds. Check that all databases are running properly!",
+ (*request)->number, blocked);
+ }
+
return 1;
}
*/
int thread_pool_addrequest(REQUEST *request, RAD_REQUEST_FUNP fun)
{
- time_t now = request->timestamp;
+ almost_now = request->timestamp;
/*
* We've been told not to spawn threads, so don't.
* in a while, OR if the thread pool appears to be full,
* go manage it.
*/
- if ((last_cleaned < now) ||
+ if ((last_cleaned < almost_now) ||
(thread_pool.active_threads == thread_pool.total_threads)) {
- thread_pool_manage(now);
+ thread_pool_manage(almost_now);
}
return 1;