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

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

Issue 8570016: Revert 110177 - Sync: Improve handling of database load failures (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
===================================================================
--- chrome/browser/sync/syncable/directory_backing_store.cc (revision 110181)
+++ chrome/browser/sync/syncable/directory_backing_store.cc (working copy)
@@ -236,11 +236,7 @@
bool DirectoryBackingStore::CheckIntegrity(sqlite3* handle, string* error)
const {
sqlite_utils::SQLStatement statement;
- if (SQLITE_OK !=
- statement.prepare(handle, "PRAGMA integrity_check(1)")) {
- *error = sqlite3_errmsg(handle);
- return false;
- }
+ statement.prepare(handle, "PRAGMA integrity_check(1)");
if (SQLITE_ROW != statement.step()) {
*error = sqlite3_errmsg(handle);
return false;
@@ -293,7 +289,37 @@
bool DirectoryBackingStore::BeginLoad() {
DCHECK(load_dbhandle_ == NULL);
- return OpenAndConfigureHandleHelper(&load_dbhandle_);
+ 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);
+#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;
}
void DirectoryBackingStore::EndLoad() {
« no previous file with comments | « chrome/browser/sync/profile_sync_service_unittest.cc ('k') | chrome/browser/sync/syncable/directory_backing_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698