Remove redundant failure delay handling in sync engine
The API client now automatically retries 5xx errors with a backoff schedule, so the engine doesn't need to do it.
This commit is contained in:
parent
a78f923a72
commit
8ba9fe7b80
|
@ -29,7 +29,6 @@ if (!Zotero.Sync.Data) {
|
||||||
|
|
||||||
// TODO: move?
|
// TODO: move?
|
||||||
Zotero.Sync.Data.conflictDelayIntervals = [10000, 20000, 40000, 60000, 120000, 240000, 300000];
|
Zotero.Sync.Data.conflictDelayIntervals = [10000, 20000, 40000, 60000, 120000, 240000, 300000];
|
||||||
Zotero.Sync.Data.failureDelayIntervals = [2500, 5000, 10000, 20000, 40000, 60000, 120000, 240000, 300000];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Engine manages sync processes for a given library
|
* An Engine manages sync processes for a given library
|
||||||
|
@ -827,8 +826,6 @@ Zotero.Sync.Data.Engine.prototype._startUpload = Zotero.Promise.coroutine(functi
|
||||||
|
|
||||||
|
|
||||||
Zotero.Sync.Data.Engine.prototype._uploadSettings = Zotero.Promise.coroutine(function* (settings, libraryVersion) {
|
Zotero.Sync.Data.Engine.prototype._uploadSettings = Zotero.Promise.coroutine(function* (settings, libraryVersion) {
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
let json = {};
|
let json = {};
|
||||||
for (let key in settings) {
|
for (let key in settings) {
|
||||||
json[key] = {
|
json[key] = {
|
||||||
|
@ -846,36 +843,7 @@ Zotero.Sync.Data.Engine.prototype._uploadSettings = Zotero.Promise.coroutine(fun
|
||||||
Object.keys(settings),
|
Object.keys(settings),
|
||||||
libraryVersion
|
libraryVersion
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
if (e instanceof Zotero.HTTP.UnexpectedStatusException) {
|
|
||||||
if (e.status == 412) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On 5xx, delay and retry
|
|
||||||
if (e.status >= 500 && e.status <= 600) {
|
|
||||||
if (!failureDelayGenerator) {
|
|
||||||
// Keep trying for up to an hour
|
|
||||||
failureDelayGenerator = Zotero.Utilities.Internal.delayGenerator(
|
|
||||||
Zotero.Sync.Data.failureDelayIntervals, 60 * 60 * 1000
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let keepGoing = yield failureDelayGenerator.next();
|
|
||||||
if (!keepGoing) {
|
|
||||||
Zotero.logError("Failed too many times");
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Zotero.debug("Done uploading settings in " + this.library.name);
|
Zotero.debug("Done uploading settings in " + this.library.name);
|
||||||
|
|
||||||
return libraryVersion;
|
return libraryVersion;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -894,8 +862,6 @@ Zotero.Sync.Data.Engine.prototype._uploadObjects = Zotero.Promise.coroutine(func
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let failureDelayGenerator = null;
|
|
||||||
|
|
||||||
while (queue.length) {
|
while (queue.length) {
|
||||||
// Get a slice of the queue and generate JSON for objects if necessary
|
// Get a slice of the queue and generate JSON for objects if necessary
|
||||||
let batch = [];
|
let batch = [];
|
||||||
|
@ -1049,10 +1015,7 @@ Zotero.Sync.Data.Engine.prototype._uploadDeletions = Zotero.Promise.coroutine(fu
|
||||||
let objectTypePlural = Zotero.DataObjectUtilities.getObjectTypePlural(objectType);
|
let objectTypePlural = Zotero.DataObjectUtilities.getObjectTypePlural(objectType);
|
||||||
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
let objectsClass = Zotero.DataObjectUtilities.getObjectsClassForObjectType(objectType);
|
||||||
|
|
||||||
let failureDelayGenerator = null;
|
|
||||||
|
|
||||||
while (keys.length) {
|
while (keys.length) {
|
||||||
try {
|
|
||||||
let batch = keys.slice(0, this.uploadDeletionBatchSize);
|
let batch = keys.slice(0, this.uploadDeletionBatchSize);
|
||||||
libraryVersion = yield this.apiClient.uploadDeletions(
|
libraryVersion = yield this.apiClient.uploadDeletions(
|
||||||
this.library.libraryType,
|
this.library.libraryType,
|
||||||
|
@ -1072,38 +1035,6 @@ Zotero.Sync.Data.Engine.prototype._uploadDeletions = Zotero.Promise.coroutine(fu
|
||||||
objectType, this.libraryID, batch
|
objectType, this.libraryID, batch
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch (e) {
|
|
||||||
if (e instanceof Zotero.HTTP.UnexpectedStatusException) {
|
|
||||||
if (e.status == 412) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
// On 5xx, delay and retry
|
|
||||||
if (e.status >= 500 && e.status <= 600) {
|
|
||||||
if (this.onError) {
|
|
||||||
this.onError(e);
|
|
||||||
}
|
|
||||||
if (this.stopOnError) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!failureDelayGenerator) {
|
|
||||||
// Keep trying for up to an hour
|
|
||||||
failureDelayGenerator = Zotero.Utilities.Internal.delayGenerator(
|
|
||||||
Zotero.Sync.Data.failureDelayIntervals, 60 * 60 * 1000
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let keepGoing = yield failureDelayGenerator.next();
|
|
||||||
if (!keepGoing) {
|
|
||||||
Zotero.logError("Failed too many times");
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Zotero.debug(`Done uploading ${objectType} deletions in ${this.library.name}`);
|
Zotero.debug(`Done uploading ${objectType} deletions in ${this.library.name}`);
|
||||||
|
|
||||||
return libraryVersion;
|
return libraryVersion;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user