diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-07 22:14:50 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-07 22:14:50 +0000 |
commit | bd2ccdb4a75327443251541be5a7d7b318de1f8d (patch) | |
tree | d79bd0671a90888787c8936e10b7148c8fc35a56 /sql | |
parent | b9dce9acfa651f215da2d7a1c76166b2ff55334e (diff) | |
download | chromium_src-bd2ccdb4a75327443251541be5a7d7b318de1f8d.zip chromium_src-bd2ccdb4a75327443251541be5a7d7b318de1f8d.tar.gz chromium_src-bd2ccdb4a75327443251541be5a7d7b318de1f8d.tar.bz2 |
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
Diffstat (limited to 'sql')
-rw-r--r-- | sql/connection.cc | 15 |
1 files changed, 15 insertions, 0 deletions
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 |