Sobes.tech
Junior — Middle

What risks arise when multiple requests that modify the same data are executed simultaneously under two transactions?

sobes.tech AI

Answer from AI

When executing multiple requests simultaneously that modify the same data in different transactions, the following risks arise:

  • Race Condition: changes made by one transaction can overwrite changes made by another, leading to data loss.

  • Data Integrity Violation: if transactions are not properly isolated, data may become inconsistent.

  • Phantom Reads: one transaction sees changed or new rows added by another transaction.

  • Deadlocks: transactions can block each other, waiting for resources to be released.

  • Lost Updates: when two requests read the same data and then both try to update it, one change may overwrite the other.

To prevent these issues, transaction isolation levels and locking mechanisms such as SELECT FOR UPDATE or optimistic locking are used.