Concurrency and data reading
When multiple sessions simultaneously access (manipulate) the same data, there are some unexpected results, including:
– Dirty Read--Dirty reads
-Non-repeatable-non-repeatable reads
-Phantom read-Phantom reads
1. Dirty Reading
Dirty reading means that when a transaction is accessing the data and the data has been modified, and the modification has not yet been submitted to the database, then another transaction accesses the data and then uses the data. Because this data is not yet submitted data, then another transaction read the data is dirty data. Looking at the following diagram may be better understood:
2. Non-repeatable reading
Non-repeatable reading means that in database access, two of the same queries within a transaction range return different data, due to other transactions in the system that have modified the data and submitted it when the query was made. such as transaction T1 read a data, the transaction T2 read and modify the data, T1 read the data again, the discovery and the first read is different.
This is illustrated below: