From bd2ccdb4a75327443251541be5a7d7b318de1f8d Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Fri, 7 Dec 2012 22:14:50 +0000 Subject: Add diagnostics to debug database open problems. Currently the histograms are binned together for all errors, but knowing open-specific errors is helpful for dealing with problems on open. BUG=159490 Review URL: https://chromiumcodereview.appspot.com/11468024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171862 0039d316-1c4b-4281-b951-d872f2087c98 --- sql/connection.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'sql') diff --git a/sql/connection.cc b/sql/connection.cc index 1de9fc5..99bc381 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -8,6 +8,7 @@ #include "base/file_path.h" #include "base/logging.h" +#include "base/metrics/histogram.h" #include "base/string_util.h" #include "base/stringprintf.h" #include "base/utf_string_conversions.h" @@ -538,12 +539,26 @@ bool Connection::OpenInternal(const std::string& file_name) { int err = sqlite3_open(file_name.c_str(), &db_); if (err != SQLITE_OK) { + // Histogram failures specific to initial open for debugging + // purposes. + UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenFailure", err & 0xff, 50); + OnSqliteError(err, NULL); Close(); db_ = NULL; return false; } + // sqlite3_open() does not actually read the database file (unless a + // hot journal is found). Successfully executing this pragma on an + // existing database requires a valid header on page 1. + // TODO(shess): For now, just probing to see what the lay of the + // land is. If it's mostly SQLITE_NOTADB, then the database should + // be razed. + err = ExecuteAndReturnErrorCode("PRAGMA auto_vacuum"); + if (err != SQLITE_OK) + UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenProbeFailure", err & 0xff, 50); + // Enable extended result codes to provide more color on I/O errors. // Not having extended result codes is not a fatal problem, as // Chromium code does not attempt to handle I/O errors anyhow. The -- cgit v1.1