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

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

Issue 10826194: sync: raise initial backoff interval from 1 second to 5 minutes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix typo Created 8 years, 4 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
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/sync_scheduler_impl.h" 5 #include "sync/engine/sync_scheduler_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 13 matching lines...) Expand all
24 using base::TimeTicks; 24 using base::TimeTicks;
25 25
26 namespace syncer { 26 namespace syncer {
27 27
28 using sessions::SyncSession; 28 using sessions::SyncSession;
29 using sessions::SyncSessionSnapshot; 29 using sessions::SyncSessionSnapshot;
30 using sessions::SyncSourceInfo; 30 using sessions::SyncSourceInfo;
31 using sync_pb::GetUpdatesCallerInfo; 31 using sync_pb::GetUpdatesCallerInfo;
32 32
33 namespace { 33 namespace {
34
35 // For integration tests only. Override initial backoff value.
36 // TODO(tim): Remove this egregiousness, use command line flag and plumb
37 // through. Done this way to reduce diffs in hotfix.
38 static bool g_force_immediate_retry = false;
rlarocque 2012/08/11 00:22:56 Discussed offline. I'll look forward to reviewing
39
34 bool ShouldRequestEarlyExit(const SyncProtocolError& error) { 40 bool ShouldRequestEarlyExit(const SyncProtocolError& error) {
35 switch (error.error_type) { 41 switch (error.error_type) {
36 case SYNC_SUCCESS: 42 case SYNC_SUCCESS:
37 case MIGRATION_DONE: 43 case MIGRATION_DONE:
38 case THROTTLED: 44 case THROTTLED:
39 case TRANSIENT_ERROR: 45 case TRANSIENT_ERROR:
40 return false; 46 return false;
41 case NOT_MY_BIRTHDAY: 47 case NOT_MY_BIRTHDAY:
42 case CLEAR_PENDING: 48 case CLEAR_PENDING:
43 // If we send terminate sync early then |sync_cycle_ended| notification 49 // If we send terminate sync early then |sync_cycle_ended| notification
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 &SyncSchedulerImpl::PollTimerCallback); 896 &SyncSchedulerImpl::PollTimerCallback);
891 } 897 }
892 898
893 void SyncSchedulerImpl::RestartWaiting() { 899 void SyncSchedulerImpl::RestartWaiting() {
894 CHECK(wait_interval_.get()); 900 CHECK(wait_interval_.get());
895 wait_interval_->timer.Stop(); 901 wait_interval_->timer.Stop();
896 wait_interval_->timer.Start(FROM_HERE, wait_interval_->length, 902 wait_interval_->timer.Start(FROM_HERE, wait_interval_->length,
897 this, &SyncSchedulerImpl::DoCanaryJob); 903 this, &SyncSchedulerImpl::DoCanaryJob);
898 } 904 }
899 905
906 namespace {
907 // TODO(tim): Move this function to syncer_error.h.
908 // Return true if the command in question was attempted and did not complete
909 // successfully.
910 bool IsError(SyncerError error) {
911 return error != UNSET && error != SYNCER_OK;
912 }
913 } // namespace
914
915 void SyncSchedulerImpl::ForceImmediateInitialBackoffRetry() {
916 g_force_immediate_retry = true;
917 }
918
919 TimeDelta SyncSchedulerImpl::GetInitialBackoffDelay(
rlarocque 2012/08/11 00:22:56 Although I don't know what the "right" place to pu
tim (not reviewing) 2012/08/11 00:43:58 Not sure I agree with that. Making it file-static
rlarocque 2012/08/11 00:58:33 That last suggestion sounds reasonable, but it's p
920 const sessions::ModelNeutralState& state) const {
921 // TODO(tim): Remove this, provide integration-test-only mechanism
922 // for override.
923 if (g_force_immediate_retry) {
924 return TimeDelta::FromSeconds(kInitialBackoffImmediateRetrySeconds);
925 }
926
927 if (IsError(state.last_get_key_result))
928 return TimeDelta::FromSeconds(kInitialBackoffRetrySeconds);
929 // Note: If we received a MIGRATION_DONE on download updates, then commit
930 // should not have taken place. Moreover, if we receive a MIGRATION_DONE
931 // on commit, it means that download updates succeeded. Therefore, we only
932 // need to check if either code is equal to SERVER_RETURN_MIGRATION_DONE,
933 // and not if there were any more serious errors requiring the long retry.
934 if (state.last_download_updates_result == SERVER_RETURN_MIGRATION_DONE ||
935 state.commit_result == SERVER_RETURN_MIGRATION_DONE) {
rlarocque 2012/08/11 00:22:56 What's the thinking behind checking the commit's r
tim (not reviewing) 2012/08/11 00:43:58 It is technically possible to get a migration done
rlarocque 2012/08/11 00:58:33 I suppose it's legal, but extremely unlikely. The
936 return TimeDelta::FromSeconds(kInitialBackoffImmediateRetrySeconds);
937 }
938
939 return TimeDelta::FromSeconds(kInitialBackoffRetrySeconds);
940 }
941
900 void SyncSchedulerImpl::HandleContinuationError( 942 void SyncSchedulerImpl::HandleContinuationError(
901 const SyncSessionJob& old_job) { 943 const SyncSessionJob& old_job) {
902 DCHECK_EQ(MessageLoop::current(), sync_loop_); 944 DCHECK_EQ(MessageLoop::current(), sync_loop_);
903 if (DCHECK_IS_ON()) { 945 if (DCHECK_IS_ON()) {
904 if (IsBackingOff()) { 946 if (IsBackingOff()) {
905 DCHECK(wait_interval_->timer.IsRunning() || old_job.is_canary_job); 947 DCHECK(wait_interval_->timer.IsRunning() || old_job.is_canary_job);
906 } 948 }
907 } 949 }
908 950
909 TimeDelta length = delay_provider_->GetDelay( 951 TimeDelta length = delay_provider_->GetDelay(
910 IsBackingOff() ? wait_interval_->length : TimeDelta::FromSeconds(1)); 952 IsBackingOff() ? wait_interval_->length :
953 GetInitialBackoffDelay(
954 old_job.session->status_controller().model_neutral_state()));
911 955
912 SDVLOG(2) << "In handle continuation error with " 956 SDVLOG(2) << "In handle continuation error with "
913 << SyncSessionJob::GetPurposeString(old_job.purpose) 957 << SyncSessionJob::GetPurposeString(old_job.purpose)
914 << " job. The time delta(ms) is " 958 << " job. The time delta(ms) is "
915 << length.InMilliseconds(); 959 << length.InMilliseconds();
916 960
917 // This will reset the had_nudge variable as well. 961 // This will reset the had_nudge variable as well.
918 wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF, 962 wait_interval_.reset(new WaitInterval(WaitInterval::EXPONENTIAL_BACKOFF,
919 length)); 963 length));
920 if (old_job.purpose == SyncSessionJob::CONFIGURATION) { 964 if (old_job.purpose == SyncSessionJob::CONFIGURATION) {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1147 1191
1148 #undef SDVLOG_LOC 1192 #undef SDVLOG_LOC
1149 1193
1150 #undef SDVLOG 1194 #undef SDVLOG
1151 1195
1152 #undef SLOG 1196 #undef SLOG
1153 1197
1154 #undef ENUM_CASE 1198 #undef ENUM_CASE
1155 1199
1156 } // namespace syncer 1200 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698