mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
[document-updater] wrap doc locks in project lock (#35416)
* [document-updater] wrap doc locks in project lock * [document-updater] use BlockingProject as redis key prefix * [redis-wrapper] update comment GitOrigin-RevId: 0ce50e76386871e6c29481494febc8d6b37e7df5
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
const Settings = require('@overleaf/settings')
|
||||
const redis = require('@overleaf/redis-wrapper')
|
||||
const rclient = redis.createClient(Settings.redis.lock)
|
||||
const keys = Settings.redis.lock.key_schema
|
||||
const RedisLocker = require('@overleaf/redis-wrapper/RedisLocker')
|
||||
|
||||
// Project level lock used to serialise processing of a project's pending
|
||||
// updates (the `BlockingProject:{project_id}` key). Acquired before the per-doc
|
||||
// `Blocking:{doc_id}` lock - never the other way around - to avoid deadlocks.
|
||||
module.exports = new RedisLocker({
|
||||
rclient,
|
||||
getKey(projectId) {
|
||||
return keys.projectBlockingKey({ project_id: projectId })
|
||||
},
|
||||
wrapTimeoutError(err, projectId) {
|
||||
err.project_id = projectId
|
||||
return err
|
||||
},
|
||||
metricsPrefix: 'project',
|
||||
lockTTLSeconds: Settings.redisLockTTLSeconds,
|
||||
})
|
||||
Reference in New Issue
Block a user