mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add comment about locking in redis migration
This commit is contained in:
parent
c2714f9ae9
commit
a638ef4251
1 changed files with 8 additions and 0 deletions
|
@ -97,6 +97,14 @@ class Multi
|
|||
exec: (callback) ->
|
||||
# decide which client to use
|
||||
project_id = getProjectId(@queueKey)
|
||||
# Put a lock around finding and updating the queue to avoid time-of-check to
|
||||
# time-of-use problems. When running in the "switch" phase we need a lock to
|
||||
# guarantee the order of operations. (Example: docupdater A sees an old
|
||||
# queue at t=t0 and pushes onto it at t=t1, project history clears the queue
|
||||
# between t0 and t1, and docupdater B sees the empty queue, sets the
|
||||
# migration flag and pushes onto the new queue at t2. Without a lock it's
|
||||
# possible to have t2 < t1 if docupdater A is slower than B - then there
|
||||
# would be entries in the old and new queues, which we want to avoid.)
|
||||
LockManager.getLock project_id, (error, lockValue) =>
|
||||
return callback(error) if error?
|
||||
releaseLock = (args...) =>
|
||||
|
|
Loading…
Reference in a new issue