Here is how the locking system was designed when I worked on it (and I doubt that anything major has changed since, for reasons described below, but someone currently on the team is welcome to give confirmation/update):
- Ideally, a user will not be shown a post in a question listing, SG listing, or be directed to a post from redirect after action on another post, if the new post is locked.
- Posts are locked when a user opens the post, and no one else has it locked
- Locks are time-bound (5 minutes? 10? Don't quite remember). So if the user does nothing on the post in that amount of time, the lock passively expires (with no notice to the user [too expensive])
- If a user leaves a post through an active SG action during this time (back to listing, perform an action that leaves the post, skip) then the lock is proactively cleared
[As a side note, a best-practice when reviewing should be to prefer using the [Return to questions] button to go back to the listing over clicking on the SG link or using browser [back]. The button will clear your lock on it, the other methods won't.]
This works similarly to the Review Queues lock, except that in SG things it is much easier for a person to end up on a locked post than in Review Queues. RQ have no listings, you are just sent to a post. And while you are reviewing it, it is locked for being given to other users, you have to work hard to get direct access to posts otherwise (like going through queue history and direct clicking).
With SG, the common way to land on a locked post is:
- User1 opens up the /questions page or SG home page, which includes a link to one or more SG posts.
- User1 does something other than opening one of the SG posts.
- In the meantime, User2 opens of those posts (not yet locked), through a listing or redirect. Post locks for User2.
- User1 then clicks on a link in their open listing (and their interface does not inform them that it is already locked, as keeping that in sync across all users and listings was deemed [too expensive]).
- The SG question opens locked for User1 (and will stay with the locked icon there, even if the User2 lock is lost, as handling that case was [too expensive]).
A variation on this theme:
- User1 loads an SG post
- User1 then proceeds to spent 20 minutes crafting a post on Meta, spending 17 of these minutes working on getting a screenshot with a hand-drawn circle that looks casually messy, and says "I have better things to do with my time than draw clear visual indicators on a screenshot, so I just did this one super quickly, thank me later", but has to keep starting over because their penchant for exactness makes it really hard to make a messy arrow. In the end, they have to resort to using their non-dominant hand to draw the circle and arrow, while blindfolded (they kept cheating when just keeping their eyes closed).
- In the meantime, the post is passively unlocked (cache entry times out). The indicator on User1's screen doesn't update to indicate this ([too expensive]).
- After the lock expired, but before User1 finished their Meta post, User2 arrives on the SG post (redirected there, after the lock was cleared). It locks for them.
- While the lock is intact for User2, User1 now (finally) attempts to perform an action on the SG post that they had opened (which does not say locked - as it would if they reloaded it - implying that they hold a lock). And they are blocked on the server-side validation due to User2's lock.
- User1 goes on to another post in SG, but is so frustrated by the experience of having wasted 2 minutes on their blocked review, decide to post on Meta about it (return to step 2, above).
Why does this review mechanism require exclusive access?
The idea behind it was that we (including myself in the we in this instance, even though no longer applicable) were asking reviewers to invest time in their review, and designed a workflow that required input from them - a comment, potentially an edit - in order to fulfil their role in the best way. And at the same time, were introducing a listing component that was designed to be flexible and offered users many ways to load/sort/filter listings of posts. But also opened up the possibility of much more frequent instances of multiple reviewers hitting one post at the same time. So having some sort of locking was considered a must. With the goal of it working unnoticed as much as possible (blocking redirects to locked posts, not showing locked posts in listings).
Hope that this helps to give some context. Up to current staff to talk about how this might change moving forward.
[too expensive] - anything above tagged with this are items that we considered building, but elected to not build at the time, due to the cost of building it time-wise relative to the value of moving on to other things.
I was one of the main decision-makers at the time as to what we would include in the initial locking mechanism.
The general driving principle was YAGNI, and not wanting to spend time on specific edge cases before knowing which ones would actively cause pain at scale. Pain principally defined as a user wasting time in any way (reviewing a post that they thought was unlocked) or running into things like edit collisions.
/staging-ground
question list IIRC.