mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #12035 from overleaf/bg-clear-first-op-timestamp-3
skip adding timestamp when flushing old projects GitOrigin-RevId: a420da0e1c2aecd1589d857744353fb5e014aa32
This commit is contained in:
parent
32661eb8c2
commit
fc9955e719
2 changed files with 15 additions and 37 deletions
|
@ -28,37 +28,18 @@ export function flushIfOld(project_id, cutoffTime, callback) {
|
|||
if (err != null) {
|
||||
return callback(OError.tag(err))
|
||||
}
|
||||
// in the normal case, the flush marker will be set with the
|
||||
// timestamp of the oldest operation in the queue by docupdater
|
||||
if (firstOpTimestamp != null) {
|
||||
if (firstOpTimestamp < cutoffTime) {
|
||||
logger.debug(
|
||||
{ project_id, firstOpTimestamp, cutoffTime },
|
||||
'flushing old project'
|
||||
)
|
||||
return UpdatesProcessor.processUpdatesForProject(
|
||||
project_id,
|
||||
(
|
||||
err // always clear the flush marker after processing the project
|
||||
) =>
|
||||
RedisManager.clearFirstOpTimestamp(project_id, function (e) {
|
||||
if (e != null) {
|
||||
logger.error(
|
||||
{ project_id, flushErr: e },
|
||||
'failed to clear flush marker'
|
||||
)
|
||||
}
|
||||
if (err) {
|
||||
OError.tag(err)
|
||||
}
|
||||
return callback(err)
|
||||
})
|
||||
) // return the original error from processUpdatesFromProject
|
||||
} else {
|
||||
return callback()
|
||||
}
|
||||
// In the normal case, the flush marker will be set with the
|
||||
// timestamp of the oldest operation in the queue by docupdater.
|
||||
// If the marker is not set for any reason, we flush it anyway
|
||||
// for safety.
|
||||
if (!firstOpTimestamp || firstOpTimestamp < cutoffTime) {
|
||||
logger.debug(
|
||||
{ project_id, firstOpTimestamp, cutoffTime },
|
||||
'flushing old project'
|
||||
)
|
||||
return UpdatesProcessor.processUpdatesForProject(project_id, callback)
|
||||
} else {
|
||||
return RedisManager.setFirstOpTimestamp(project_id, callback)
|
||||
return callback()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -209,7 +209,7 @@ describe('Flushing old queues', function () {
|
|||
)
|
||||
})
|
||||
|
||||
it('sets the timestamp and does not flush the project history queue', function (done) {
|
||||
it('flushes the project history queue anyway', function (done) {
|
||||
request.post(
|
||||
{
|
||||
url: `http://localhost:3054/flush/old?maxAge=${3 * 3600}`,
|
||||
|
@ -220,8 +220,8 @@ describe('Flushing old queues', function () {
|
|||
}
|
||||
expect(res.statusCode).to.equal(200)
|
||||
assert(
|
||||
!this.flushCall.isDone(),
|
||||
'did not make calls to history service to store updates'
|
||||
this.flushCall.isDone(),
|
||||
'made calls to history service to store updates'
|
||||
)
|
||||
ProjectHistoryClient.getFirstOpTimestamp(
|
||||
this.projectId,
|
||||
|
@ -229,10 +229,7 @@ describe('Flushing old queues', function () {
|
|||
if (err) {
|
||||
return done(err)
|
||||
}
|
||||
expect(parseInt(result, 10)).to.be.within(
|
||||
this.startDate,
|
||||
Date.now()
|
||||
)
|
||||
expect(result).to.be.null
|
||||
done()
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue