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

Issue 8496002: Sync: Improve handling of database load failures (Closed)

Created:
9 years, 1 month ago by rlarocque
Modified:
9 years, 1 month ago
CC:
chromium-reviews, Raghu Simha, ncarter (slow), akalin, tim (not reviewing)
Visibility:
Public.

Description

Sync: Improve handling of database load failures This failure path has not received a lot of testing until now. Here are the issues addressed by this patch: - We usually check the return value of step() calls. However, we do not check the return value of prepare() calls, which are more likely to fail. If they do fail, we will DCHECK() or go on to dereference an invalid pointer in step(). This patch checks the return value of one particular prepare statement, the one in CheckIntegrity(). - Disable DCHECKs on sqlite errors, DirectoryManager open failure, and SyncManager initialization failure. This will allow us to test these error paths. - Be careful in ShutdownOnSyncThread(). The directory will not be fully intialized during shutdown if the database load failed. - Add a ProfileSyncService unit test that simulates a load from an unreadable database. The harness had to be modified slightly to make this possible. - Remove a setup_for_test_mode_ flag in SyncManager::SyncInternal::Init. I don't know what the original intent of this flag was. However, I do know that it prevents me from properly simulating a database load failure and removing it seems to have no ill effects. - Do not delete the database from DirectoryBackingStore. If this code were to get executed it would put us into an inconsistent state. See issue 103824. However, it's unlikely this code would get executed. If the database were actually corrupt, we would DCHECK or de-reference an invalid pointer on our way to this code because we don't check the return value of the attempt to prepare an SQL statement in DirectoryBackingStore::CheckIntegrity(). - Modify the DirectoryBackingStoreTest.Corruption unit test to expect the new behaviour. - Disable sync when backend initialize fails. Such a failure could be due to bad local state. We don't know the actual cause because the information is not available from the ProfileSyncService callback. The safe course of action is to clear our local sync state and try again later. It's the easiest way to get back to the most well travelled sync initialization path. BUG=103307, 103824 TEST=DirectoryBackingStoreTest.Corruption, ProfileSyncServiceTest.CorruptDatabase Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=110177

Patch Set 1 #

Total comments: 6

Patch Set 2 : Many improvements and scope expansion #

Total comments: 10

Patch Set 3 : Review comment responses #

Patch Set 4 : Fix memory access bugs #

Unified diffs Side-by-side diffs Delta from patch set Stats (+84 lines, -72 lines) Patch
M chrome/browser/sync/glue/sync_backend_host.cc View 1 2 chunks +6 lines, -3 lines 0 comments Download
M chrome/browser/sync/internal_api/sync_manager.cc View 1 3 chunks +2 lines, -3 lines 0 comments Download
M chrome/browser/sync/profile_sync_service.cc View 1 2 3 1 chunk +9 lines, -4 lines 0 comments Download
M chrome/browser/sync/profile_sync_service_unittest.cc View 1 2 6 chunks +36 lines, -8 lines 0 comments Download
M chrome/browser/sync/syncable/directory_backing_store.cc View 1 2 3 3 chunks +27 lines, -42 lines 0 comments Download
M chrome/browser/sync/syncable/directory_backing_store_unittest.cc View 1 1 chunk +1 line, -9 lines 0 comments Download
M chrome/browser/sync/util/sqlite_utils.cc View 1 2 3 1 chunk +3 lines, -3 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
rlarocque
This change fixes some issues I ran into while working on code to verify the ...
9 years, 1 month ago (2011-11-08 02:25:00 UTC) #1
Nicolas Zea
Since you've removed these DCHECKS, could you now add some tests? I think profile_sync_service_unittest has ...
9 years, 1 month ago (2011-11-08 22:12:18 UTC) #2
rlarocque
I've addressed most of Nicolas' comments in the second patch set. I've also made this ...
9 years, 1 month ago (2011-11-11 22:24:56 UTC) #3
rlarocque
Nicolas was right to suggest I unit test my change. I discovered a few additional ...
9 years, 1 month ago (2011-11-11 22:39:17 UTC) #4
tim (not reviewing)
http://codereview.chromium.org/8496002/diff/4001/chrome/browser/sync/profile_sync_service.cc File chrome/browser/sync/profile_sync_service.cc (right): http://codereview.chromium.org/8496002/diff/4001/chrome/browser/sync/profile_sync_service.cc#newcode561 chrome/browser/sync/profile_sync_service.cc:561: DisableForUser(); Lets add a UMA counter here so we ...
9 years, 1 month ago (2011-11-14 19:13:13 UTC) #5
Nicolas Zea
LGTM with nits (and with the new histograms Tim mentions) http://codereview.chromium.org/8496002/diff/4001/chrome/browser/sync/profile_sync_service_unittest.cc File chrome/browser/sync/profile_sync_service_unittest.cc (right): http://codereview.chromium.org/8496002/diff/4001/chrome/browser/sync/profile_sync_service_unittest.cc#newcode310 ...
9 years, 1 month ago (2011-11-14 19:29:21 UTC) #6
lipalani1
lgtm couple of comments. http://codereview.chromium.org/8496002/diff/4001/chrome/browser/sync/internal_api/sync_manager.cc File chrome/browser/sync/internal_api/sync_manager.cc (left): http://codereview.chromium.org/8496002/diff/4001/chrome/browser/sync/internal_api/sync_manager.cc#oldcode805 chrome/browser/sync/internal_api/sync_manager.cc:805: if (signed_in || setup_for_test_mode_) { ...
9 years, 1 month ago (2011-11-14 21:34:24 UTC) #7
rlarocque
New patch uploaded. Let me know what you think about the new UMA names. I ...
9 years, 1 month ago (2011-11-14 22:56:26 UTC) #8
Nicolas Zea
UMA names lgtm
9 years, 1 month ago (2011-11-15 20:21:08 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rlarocque@chromium.org/8496002/9003
9 years, 1 month ago (2011-11-15 20:29:11 UTC) #10
commit-bot: I haz the power
Change committed as 110177
9 years, 1 month ago (2011-11-15 21:28:33 UTC) #11
rlarocque
9 years, 1 month ago (2011-11-15 22:58:24 UTC) #12
On 2011/11/15 21:28:33, I haz the power (commit-bot) wrote:
> Change committed as 110177

I had to revert this because of memory issues.  Patch set 4 shows the changes
I've made to attempt to fix it, but I don't think I'll be able to commit off of
this review anymore.  I will start a new review for the next attempt at this
change.

Powered by Google App Engine
This is Rietveld 408576698