Merge lp:~ted/url-dispatcher/error-data into lp:url-dispatcher/14.10

Proposed by Ted Gould
Status: Merged
Approved by: Charles Kerr
Approved revision: 60
Merged at revision: 57
Proposed branch: lp:~ted/url-dispatcher/error-data
Merge into: lp:url-dispatcher/14.10
Diff against target: 198 lines (+57/-24)
4 files modified
debian/rules (+8/-0)
debian/source_url-dispatcher.py (+20/-0)
debian/url-dispatcher-crashdb.conf (+6/-0)
service/url-db.c (+23/-24)
To merge this branch: bzr merge lp:~ted/url-dispatcher/error-data
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+222363@code.launchpad.net

Commit message

Improving error messages and collecting more data

Description of the change

Trying to track down errors in updating the URL DB, but the errors didn't tell us what was wrong. The theory is that there's no tables, but odd considering that shouldn't happen. Asking Apport to pick up the data for us.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Nice small catch with dir_search in url_db_files_for_dir(), too

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/rules'
2--- debian/rules 2014-01-13 19:18:51 +0000
3+++ debian/rules 2014-06-06 16:13:36 +0000
4@@ -5,3 +5,11 @@
5
6 %:
7 dh $@ --fail-missing --with click
8+
9+override_dh_install:
10+ mkdir -p debian/url-dispatcher/usr/share/apport/package-hooks/
11+ install -m 644 debian/source_url-dispatcher.py debian/url-dispatcher/usr/share/apport/package-hooks/
12+ mkdir -p debian/url-dispatcher/etc/apport/crashdb.conf.d/
13+ install -m 644 debian/url-dispatcher-crashdb.conf debian/url-dispatcher/etc/apport/crashdb.conf.d/
14+ dh_install --fail-missing
15+
16
17=== added file 'debian/source_url-dispatcher.py'
18--- debian/source_url-dispatcher.py 1970-01-01 00:00:00 +0000
19+++ debian/source_url-dispatcher.py 2014-06-06 16:13:36 +0000
20@@ -0,0 +1,20 @@
21+import os.path
22+from xdg.BaseDirectory import xdg_cache_home
23+from apport.hookutils import *
24+
25+def attach_command_output(report, command_list, key):
26+ log = command_output(command_list)
27+ if not log or log[:5] == "Error":
28+ return
29+ report[key] = log
30+
31+def add_info(report):
32+ if not apport.packaging.is_distro_package(report['Package'].split()[0]):
33+ report['ThirdParty'] = 'True'
34+ report['CrashDB'] = 'url_dispatcher'
35+
36+ dbpath = os.path.join(xdg_cache_home, 'url-dispatcher', 'urls-1.db')
37+ if os.path.exists(dbpath):
38+ attach_command_output(report, ['sqlite3', dbpath, '.tables'], 'CacheDBTables')
39+ attach_command_output(report, ['sqlite3', dbpath, 'select * from urls'], 'CacheDBURLS')
40+ attach_command_output(report, ['sqlite3', dbpath, 'select * from configfiles'], 'CacheDBFiles')
41
42=== added file 'debian/url-dispatcher-crashdb.conf'
43--- debian/url-dispatcher-crashdb.conf 1970-01-01 00:00:00 +0000
44+++ debian/url-dispatcher-crashdb.conf 2014-06-06 16:13:36 +0000
45@@ -0,0 +1,6 @@
46+
47+url_dispatcher = {
48+ 'impl': 'launchpad',
49+ 'project': 'url-dispatcher',
50+ 'bug_pattern_base': None,
51+}
52
53=== modified file 'service/url-db.c'
54--- service/url-db.c 2014-03-14 19:48:28 +0000
55+++ service/url-db.c 2014-06-06 16:13:36 +0000
56@@ -52,7 +52,7 @@
57
58 open_status = sqlite3_open(dbfilename, &db);
59 if (open_status != SQLITE_OK) {
60- g_warning("Unable to open URL database");
61+ g_warning("Unable to open URL database: %s", sqlite3_errmsg(db));
62 g_free(dbfilename);
63 if (db != NULL) {
64 sqlite3_close(db);
65@@ -96,7 +96,7 @@
66 -1, /* length */
67 &stmt,
68 NULL) != SQLITE_OK) {
69- g_warning("Unable to parse SQL to get file times");
70+ g_warning("Unable to parse SQL to get file times: %s", sqlite3_errmsg(db));
71 return FALSE;
72 }
73
74@@ -136,7 +136,7 @@
75 -1, /* length */
76 &stmt,
77 NULL) != SQLITE_OK) {
78- g_warning("Unable to parse SQL to set file times");
79+ g_warning("Unable to parse SQL to set file times: %s", sqlite3_errmsg(db));
80 return FALSE;
81 }
82
83@@ -187,7 +187,7 @@
84 sqlite3_finalize(stmt);
85
86 if (exec_status != SQLITE_DONE) {
87- g_warning("Unable to execute insert");
88+ g_warning("Unable to execute insert: %s", sqlite3_errmsg(db));
89 return FALSE;
90 }
91
92@@ -210,7 +210,7 @@
93 -1, /* length */
94 &stmt,
95 NULL) != SQLITE_OK) {
96- g_warning("Unable to parse SQL to find url");
97+ g_warning("Unable to parse SQL to find url: %s", sqlite3_errmsg(db));
98 return NULL;
99 }
100
101@@ -238,7 +238,7 @@
102 sqlite3_finalize(stmt);
103
104 if (exec_status != SQLITE_DONE) {
105- g_warning("Unable to execute insert");
106+ g_warning("Unable to execute insert: %s", sqlite3_errmsg(db));
107 g_free(output);
108 return NULL;
109 }
110@@ -255,18 +255,17 @@
111 dir = "";
112 }
113
114+ sqlite3_stmt * stmt;
115+ if (sqlite3_prepare_v2(db,
116+ "select name from configfiles where name like ?1",
117+ -1, /* length */
118+ &stmt,
119+ NULL) != SQLITE_OK) {
120+ g_warning("Unable to parse SQL to find files: %s", sqlite3_errmsg(db));
121+ return NULL;
122+ }
123+
124 gchar * dir_search = g_strdup_printf("%s%%", dir);
125-
126- sqlite3_stmt * stmt;
127- if (sqlite3_prepare_v2(db,
128- "select name from configfiles where name like ?1",
129- -1, /* length */
130- &stmt,
131- NULL) != SQLITE_OK) {
132- g_warning("Unable to parse SQL to find files");
133- return NULL;
134- }
135-
136 sqlite3_bind_text(stmt, 1, dir_search, -1, SQLITE_TRANSIENT);
137
138 GList * filelist = NULL;
139@@ -280,7 +279,7 @@
140 g_free(dir_search);
141
142 if (exec_status != SQLITE_DONE) {
143- g_warning("Unable to execute insert");
144+ g_warning("Unable to execute insert: %s", sqlite3_errmsg(db));
145 g_list_free_full(filelist, g_free);
146 return NULL;
147 }
148@@ -299,7 +298,7 @@
149 /* Start a transaction so the database doesn't end up
150 in an inconsistent state */
151 if (sqlite3_exec(db, "begin", NULL, NULL, NULL) != SQLITE_OK) {
152- g_warning("Unable to start transaction to delete");
153+ g_warning("Unable to start transaction to delete: %s", sqlite3_errmsg(db));
154 return FALSE;
155 }
156
157@@ -310,7 +309,7 @@
158 -1, /* length */
159 &stmt,
160 NULL) != SQLITE_OK) {
161- g_warning("Unable to parse SQL to remove urls");
162+ g_warning("Unable to parse SQL to remove urls: %s", sqlite3_errmsg(db));
163 return FALSE;
164 }
165
166@@ -323,7 +322,7 @@
167 sqlite3_finalize(stmt);
168
169 if (exec_status != SQLITE_DONE) {
170- g_warning("Unable to execute removal of URLs");
171+ g_warning("Unable to execute removal of URLs: %s", sqlite3_errmsg(db));
172 return FALSE;
173 }
174
175@@ -335,7 +334,7 @@
176 -1, /* length */
177 &stmt,
178 NULL) != SQLITE_OK) {
179- g_warning("Unable to parse SQL to remove urls");
180+ g_warning("Unable to parse SQL to remove urls: %s", sqlite3_errmsg(db));
181 return FALSE;
182 }
183
184@@ -348,13 +347,13 @@
185 sqlite3_finalize(stmt);
186
187 if (exec_status != SQLITE_DONE) {
188- g_warning("Unable to execute removal of file");
189+ g_warning("Unable to execute removal of file: %s", sqlite3_errmsg(db));
190 return FALSE;
191 }
192
193 /* Commit the full transaction */
194 if (sqlite3_exec(db, "commit", NULL, NULL, NULL) != SQLITE_OK) {
195- g_warning("Unable to commit transaction to delete");
196+ g_warning("Unable to commit transaction to delete: %s", sqlite3_errmsg(db));
197 return FALSE;
198 }
199

Subscribers

People subscribed via source and target branches