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

Side by Side Diff: sync/engine/syncer.cc

Issue 10006046: Abort sync cycles when download step fails (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Retry on migration done responses Created 8 years, 8 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sync/engine/sync_scheduler.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/engine/syncer.h" 5 #include "sync/engine/syncer.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 SyncerStep current_step = first_step; 103 SyncerStep current_step = first_step;
104 104
105 SyncerStep next_step = current_step; 105 SyncerStep next_step = current_step;
106 while (!ExitRequested()) { 106 while (!ExitRequested()) {
107 TRACE_EVENT1("sync", "SyncerStateMachine", 107 TRACE_EVENT1("sync", "SyncerStateMachine",
108 "state", SyncerStepToString(current_step)); 108 "state", SyncerStepToString(current_step));
109 DVLOG(1) << "Syncer step:" << SyncerStepToString(current_step); 109 DVLOG(1) << "Syncer step:" << SyncerStepToString(current_step);
110 110
111 switch (current_step) { 111 switch (current_step) {
112 case SYNCER_BEGIN: 112 case SYNCER_BEGIN:
113 // This isn't perfect, as we can end up bundling extensions activity
114 // intended for the next session into the current one. We could do a
115 // test-and-reset as with the source, but note that also falls short if
116 // the commit request fails (e.g. due to lost connection), as we will
117 // fall all the way back to the syncer thread main loop in that case,
118 // creating a new session when a connection is established, losing the
119 // records set here on the original attempt. This should provide us
120 // with the right data "most of the time", and we're only using this
121 // for analysis purposes, so Law of Large Numbers FTW.
122 session->context()->extensions_monitor()->GetAndClearRecords(
123 session->mutable_extensions_activity());
124 session->context()->PruneUnthrottledTypes(base::TimeTicks::Now()); 113 session->context()->PruneUnthrottledTypes(base::TimeTicks::Now());
125 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN); 114 session->SendEventNotification(SyncEngineEvent::SYNC_CYCLE_BEGIN);
126 115
127 next_step = CLEANUP_DISABLED_TYPES; 116 next_step = CLEANUP_DISABLED_TYPES;
128 break; 117 break;
129 case CLEANUP_DISABLED_TYPES: { 118 case CLEANUP_DISABLED_TYPES: {
130 CleanupDisabledTypesCommand cleanup; 119 CleanupDisabledTypesCommand cleanup;
131 cleanup.Execute(session); 120 cleanup.Execute(session);
132 next_step = DOWNLOAD_UPDATES; 121 next_step = DOWNLOAD_UPDATES;
133 break; 122 break;
(...skipping 25 matching lines...) Expand all
159 } 148 }
160 case PROCESS_UPDATES: { 149 case PROCESS_UPDATES: {
161 ProcessUpdatesCommand process_updates; 150 ProcessUpdatesCommand process_updates;
162 process_updates.Execute(session); 151 process_updates.Execute(session);
163 next_step = STORE_TIMESTAMPS; 152 next_step = STORE_TIMESTAMPS;
164 break; 153 break;
165 } 154 }
166 case STORE_TIMESTAMPS: { 155 case STORE_TIMESTAMPS: {
167 StoreTimestampsCommand store_timestamps; 156 StoreTimestampsCommand store_timestamps;
168 store_timestamps.Execute(session); 157 store_timestamps.Execute(session);
169 // We should download all of the updates before attempting to process 158 // We download all of the updates before attempting to apply them.
170 // them. 159 if (!session->status_controller().download_updates_succeeded()) {
171 if (session->status_controller().ServerSaysNothingMoreToDownload() || 160 // We may have downloaded some updates, but if the latest download
172 !session->status_controller().download_updates_succeeded()) { 161 // attempt failed then we don't have all the updates. We'll leave
162 // it to a retry job to pick up where we left off.
163 last_step = SYNCER_END; // Necessary for CONFIGURATION mode.
164 next_step = SYNCER_END;
165 DVLOG(1) << "Aborting sync cycle due to download updates failure";
166 } else if (!session->status_controller()
167 .ServerSaysNothingMoreToDownload()) {
168 next_step = DOWNLOAD_UPDATES;
169 } else {
173 next_step = APPLY_UPDATES; 170 next_step = APPLY_UPDATES;
174 } else {
175 next_step = DOWNLOAD_UPDATES;
176 } 171 }
177 break; 172 break;
178 } 173 }
179 case APPLY_UPDATES: { 174 case APPLY_UPDATES: {
180 ApplyUpdatesCommand apply_updates; 175 ApplyUpdatesCommand apply_updates;
181 apply_updates.Execute(session); 176 apply_updates.Execute(session);
182 if (last_step == APPLY_UPDATES) { 177 if (last_step == APPLY_UPDATES) {
183 // We're in configuration mode, but we still need to run the 178 // We're in configuration mode, but we still need to run the
184 // SYNCER_END step. 179 // SYNCER_END step.
185 last_step = SYNCER_END; 180 last_step = SYNCER_END;
(...skipping 10 matching lines...) Expand all
196 WriteTransaction trans(FROM_HERE, SYNCER, dir); 191 WriteTransaction trans(FROM_HERE, SYNCER, dir);
197 sessions::ScopedSetSessionWriteTransaction set_trans(session, &trans); 192 sessions::ScopedSetSessionWriteTransaction set_trans(session, &trans);
198 193
199 DVLOG(1) << "Getting the Commit IDs"; 194 DVLOG(1) << "Getting the Commit IDs";
200 GetCommitIdsCommand get_commit_ids_command( 195 GetCommitIdsCommand get_commit_ids_command(
201 session->context()->max_commit_batch_size()); 196 session->context()->max_commit_batch_size());
202 get_commit_ids_command.Execute(session); 197 get_commit_ids_command.Execute(session);
203 198
204 if (!session->status_controller().commit_ids().empty()) { 199 if (!session->status_controller().commit_ids().empty()) {
205 DVLOG(1) << "Building a commit message"; 200 DVLOG(1) << "Building a commit message";
201
202 // This isn't perfect, since the set of extensions activity may not
203 // correlate exactly with the items being committed. That's OK as
204 // long as we're looking for a rough estimate of extensions activity,
205 // not an precise mapping of which commits were triggered by which
206 // extension.
207 //
208 // We will push this list of extensions activity back into the
209 // ExtensionsActivityMonitor if this commit turns out to not contain
210 // any bookmarks, or if the commit fails.
211 session->context()->extensions_monitor()->GetAndClearRecords(
212 session->mutable_extensions_activity());
213
206 BuildCommitCommand build_commit_command; 214 BuildCommitCommand build_commit_command;
207 build_commit_command.Execute(session); 215 build_commit_command.Execute(session);
208 216
209 next_step = POST_COMMIT_MESSAGE; 217 next_step = POST_COMMIT_MESSAGE;
210 } else { 218 } else {
211 next_step = RESOLVE_CONFLICTS; 219 next_step = RESOLVE_CONFLICTS;
212 } 220 }
213 221
214 break; 222 break;
215 } 223 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 entry->Put(SERVER_CTIME, Time()); 344 entry->Put(SERVER_CTIME, Time());
337 entry->Put(SERVER_VERSION, 0); 345 entry->Put(SERVER_VERSION, 0);
338 entry->Put(SERVER_IS_DIR, false); 346 entry->Put(SERVER_IS_DIR, false);
339 entry->Put(SERVER_IS_DEL, false); 347 entry->Put(SERVER_IS_DEL, false);
340 entry->Put(IS_UNAPPLIED_UPDATE, false); 348 entry->Put(IS_UNAPPLIED_UPDATE, false);
341 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); 349 entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance());
342 entry->Put(SERVER_POSITION_IN_PARENT, 0); 350 entry->Put(SERVER_POSITION_IN_PARENT, 0);
343 } 351 }
344 352
345 } // namespace browser_sync 353 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/engine/sync_scheduler.cc ('k') | sync/engine/syncer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698