Joist uses optimistic locking to prevent conflicting or dropped UPDATE statements. Instead of locking rows at the database level during a read (pessimistic locking), Joist assumes no conflict will occur. When writing data, Joist verifies that the row has not changed since it was last read by including the updated_at timestamp in the WHERE clause of the UPDATE statement.
If the UPDATE modifies 1 row, the write is successful. If it modifies 0 rows, it indicates another thread changed the data, and Joist throws an Oplock failure error.
-- Conceptual SQL generated by Joist
UPDATE authors
SET
first_name = 'bob'
updated_at = '...10:01am...'
WHERE id = 1
AND updated_at = '...10:00am...'