remove the delay before requeueing 'error==TIMEOUT' tiles. it's not needed (stock site has no delay), and the other delay (before processing the queue again) has more than enough effect to batch multiple retries together when it's useful

This commit is contained in:
Jon Atkins 2013-10-25 08:01:45 +01:00
parent 8270812406
commit d268b0a79f

View File

@ -42,8 +42,7 @@ window.MapDataRequest = function() {
// this gives a chance of other requests finishing, allowing better grouping of retries in new requests // this gives a chance of other requests finishing, allowing better grouping of retries in new requests
this.RUN_QUEUE_DELAY = 0.5; this.RUN_QUEUE_DELAY = 0.5;
// delay before re-queueing tiles // delay before re-queueing tiles in failed requests
this.TILE_TIMEOUT_REQUEUE_DELAY = 0.2; // short delay before retrying a 'error==TIMEOUT' tile. a common 'error', and the stock site has no delay in this case
this.BAD_REQUEST_REQUEUE_DELAY = 5; // longer delay before retrying a completely failed request - as in this case the servers are struggling this.BAD_REQUEST_REQUEUE_DELAY = 5; // longer delay before retrying a completely failed request - as in this case the servers are struggling
// a delay before processing the queue after requeueing tiles. this gives a chance for other requests to finish // a delay before processing the queue after requeueing tiles. this gives a chance for other requests to finish
@ -513,7 +512,6 @@ window.MapDataRequest.prototype.handleResponse = function (data, tiles, success)
if (val.error == "TIMEOUT") { if (val.error == "TIMEOUT") {
// TIMEOUT errors for individual tiles are 'expected'(!) - and result in a silent unlimited retries // TIMEOUT errors for individual tiles are 'expected'(!) - and result in a silent unlimited retries
timeoutTiles.push (id); timeoutTiles.push (id);
this.debugTiles.setState (id, 'tile-timeout');
} else { } else {
console.warn('map data tile '+id+' failed: error=='+val.error); console.warn('map data tile '+id+' failed: error=='+val.error);
errorTiles.push (id); errorTiles.push (id);
@ -588,21 +586,20 @@ console.log('processed delta mapData request:'+id+': '+oldEntityCount+' original
console.log ('getThinnedEntities status: '+tiles.length+' tiles: '+successTiles.length+' successful, '+timeoutTiles.length+' timed out, '+errorTiles.length+' failed'); console.log ('getThinnedEntities status: '+tiles.length+' tiles: '+successTiles.length+' successful, '+timeoutTiles.length+' timed out, '+errorTiles.length+' failed');
//setTimeout has no way of passing the 'context' (aka 'this') to it's function // requeue any 'timeout' tiles immediately
var savedContext = this;
if (timeoutTiles.length > 0) { if (timeoutTiles.length > 0) {
setTimeout (function() { for (var i in timeoutTiles) {
for (var i in timeoutTiles) { var id = timeoutTiles[i];
var id = timeoutTiles[i]; delete this.requestedTiles[id];
delete savedContext.requestedTiles[id]; this.requeueTile(id, false);
savedContext.requeueTile(id, false); }
}
savedContext.delayProcessRequestQueue(this.REQUEUE_DELAY);
}, this.TILE_TIMEOUT_REQUEUE_DELAY*1000);
} }
// but for other errors, delay before retrying (as the server is having issues)
if (errorTiles.length > 0) { if (errorTiles.length > 0) {
//setTimeout has no way of passing the 'context' (aka 'this') to it's function
var savedContext = this;
setTimeout (function() { setTimeout (function() {
for (var i in errorTiles) { for (var i in errorTiles) {
var id = errorTiles[i]; var id = errorTiles[i];