mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 10:53:35 -05:00
add metric for queue length
This commit is contained in:
parent
f6b2ac7360
commit
83dd43b809
2 changed files with 7 additions and 3 deletions
|
@ -35,9 +35,11 @@ module.exports = DeleteQueueManager =
|
||||||
logger.log "hit count limit on flushing old projects"
|
logger.log "hit count limit on flushing old projects"
|
||||||
return callback()
|
return callback()
|
||||||
cutoffTime = now - options.min_delete_age
|
cutoffTime = now - options.min_delete_age
|
||||||
RedisManager.getNextProjectToFlushAndDelete cutoffTime, (err, project_id, flushTimestamp) ->
|
RedisManager.getNextProjectToFlushAndDelete cutoffTime, (err, project_id, flushTimestamp, queueLength) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
return callback() if !project_id?
|
return callback() if !project_id?
|
||||||
|
logger.log {project_id, queueLength: queueLength}, "flushing queued project"
|
||||||
|
metrics.globalGauge "queued-flush-backlog", queueLength
|
||||||
flushProjectIfNotModified project_id, flushTimestamp, (err, flushed) ->
|
flushProjectIfNotModified project_id, flushTimestamp, (err, flushed) ->
|
||||||
count++ if flushed
|
count++ if flushed
|
||||||
flushNextProject()
|
flushNextProject()
|
||||||
|
|
|
@ -298,18 +298,20 @@ module.exports = RedisManager =
|
||||||
rclient.zadd keys.flushAndDeleteQueue(), Date.now(), project_id, callback
|
rclient.zadd keys.flushAndDeleteQueue(), Date.now(), project_id, callback
|
||||||
|
|
||||||
getNextProjectToFlushAndDelete: (cutoffTime, callback = (error, key, timestamp)->) ->
|
getNextProjectToFlushAndDelete: (cutoffTime, callback = (error, key, timestamp)->) ->
|
||||||
# find the oldest queued flsus
|
# find the oldest queued flush
|
||||||
rclient.zrangebyscore keys.flushAndDeleteQueue(), 0, cutoffTime, "WITHSCORES", "LIMIT", 0, 1, (err, reply) ->
|
rclient.zrangebyscore keys.flushAndDeleteQueue(), 0, cutoffTime, "WITHSCORES", "LIMIT", 0, 1, (err, reply) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
return callback() if !reply?.length
|
return callback() if !reply?.length
|
||||||
multi = rclient.multi()
|
multi = rclient.multi()
|
||||||
multi.zrange keys.flushAndDeleteQueue(), 0, 0, "WITHSCORES"
|
multi.zrange keys.flushAndDeleteQueue(), 0, 0, "WITHSCORES"
|
||||||
multi.zremrangebyrank keys.flushAndDeleteQueue(), 0, 0
|
multi.zremrangebyrank keys.flushAndDeleteQueue(), 0, 0
|
||||||
|
multi.zcard keys.flushAndDeleteQueue()
|
||||||
multi.exec (err, reply) ->
|
multi.exec (err, reply) ->
|
||||||
return callback(err) if err?
|
return callback(err) if err?
|
||||||
return callback() if !reply?.length
|
return callback() if !reply?.length
|
||||||
[key, timestamp] = reply[0]
|
[key, timestamp] = reply[0]
|
||||||
callback(null, key, timestamp)
|
queueLength = reply[2]
|
||||||
|
callback(null, key, timestamp, queueLength)
|
||||||
|
|
||||||
_serializeRanges: (ranges, callback = (error, serializedRanges) ->) ->
|
_serializeRanges: (ranges, callback = (error, serializedRanges) ->) ->
|
||||||
jsonRanges = JSON.stringify(ranges)
|
jsonRanges = JSON.stringify(ranges)
|
||||||
|
|
Loading…
Reference in a new issue