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

Unified Diff: chrome/browser/sync/syncable/directory_backing_store.cc

Issue 8496002: Sync: Improve handling of database load failures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Many improvements and scope expansion Created 9 years, 1 month 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
Index: chrome/browser/sync/syncable/directory_backing_store.cc
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc
index ed4242fd943695da86cd5285984c2f83cacfd4b2..c037ff09a9b01bdc3defe2d9582ad921ad9a4833 100644
--- a/chrome/browser/sync/syncable/directory_backing_store.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store.cc
@@ -236,7 +236,11 @@ bool DirectoryBackingStore::OpenAndConfigureHandleHelper(
bool DirectoryBackingStore::CheckIntegrity(sqlite3* handle, string* error)
const {
sqlite_utils::SQLStatement statement;
- statement.prepare(handle, "PRAGMA integrity_check(1)");
+ if (SQLITE_OK !=
+ statement.prepare(handle, "PRAGMA integrity_check(1)")) {
lipalani1 2011/11/14 21:34:24 We can add a UMA metric here.
rlarocque 2011/11/14 22:56:26 We could, but we'd probably end up taking it out i
+ *error = sqlite3_errmsg(handle);
+ return false;
+ }
if (SQLITE_ROW != statement.step()) {
*error = sqlite3_errmsg(handle);
return false;
@@ -289,37 +293,7 @@ DirOpenResult DirectoryBackingStore::Load(MetahandlesIndex* entry_bucket,
bool DirectoryBackingStore::BeginLoad() {
DCHECK(load_dbhandle_ == NULL);
- bool ret = OpenAndConfigureHandleHelper(&load_dbhandle_);
- if (ret)
- return true;
- // Something's gone wrong. Nuke the database and try again.
- using ::operator<<; // For string16.
- LOG(ERROR) << "Sync database " << backing_filepath_.value()
- << " corrupt. Deleting and recreating.";
- file_util::Delete(backing_filepath_, false);
- bool failed_again = !OpenAndConfigureHandleHelper(&load_dbhandle_);
-
- // Using failed_again here lets us distinguish from cases where corruption
- // occurred even when re-opening a fresh directory (they'll go in a separate
- // double weight histogram bucket). Failing twice in a row means we disable
- // sync, so it's useful to see this number separately.
- int bucket = failed_again ? 2 : 1;
-#if defined(OS_WIN)
- UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedWin", bucket);
Nicolas Zea 2011/11/14 19:29:21 Since I suppose these histograms don't make sense
rlarocque 2011/11/14 22:56:26 Done in a separate CL that also adds replacement h
-#elif defined(OS_MACOSX)
- UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedMac", bucket);
-#else
- UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedNotWinMac", bucket);
-
-#if defined(OS_CHROMEOS)
- UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedCros", bucket);
-#elif defined(OS_LINUX)
- UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedLinux", bucket);
-#else
- UMA_HISTOGRAM_COUNTS_100("Sync.DirectoryOpenFailedOther", bucket);
-#endif // OS_LINUX && !OS_CHROMEOS
-#endif // OS_WIN
- return !failed_again;
+ return OpenAndConfigureHandleHelper(&load_dbhandle_);
}
void DirectoryBackingStore::EndLoad() {

Powered by Google App Engine
This is Rietveld 408576698