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 |