But in applications where concurrency conflicts may occur, it's worthwhile to consider adding some form of concurrency control.The only way to guarantee that concurrency conflicts cannot occur is to limit data modification to one user at a time.
To accommodate this, many reservation systems let you choose a seat and then lock it for a specified duration.
Optimistic assumes that concurrency violations are rare and that if such an error occurs that it's adequate to ask one of the conflicting parties to re-enter their information.
Pessimistic concurrency, on the other hand, implements policies to ensure that concurrency violations cannot occur.
" One challenge with pessimistic concurrency control is knowing when a user is truly done editing the records.
If it's been 30 minutes since the user has last loaded the page, does that mean that they're busily editing the data, and need it to remain locked, or that they've closed their browser and gone home for the night?
The following figure illustrates this workflow when Manager A - the manager who updates the unit price to .00 - clicks the Update button after Manager B has already saved his changes.