Junior — Middle
What resources or data are blocked during the use of pessimistic locking?
sobes.tech AI
Answer from AI
Pessimistic locking assumes that when working with a resource (for example, a database record), it is locked for other users or processes during the operation to prevent conflicts and ensure data integrity. Typically, the following are locked:
- Rows or records in a database that are being modified or read with the intent to modify.
- Database tables or pages (depending on the level of locking).
- Other resources related to the data being changed, such as files or objects in memory.
This means that while one process holds a lock, others cannot modify or sometimes even read these data, preventing race conditions and ensuring consistency.