Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: sql/connection.cc

Issue 18978012: [sql] Cleanup open and close error histograms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-cl-upload said I should do so. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index 4550b0e5569304a75e77ef8a58298304fa7b2c1d..9836a06df413f59e62b3467cdd6d626bdacd33cf 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -256,8 +256,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;
}
@@ -810,9 +814,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_;
@@ -854,6 +862,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.
@@ -862,15 +878,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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698