4 ms·
> I seriously thought atomicity in databases was the same idea as atomicity in concurrent programs like an “atomic instruction” and it’s a TOTALLY DIFFERENT THI
by jorams 9y ago
> I seriously thought atomicity in databases was the same idea as atomicity in concurrent programs like an “atomic instruction” and it’s a TOTALLY DIFFERENT THING
I don't see how it's a totally different thing.
When a change to a database is atomic, it can never be observed to be in progress by others. Either it has occurred or it hasn't. To the observer this means it appears to happen instantly.
When an instruction in a concurrent program is atomic, it can never be observed to be in progress by others. Either it has occurred or it hasn't. To the observer this means it appears to happen instantly.
Is either of these descriptions wrong?
- Arcsech 9y agoAs described in the article & accompanying illustration, that's actually Isolation. Atomicity in ACID refers to "either all of the operations in this transaction happen, or none of them do".
- twic 9y agoYes, your description of database atomicity is wrong (i think!). In ACID, atomicity doesn't mean that a set of writes in one transaction become visible to other transactions all at the same time; it means that after the writing transaction is finished, they are either all applied, or none are applied. In practice, that means if you successfully commit, all your data is saved, and if you successfully roll back, none of your data is saved. EDIT: I'm not sure what the guarantees are if either fail. The property that the writes don't become visible to other transactions is isolation. This is where the infamous transaction isolation levels come in; with a weak level of isolation, writes in one transaction may be visible to others before they are committed.
- jorams 9y agoAlright, so the non-database definition of atomicity combines the Atomicity and Isolation of ACID. Thanks for helping clear that up. I don't think that makes it a "TOTALLY DIFFERENT THING", but it's definitely important to understand the difference.