* debuginfod-client.c (debuginfod_query_server): Initialize
struct handle_data errbuf to the empty string.
+2020-11-23 Frank Ch. Eigler <fche@redhat.com>
+
+ * debuginfod.cxx (tmp_ms_metric): New class for RAII timing metrics.
+ (sqlite_ps::reset, step*): Call it to track sqlite3 performance.
+ (sqlite_exception ctor): Increment sqlite3 error_count.
+
2020-11-11 Mark Wielaard <mark@klomp.org>
* debuginfod-client.c (debuginfod_set_verbose_fd): New function.
}
};
+class tmp_ms_metric { // a RAII style wrapper for exception-safe scoped timing
+ string m, n, v;
+ struct timeval tv_start;
+public:
+ tmp_ms_metric(const string& mname, const string& lname, const string& lvalue):
+ m(mname), n(lname), v(lvalue)
+ {
+ gettimeofday (& tv_start, NULL);
+ }
+ ~tmp_ms_metric()
+ {
+ struct timeval tv_end;
+ gettimeofday (& tv_end, NULL);
+ double deltas = (tv_end.tv_sec - tv_start.tv_sec)
+ + (tv_end.tv_usec - tv_start.tv_usec)*0.000001;
+
+ add_metric (m + "_milliseconds_sum", n, v, (deltas*1000));
+ inc_metric (m + "_milliseconds_count", n, v);
+ }
+};
+
/* Handle program arguments. */
static error_t
struct sqlite_exception: public reportable_exception
{
sqlite_exception(int rc, const string& msg):
- reportable_exception(string("sqlite3 error: ") + msg + ": " + string(sqlite3_errstr(rc) ?: "?")) {}
+ reportable_exception(string("sqlite3 error: ") + msg + ": " + string(sqlite3_errstr(rc) ?: "?")) {
+ inc_metric("error_count","sqlite3",sqlite3_errstr(rc));
+ }
};
struct libc_exception: public reportable_exception
public:
sqlite_ps (sqlite3* d, const string& n, const string& s): db(d), nickname(n), sql(s) {
+ // tmp_ms_metric tick("sqlite3","prep",nickname);
if (verbose > 4)
obatched(clog) << nickname << " prep " << sql << endl;
int rc = sqlite3_prepare_v2 (db, sql.c_str(), -1 /* to \0 */, & this->pp, NULL);
sqlite_ps& reset()
{
+ tmp_ms_metric tick("sqlite3","reset",nickname);
sqlite3_reset(this->pp);
return *this;
}
void step_ok_done() {
+ tmp_ms_metric tick("sqlite3","step-done",nickname);
int rc = sqlite3_step (this->pp);
if (verbose > 4)
obatched(clog) << nickname << " step-ok-done(" << sqlite3_errstr(rc) << ") " << sql << endl;
int step() {
+ tmp_ms_metric tick("sqlite3","step",nickname);
int rc = sqlite3_step (this->pp);
if (verbose > 4)
obatched(clog) << nickname << " step(" << sqlite3_errstr(rc) << ") " << sql << endl;
return rc;
}
-
-
~sqlite_ps () { sqlite3_finalize (this->pp); }
operator sqlite3_stmt* () { return this->pp; }
};
########################################################################
+# Corrupt the sqlite database and get debuginfod to trip across its errors
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'sqlite3.*reset'
+ls -al $DB
+dd if=/dev/zero of=$DB bs=1 count=1
+ls -al $DB
+# trigger some random activity that's Sure to get sqlite3 upset
+kill -USR1 $PID1
+wait_ready $PORT1 'thread_work_total{role="traverse"}' 9
+wait_ready $PORT1 'thread_work_pending{role="scan"}' 0
+wait_ready $PORT1 'thread_busy{role="scan"}' 0
+kill -USR2 $PID1
+wait_ready $PORT1 'thread_work_total{role="groom"}' 4
+curl -s http://127.0.0.1:$PORT1/buildid/beefbeefbeefd00dd00d/debuginfo > /dev/null || true
+curl -s http://127.0.0.1:$PORT1/metrics | grep 'error_count.*sqlite'
+
+########################################################################
# Run the tests again without the servers running. The target file should
# be found in the cache.