[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:
Jakob Ackermann
2026-09-17 11:24:34 +00:00
committed by Copybot
parent ff72ccf5ba
commit 89f12e6b1f
6 changed files with 197 additions and 21 deletions
@@ -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,
})