diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-03-10 10:59:19 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-03-10 10:59:19 +0100 |
commit | 0444330a107cdf015f162194a36c0439ef1cc558 (patch) | |
tree | 1794612b14266bc96821a22cf9ef9eb440dc626e /src/datastore | |
parent | 9f466ede8c667284e2747827d0f078cf5851521b (diff) | |
download | gnunet-0444330a107cdf015f162194a36c0439ef1cc558.tar.gz gnunet-0444330a107cdf015f162194a36c0439ef1cc558.zip |
introduce warning if QE fails to make progress
Diffstat (limited to 'src/datastore')
-rw-r--r-- | src/datastore/datastore_api.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/datastore/datastore_api.c b/src/datastore/datastore_api.c index 916e6acae..cf7c7bb1a 100644 --- a/src/datastore/datastore_api.c +++ b/src/datastore/datastore_api.c | |||
@@ -33,6 +33,8 @@ | |||
33 | 33 | ||
34 | #define LOG(kind,...) GNUNET_log_from (kind, "datastore-api",__VA_ARGS__) | 34 | #define LOG(kind,...) GNUNET_log_from (kind, "datastore-api",__VA_ARGS__) |
35 | 35 | ||
36 | #define DELAY_WARN_TIMEOUT GNUNET_TIME_UNIT_MINUTES | ||
37 | |||
36 | /** | 38 | /** |
37 | * Collect an instane number of statistics? May cause excessive IPC. | 39 | * Collect an instane number of statistics? May cause excessive IPC. |
38 | */ | 40 | */ |
@@ -138,6 +140,12 @@ struct GNUNET_DATASTORE_QueueEntry | |||
138 | struct GNUNET_MQ_Envelope *env; | 140 | struct GNUNET_MQ_Envelope *env; |
139 | 141 | ||
140 | /** | 142 | /** |
143 | * Task we run if this entry stalls the queue and we | ||
144 | * need to warn the user. | ||
145 | */ | ||
146 | struct GNUNET_SCHEDULER_Task *delay_warn_task; | ||
147 | |||
148 | /** | ||
141 | * Priority in the queue. | 149 | * Priority in the queue. |
142 | */ | 150 | */ |
143 | unsigned int priority; | 151 | unsigned int priority; |
@@ -269,11 +277,36 @@ free_queue_entry (struct GNUNET_DATASTORE_QueueEntry *qe) | |||
269 | h->queue_size--; | 277 | h->queue_size--; |
270 | if (NULL != qe->env) | 278 | if (NULL != qe->env) |
271 | GNUNET_MQ_discard (qe->env); | 279 | GNUNET_MQ_discard (qe->env); |
280 | if (NULL != qe->delay_warn_task) | ||
281 | GNUNET_SCHEDULER_cancel (qe->delay_warn_task); | ||
272 | GNUNET_free (qe); | 282 | GNUNET_free (qe); |
273 | } | 283 | } |
274 | 284 | ||
275 | 285 | ||
276 | /** | 286 | /** |
287 | * Task that logs an error after some time. | ||
288 | * | ||
289 | * @param qe `struct GNUNET_DATASTORE_QueueEntry` about which the error is | ||
290 | */ | ||
291 | static void | ||
292 | delay_warning (void *cls) | ||
293 | { | ||
294 | struct GNUNET_DATASTORE_QueueEntry *qe = cls; | ||
295 | |||
296 | qe->delay_warn_task = NULL; | ||
297 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
298 | "Request %p of type %u at head of datastore queue for more than %s\n", | ||
299 | qe, | ||
300 | (unsigned int) qe->response_type, | ||
301 | GNUNET_STRINGS_relative_time_to_string (DELAY_WARN_TIMEOUT, | ||
302 | GNUNET_YES)); | ||
303 | qe->delay_warn_task = GNUNET_SCHEDULER_add_delayed (DELAY_WARN_TIMEOUT, | ||
304 | &delay_warning, | ||
305 | qe); | ||
306 | } | ||
307 | |||
308 | |||
309 | /** | ||
277 | * Handle error in sending drop request to datastore. | 310 | * Handle error in sending drop request to datastore. |
278 | * | 311 | * |
279 | * @param cls closure with the datastore handle | 312 | * @param cls closure with the datastore handle |
@@ -290,6 +323,12 @@ mq_error_handler (void *cls, | |||
290 | "MQ error, reconnecting to DATASTORE\n"); | 323 | "MQ error, reconnecting to DATASTORE\n"); |
291 | do_disconnect (h); | 324 | do_disconnect (h); |
292 | qe = h->queue_head; | 325 | qe = h->queue_head; |
326 | if (NULL != qe->delay_warn_task) | ||
327 | { | ||
328 | GNUNET_SCHEDULER_cancel (qe->delay_warn_task); | ||
329 | qe->delay_warn_task = NULL; | ||
330 | } | ||
331 | |||
293 | if ( (NULL != qe) && | 332 | if ( (NULL != qe) && |
294 | (NULL == qe->env) ) | 333 | (NULL == qe->env) ) |
295 | { | 334 | { |
@@ -594,6 +633,10 @@ process_queue (struct GNUNET_DATASTORE_Handle *h) | |||
594 | "Not connected\n"); | 633 | "Not connected\n"); |
595 | return; | 634 | return; |
596 | } | 635 | } |
636 | GNUNET_assert (NULL == qe->delay_warn_task); | ||
637 | qe->delay_warn_task = GNUNET_SCHEDULER_add_delayed (DELAY_WARN_TIMEOUT, | ||
638 | &delay_warning, | ||
639 | qe); | ||
597 | GNUNET_MQ_send (h->mq, | 640 | GNUNET_MQ_send (h->mq, |
598 | qe->env); | 641 | qe->env); |
599 | qe->env = NULL; | 642 | qe->env = NULL; |