aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-10 10:59:19 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-10 10:59:19 +0100
commit0444330a107cdf015f162194a36c0439ef1cc558 (patch)
tree1794612b14266bc96821a22cf9ef9eb440dc626e
parent9f466ede8c667284e2747827d0f078cf5851521b (diff)
introduce warning if QE fails to make progress
-rw-r--r--src/datastore/datastore_api.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c
index 916e6acaef..cf7c7bb1a7 100644
--- a/src/datastore/datastore_api.c
+++ b/src/datastore/datastore_api.c
@@ -33,6 +33,8 @@
#define LOG(kind,...) GNUNET_log_from (kind, "datastore-api",__VA_ARGS__)
+#define DELAY_WARN_TIMEOUT GNUNET_TIME_UNIT_MINUTES
+
/**
* Collect an instane number of statistics? May cause excessive IPC.
*/
@@ -138,6 +140,12 @@ struct GNUNET_DATASTORE_QueueEntry
struct GNUNET_MQ_Envelope *env;
/**
+ * Task we run if this entry stalls the queue and we
+ * need to warn the user.
+ */
+ struct GNUNET_SCHEDULER_Task *delay_warn_task;
+
+ /**
* Priority in the queue.
*/
unsigned int priority;
@@ -269,11 +277,36 @@ free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe)
h->queue_size--;
if (NULL != qe->env)
GNUNET_MQ_discard (qe->env);
+ if (NULL != qe->delay_warn_task)
+ GNUNET_SCHEDULER_cancel (qe->delay_warn_task);
GNUNET_free (qe);
}
/**
+ * Task that logs an error after some time.
+ *
+ * @param qe `struct GNUNET_DATASTORE_QueueEntry` about which the error is
+ */
+static void
+delay_warning (void *cls)
+{
+ struct GNUNET_DATASTORE_QueueEntry *qe = cls;
+
+ qe->delay_warn_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Request %p of type %u at head of datastore queue for more than %s\n",
+ qe,
+ (unsigned int) qe->response_type,
+ GNUNET_STRINGS_relative_time_to_string (DELAY_WARN_TIMEOUT,
+ GNUNET_YES));
+ qe->delay_warn_task = GNUNET_SCHEDULER_add_delayed (DELAY_WARN_TIMEOUT,
+ &delay_warning,
+ qe);
+}
+
+
+/**
* Handle error in sending drop request to datastore.
*
* @param cls closure with the datastore handle
@@ -290,6 +323,12 @@ mq_error_handler (void *cls,
"MQ error, reconnecting to DATASTORE\n");
do_disconnect (h);
qe = h->queue_head;
+ if (NULL != qe->delay_warn_task)
+ {
+ GNUNET_SCHEDULER_cancel (qe->delay_warn_task);
+ qe->delay_warn_task = NULL;
+ }
+
if ( (NULL != qe) &&
(NULL == qe->env) )
{
@@ -594,6 +633,10 @@ process_queue (struct GNUNET_DATASTORE_Handle *h)
"Not connected\n");
return;
}
+ GNUNET_assert (NULL == qe->delay_warn_task);
+ qe->delay_warn_task = GNUNET_SCHEDULER_add_delayed (DELAY_WARN_TIMEOUT,
+ &delay_warning,
+ qe);
GNUNET_MQ_send (h->mq,
qe->env);
qe->env = NULL;