Phantom read is one of anomalies that may happen in a database in case if proper transaction level is not imposed.
Phantom read occurs when two identical queries executed at pretty much the same time return different sets of results.
Imagine two transactions happening at the same time.
First transaction selects all records from some table, then second one inserts a new record in that same table. And then first transaction selects all records from that table again. This time it will get newly inserted record in a result set. If second transaction fails before committing its result (and the newly inserted record is not saved), this record is called a phantom record - because at the end of the day it does not exist in the database.
Phantom reads occur when range locks are not acquired to the table that is modified and may be prevented by applying appropriate transaction isolation level to the database.
Войдите чтобы поставить Нравится
Войдите чтобы прокомментировать