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

Side by Side Diff: components/sync/engine_impl/syncer_proto_util.cc

Issue 2475043002: [Sync] Sync client should to exponential backoff when receive partial failure (Closed)
Patch Set: review by self Created 4 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 unified diff | Download patch
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 "components/sync/engine_impl/syncer_proto_util.h" 5 #include "components/sync/engine_impl/syncer_proto_util.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 << "recent version."; 465 << "recent version.";
466 return SERVER_RETURN_UNKNOWN_ERROR; 466 return SERVER_RETURN_UNKNOWN_ERROR;
467 case SYNC_SUCCESS: 467 case SYNC_SUCCESS:
468 LogResponseProfilingData(*response); 468 LogResponseProfilingData(*response);
469 return SYNCER_OK; 469 return SYNCER_OK;
470 case THROTTLED: 470 case THROTTLED:
471 if (sync_protocol_error.error_data_types.Empty()) { 471 if (sync_protocol_error.error_data_types.Empty()) {
472 DLOG(WARNING) << "Client fully throttled by syncer."; 472 DLOG(WARNING) << "Client fully throttled by syncer.";
473 cycle->delegate()->OnThrottled(GetThrottleDelay(*response)); 473 cycle->delegate()->OnThrottled(GetThrottleDelay(*response));
474 } else { 474 } else {
475 // This is a spicial case, since server only throttle some of datatype,
Nicolas Zea 2016/11/09 00:21:25 typo: spicial -> special
Gang Wu 2016/11/10 21:56:51 Done.
476 // so can treat this case as partial failure.
475 DLOG(WARNING) << "Some types throttled by syncer."; 477 DLOG(WARNING) << "Some types throttled by syncer.";
476 cycle->delegate()->OnTypesThrottled( 478 cycle->delegate()->OnTypesThrottled(
477 sync_protocol_error.error_data_types, GetThrottleDelay(*response)); 479 sync_protocol_error.error_data_types, GetThrottleDelay(*response));
480 if (partial_failure_data_types != nullptr) {
481 *partial_failure_data_types = sync_protocol_error.error_data_types;
482 }
483 return SERVER_RETURN_PARTIAL_FAILURE;
478 } 484 }
479 return SERVER_RETURN_THROTTLED; 485 return SERVER_RETURN_THROTTLED;
480 case TRANSIENT_ERROR: 486 case TRANSIENT_ERROR:
481 return SERVER_RETURN_TRANSIENT_ERROR; 487 return SERVER_RETURN_TRANSIENT_ERROR;
482 case MIGRATION_DONE: 488 case MIGRATION_DONE:
483 LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) 489 LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size())
484 << "MIGRATION_DONE but no types specified."; 490 << "MIGRATION_DONE but no types specified.";
485 cycle->delegate()->OnReceivedMigrationRequest( 491 cycle->delegate()->OnReceivedMigrationRequest(
486 GetTypesToMigrate(*response)); 492 GetTypesToMigrate(*response));
487 return SERVER_RETURN_MIGRATION_DONE; 493 return SERVER_RETURN_MIGRATION_DONE;
488 case CLEAR_PENDING: 494 case CLEAR_PENDING:
489 return SERVER_RETURN_CLEAR_PENDING; 495 return SERVER_RETURN_CLEAR_PENDING;
490 case NOT_MY_BIRTHDAY: 496 case NOT_MY_BIRTHDAY:
491 return SERVER_RETURN_NOT_MY_BIRTHDAY; 497 return SERVER_RETURN_NOT_MY_BIRTHDAY;
492 case DISABLED_BY_ADMIN: 498 case DISABLED_BY_ADMIN:
493 return SERVER_RETURN_DISABLED_BY_ADMIN; 499 return SERVER_RETURN_DISABLED_BY_ADMIN;
494 case PARTIAL_FAILURE: 500 case PARTIAL_FAILURE:
495 // This only happens when partial throttling during GetUpdates. 501 // This only happens when partial backoff during GetUpdates.
496 if (!sync_protocol_error.error_data_types.Empty()) { 502 if (!sync_protocol_error.error_data_types.Empty()) {
497 DLOG(WARNING) << "Some types throttled by syncer during GetUpdates."; 503 DLOG(WARNING)
498 cycle->delegate()->OnTypesThrottled( 504 << "Some types got partial failure by syncer during GetUpdates.";
499 sync_protocol_error.error_data_types, GetThrottleDelay(*response)); 505 cycle->delegate()->OnTypesBackedOff(
506 sync_protocol_error.error_data_types);
500 } 507 }
501 if (partial_failure_data_types != nullptr) { 508 if (partial_failure_data_types != nullptr) {
502 *partial_failure_data_types = sync_protocol_error.error_data_types; 509 *partial_failure_data_types = sync_protocol_error.error_data_types;
503 } 510 }
504 return SERVER_RETURN_PARTIAL_FAILURE; 511 return SERVER_RETURN_PARTIAL_FAILURE;
505 case CLIENT_DATA_OBSOLETE: 512 case CLIENT_DATA_OBSOLETE:
506 return SERVER_RETURN_CLIENT_DATA_OBSOLETE; 513 return SERVER_RETURN_CLIENT_DATA_OBSOLETE;
507 default: 514 default:
508 NOTREACHED(); 515 NOTREACHED();
509 return UNSET; 516 return UNSET;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 std::string SyncerProtoUtil::ClientToServerResponseDebugString( 601 std::string SyncerProtoUtil::ClientToServerResponseDebugString(
595 const ClientToServerResponse& response) { 602 const ClientToServerResponse& response) {
596 // Add more handlers as needed. 603 // Add more handlers as needed.
597 std::string output; 604 std::string output;
598 if (response.has_get_updates()) 605 if (response.has_get_updates())
599 output.append(GetUpdatesResponseString(response.get_updates())); 606 output.append(GetUpdatesResponseString(response.get_updates()));
600 return output; 607 return output;
601 } 608 }
602 609
603 } // namespace syncer 610 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698