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

Unified Diff: sql/connection.cc

Issue 11468024: Add diagnostics to debug database open problems. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years 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 | no next file » | 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 1de9fc5cfa536c65fd2328640f5d6e4ec443a08f..99bc38173ee2daa7cb486abc2deddcd674a251a3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698