Node.js · Senior · Question 72 of 75

Two requests read a record, change it and save it at the same time, and one update is lost. How does optimistic locking prevent this?

Explanation

Optimistic locking works well when conflicts are rare. Pessimistic locking (SELECT ... FOR UPDATE) fits frequent conflicts but holds locks longer.

Further reading

Problem with a question

Node.js · Senior · question 72

Test yourself

Take the Node.js · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz