Merge lp:~ev/whoopsie/exponential-backoff into lp:whoopsie

Proposed by Evan
Status: Needs review
Proposed branch: lp:~ev/whoopsie/exponential-backoff
Merge into: lp:whoopsie
Diff against target: 116 lines (+29/-7)
4 files modified
Makefile (+1/-1)
src/tests/Makefile (+1/-1)
src/whoopsie.c (+26/-4)
src/whoopsie.h (+1/-1)
To merge this branch: bzr merge lp:~ev/whoopsie/exponential-backoff
Reviewer Review Type Date Requested Status
Daisy Pluckers Pending
Review via email: mp+170621@code.launchpad.net

Description of the change

This branch adds exponential backing off of report submissions when one of the submissions fails. So normally whoopsie will process outstanding reports every two hours. If one of the reports in the handful it's currently processing fails, it will retry two hours and 4 minutes later, then two hours and 8 minutes if that fails, two hours and 16, and so on.

This will help us when we and if we have to bring daisy.ubuntu.com down for any length of time in that it will prevent a flood of systems hitting us all at once.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
Revision history for this message
Ted Gould (ted) :

Unmerged revisions

560. By Evan

Back off exponentially.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2013-02-26 10:36:50 +0000
3+++ Makefile 2013-06-20 13:54:24 +0000
4@@ -12,7 +12,7 @@
5 whoopsie_CFLAGS=$(shell pkg-config --cflags gio-2.0 glib-2.0 libcurl) \
6 -g -Ilib -Wall -Werror -Os -DVERSION=\"$(VERSION)\" \
7 $(CFLAGS) $(CPPFLAGS)
8-whoopsie_LIBS=$(shell pkg-config --libs gio-2.0 glib-2.0 libcurl) -lcap \
9+whoopsie_LIBS=$(shell pkg-config --libs gio-2.0 glib-2.0 libcurl) -lm -lcap \
10 $(LDFLAGS)
11 SOURCES=src/whoopsie.c \
12 src/utils.c \
13
14=== modified file 'src/tests/Makefile'
15--- src/tests/Makefile 2013-02-26 11:02:35 +0000
16+++ src/tests/Makefile 2013-06-20 13:54:24 +0000
17@@ -2,7 +2,7 @@
18 CFLAGS=$(shell pkg-config --cflags gio-2.0 glib-2.0 libcurl) \
19 $(shell libgcrypt-config --cflags) \
20 -g -I../../lib -I.. -DVERSION=\"$(VERSION)\" -DTEST -DTEST_DIR=\"$(CURDIR)\" -Wall
21-LIBS=$(shell pkg-config --libs gio-2.0 glib-2.0 libcurl) -lcap \
22+LIBS=$(shell pkg-config --libs gio-2.0 glib-2.0 libcurl) -lm -lcap \
23 $(shell libgcrypt-config --libs)
24
25 test_parse_report_SOURCES=test_parse_report.c \
26
27=== modified file 'src/whoopsie.c'
28--- src/whoopsie.c 2013-02-08 11:58:46 +0000
29+++ src/whoopsie.c 2013-06-20 13:54:24 +0000
30@@ -39,6 +39,7 @@
31 #include <sys/mount.h>
32 #include <sys/time.h>
33 #include <sys/resource.h>
34+#include <math.h>
35
36 #include "bson/bson.h"
37 #include "whoopsie.h"
38@@ -47,10 +48,16 @@
39 #include "monitor.h"
40 #include "identifier.h"
41
42-/* The length of time to wait before processing outstanding crashes, in seconds
43- */
44+/* The length of time to wait before processing outstanding crashes (retrying),
45+ * in seconds. */
46 #define PROCESS_OUTSTANDING_TIMEOUT 7200
47
48+/* The starting point for exponential backoff, in seconds. */
49+#define BASE_BACKOFF 60
50+
51+/* The number of times we've retried the upload of reports */
52+static int retry_count = 0;
53+
54 /* If true, we have an active Internet connection. True by default in case we
55 * can't bring up GNetworkMonitor */
56 static gboolean online_state = TRUE;
57@@ -638,7 +645,7 @@
58 return success;
59 }
60
61-void
62+gboolean
63 process_existing_files (const char* report_dir)
64 {
65 GDir* dir = NULL;
66@@ -646,6 +653,7 @@
67 const gchar* ext = NULL;
68 char* upload_file = NULL;
69 char* crash_file = NULL;
70+ gboolean failed = FALSE;
71
72 dir = g_dir_open (report_dir, 0, NULL);
73 while ((file = g_dir_read_name (dir)) != NULL) {
74@@ -671,15 +679,29 @@
75 g_free (crash_file);
76 continue;
77 } else if (online_state && parse_and_upload_report (crash_file)) {
78+ retry_count = 0;
79 if (!mark_handled (crash_file))
80 g_print ("Unable to mark report as seen (%s)\n", crash_file);
81
82- }
83+ } else {
84+ failed = TRUE;
85+ }
86
87 g_free (upload_file);
88 g_free (crash_file);
89 }
90 g_dir_close (dir);
91+
92+ if (failed) {
93+ retry_count += 1;
94+ /* Exponential backoff. */
95+ g_timeout_add_seconds (PROCESS_OUTSTANDING_TIMEOUT + BASE_BACKOFF * pow(2, retry_count),
96+ (GSourceFunc) process_existing_files,
97+ (gpointer) report_dir);
98+ /* Cancel the existing timeout, since we've just created a new one. */
99+ return FALSE;
100+ }
101+ return TRUE;
102 }
103
104 void daemonize (void)
105
106=== modified file 'src/whoopsie.h'
107--- src/whoopsie.h 2012-12-11 17:56:52 +0000
108+++ src/whoopsie.h 2013-06-20 13:54:24 +0000
109@@ -24,6 +24,6 @@
110 char* get_crash_db_url (void);
111 void destroy_key_and_value (gpointer key, gpointer value, gpointer user_data);
112 void drop_privileges (GError** error);
113-void process_existing_files (const char* report_dir);
114+gboolean process_existing_files (const char* report_dir);
115
116 #endif /* WHOOPSIE_H */

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: