Consider the following workflow, running in MySQL with the InnoDB engine.
- Begin a transaction.
- Select some rows using
SELECT FROM tablename WHERE ...
, rather thanSELECT ... FOR UPDATE
. - Filter those rows using code that is not executing in the database (let's say Python).
- Perform a
DELETE
on some subset of the rows. - End the transaction.
Based on this question, it seems that this workflow is not safe because of step 2, but the answers did not give details on the failure modes.
Is this simply undefined behavior, or is there a specific, well-defined set of failure modes?
Additionally, why doesn't the ACID nature of transactions protect against unsafe behavior here?