Bug 1401686 - Handle cases where max_post_bytes is less than max_record_payload_bytes. r=kitcambridge
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Wed, 20 Sep 2017 16:18:20 -0400
changeset 382011 5fa690493eaa3a6d7993bb2f46478e94b9385e6d
parent 382010 5340cb842af889e483abed2ee2edc0aeb9327ea3
child 382012 36d6f521c2b20ca63bfaf2bfdd3aaa656ea17424
push id51726
push usertchiovoloni@mozilla.com
push dateWed, 20 Sep 2017 23:18:32 +0000
treeherderautoland@5fa690493eaa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskitcambridge
bugs1401686
milestone57.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 1401686 - Handle cases where max_post_bytes is less than max_record_payload_bytes. r=kitcambridge MozReview-Commit-ID: AAiF2rD075A
services/sync/modules/record.js
services/sync/modules/service.js
--- a/services/sync/modules/record.js
+++ b/services/sync/modules/record.js
@@ -814,18 +814,19 @@ Collection.prototype = {
       max_post_records: getConfig("max_post_records", Infinity),
 
       max_batch_bytes: getConfig("max_total_bytes", Infinity),
       max_batch_records: getConfig("max_total_records", Infinity),
       max_record_payload_bytes: getConfig("max_record_payload_bytes", 256 * 1024),
     };
 
     if (config.max_post_bytes <= config.max_record_payload_bytes) {
-      this._log.error("Server configuration max_post_bytes is too low", config);
-      throw new Error("Server configuration max_post_bytes is too low");
+      this._log.warn("Server configuration max_post_bytes is too low for max_record_payload_bytes", config);
+      // Assume 4k of extra is enough. See also getMaxRecordPayloadSize in service.js
+      config.max_record_payload_bytes = config.max_post_bytes - 4096;
     }
 
     this._log.trace("new PostQueue created with config", config);
     return new PostQueue(poster, timestamp, config, log, postCallback);
   },
 };
 
 /* A helper to manage the posting of records while respecting the various
--- a/services/sync/modules/service.js
+++ b/services/sync/modules/service.js
@@ -620,17 +620,21 @@ Sync11Service.prototype = {
 
   getMaxRecordPayloadSize() {
     let config = this.serverConfiguration;
     if (!config || !config.max_record_payload_bytes) {
       this._log.warn("No config or incomplete config in getMaxRecordPayloadSize."
                      + " Are we running tests?");
       return 256 * 1024;
     }
-    return config.max_record_payload_bytes;
+    let payloadMax = config.max_record_payload_bytes;
+    if (config.max_post_bytes && payloadMax <= config.max_post_bytes) {
+      return config.max_post_bytes - 4096;
+    }
+    return payloadMax;
   },
 
   async verifyLogin(allow40XRecovery = true) {
     if (!this.identity.username) {
       this._log.warn("No username in verifyLogin.");
       this.status.login = LOGIN_FAILED_NO_USERNAME;
       return false;
     }