Bug 1415012 - Don't trigger a resync if the previous sync wasn't completely successful r=kitcambridge
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Mon, 06 Nov 2017 20:56:57 -0500
changeset 443814 5e887aadb923fc933cc09d500c01c540791a76da
parent 443813 8823f33351025e25a949160bc23bae9fba9aac5f
child 443815 deaf42e9dbecacba453afa921cad45f3dfeebc6c
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge
bugs1415012
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415012 - Don't trigger a resync if the previous sync wasn't completely successful r=kitcambridge MozReview-Commit-ID: DcNsFUxXR1O
services/sync/modules/policies.js
services/sync/tests/unit/test_syncscheduler.js
--- a/services/sync/modules/policies.js
+++ b/services/sync/modules/policies.js
@@ -170,17 +170,17 @@ SyncScheduler.prototype = {
         if (Status.service == SYNC_FAILED_PARTIAL && this.requiresBackoff) {
           this.requiresBackoff = false;
           this.handleSyncError();
           return;
         }
 
         let sync_interval;
         this.updateGlobalScore();
-        if (this.globalScore > 0) {
+        if (this.globalScore > 0 && Status.service == STATUS_OK) {
           // The global score should be 0 after a sync. If it's not, items were
           // changed during the last sync, and we should schedule an immediate
           // follow-up sync.
           this._resyncs++;
           if (this._resyncs <= this.maxResyncs) {
             sync_interval = 0;
           } else {
             this._log.warn(`Resync attempt ${this._resyncs} exceeded ` +
--- a/services/sync/tests/unit/test_syncscheduler.js
+++ b/services/sync/tests/unit/test_syncscheduler.js
@@ -751,16 +751,47 @@ add_task(async function test_sync_failed
   do_check_true(Status.enforceBackoff);
   do_check_eq(scheduler._syncErrors, 4);
   do_check_true(scheduler.nextSync <= (Date.now() + maxInterval));
   do_check_true(scheduler.syncTimer.delay <= maxInterval);
 
   await cleanUpAndGo(server);
 });
 
+add_task(async function test_sync_failed_partial_noresync() {
+  enableValidationPrefs();
+  let server = sync_httpd_setup();
+
+  let engine = Service.engineManager.get("catapult");
+  engine.enabled = true;
+  engine.exception = "Bad news";
+  engine._tracker._score = 10;
+
+  do_check_eq(Status.sync, SYNC_SUCCEEDED);
+
+  do_check_true(await setUp(server));
+
+  let resyncDoneObserver = promiseOneObserver("weave:service:resyncs-finished");
+
+  await Service.sync();
+
+  do_check_eq(Status.service, SYNC_FAILED_PARTIAL);
+
+  function onSyncStarted() {
+    do_throw("Should not start resync when previous sync failed");
+  }
+
+  Svc.Obs.add("weave:service:sync:start", onSyncStarted);
+  await resyncDoneObserver;
+
+  Svc.Obs.remove("weave:service:sync:start", onSyncStarted);
+  engine._tracker._store = 0;
+  await cleanUpAndGo(server);
+});
+
 add_task(async function test_sync_failed_partial_400s() {
   enableValidationPrefs();
 
   _("Test a non-5xx status doesn't call handleSyncError.");
   scheduler._syncErrors = MAX_ERROR_COUNT_BEFORE_BACKOFF;
   let server = sync_httpd_setup();
 
   let engine = Service.engineManager.get("catapult");