summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-24 05:04:28 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-24 05:04:28 +0000
commit73fb8d575817052e106927064f5046a3606fe4ca (patch)
tree61fb4b52c7cf5b596e84faadfc7c935ab8435dbf
parentdf113a1ba533568769a3154dc63fdd62818b8200 (diff)
downloadchromium_src-73fb8d575817052e106927064f5046a3606fe4ca.zip
chromium_src-73fb8d575817052e106927064f5046a3606fe4ca.tar.gz
chromium_src-73fb8d575817052e106927064f5046a3606fe4ca.tar.bz2
[sql] Cleanup open and close error histograms.
Cleanup open-time histograms to use the sparse framework so that extended histograms can be recorded - also add entries to the xml file. Add a histogram to track close-time failures. This should never fail, but if it is it probably leaks memory and file handles, and possibly locks. BUG=none Review URL: https://chromiumcodereview.appspot.com/18978012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213345 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--sql/connection.cc32
-rw-r--r--tools/metrics/histograms/histograms.xml12
2 files changed, 32 insertions, 12 deletions
diff --git a/sql/connection.cc b/sql/connection.cc
index c10f5a7..3bc2545 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -272,8 +272,12 @@ void Connection::CloseInternal(bool forced) {
// TODO(paivanof@gmail.com): This should move to the beginning
// of the function. http://crbug.com/136655.
AssertIOAllowed();
- // TODO(shess): Histogram for failure.
- sqlite3_close(db_);
+
+ int rc = sqlite3_close(db_);
+ if (rc != SQLITE_OK) {
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.CloseFailure", rc);
+ DLOG(FATAL) << "sqlite3_close failed: " << GetErrorMessage();
+ }
}
db_ = NULL;
}
@@ -829,9 +833,13 @@ bool Connection::OpenInternal(const std::string& file_name,
int err = sqlite3_open(file_name.c_str(), &db_);
if (err != SQLITE_OK) {
+ // Extended error codes cannot be enabled until a handle is
+ // available, fetch manually.
+ err = sqlite3_extended_errcode(db_);
+
// Histogram failures specific to initial open for debugging
// purposes.
- UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenFailure", err & 0xff, 50);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenFailure", err);
OnSqliteError(err, NULL);
bool was_poisoned = poisoned_;
@@ -873,6 +881,14 @@ bool Connection::OpenInternal(const std::string& file_name,
// statements are run.
sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0);
+ // 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
+ // current implementation always returns SQLITE_OK, the DCHECK is to
+ // quickly notify someone if SQLite changes.
+ err = sqlite3_extended_result_codes(db_, 1);
+ DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes";
+
// 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.
@@ -881,15 +897,7 @@ bool Connection::OpenInternal(const std::string& file_name,
// 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
- // current implementation always returns SQLITE_OK, the DCHECK is to
- // quickly notify someone if SQLite changes.
- err = sqlite3_extended_result_codes(db_, 1);
- DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes";
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenProbeFailure", err);
#if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE)
// The version of SQLite shipped with iOS doesn't enable ICU, which includes
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index c18ab7b..e428ca6 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -13079,6 +13079,10 @@ other types of suffix sets.
<summary>Error codes returned by sqlite for the appcache db.</summary>
</histogram>
+<histogram name="Sqlite.CloseFailure" enum="SqliteErrorCode">
+ <summary>Error which prevented database close.</summary>
+</histogram>
+
<histogram name="Sqlite.Cookie.Error" enum="SqliteErrorCode">
<summary>Error codes returned by sqlite the cookie db.</summary>
</histogram>
@@ -13112,6 +13116,14 @@ other types of suffix sets.
<summary>Error codes returned by sqlite for the history db.</summary>
</histogram>
+<histogram name="Sqlite.OpenFailure" enum="SqliteErrorCode">
+ <summary>Error which prevented database open.</summary>
+</histogram>
+
+<histogram name="Sqlite.OpenProbeFailure" enum="SqliteErrorCode">
+ <summary>Error from first read of the database.</summary>
+</histogram>
+
<histogram name="Sqlite.Quota.Error" enum="SqliteErrorCode">
<summary>Error codes returned by sqlite for the quota db.</summary>
</histogram>