DEV Community

Discussion on: Solve Phantom Read in MySQL

Collapse
 
darkain profile image
Vincent Milum Jr

Really interesting concept on this one. Curious why not just go for the simpler approach? You already have a parent table with the list of rooms themselves, correct? Why not create a lock on the room's row on the parent table, do the serialized work on the child table, and then release the lock on the row on the parent table. This is a much simpler and more elegant solution, and pretty much solves all the problems discussed here.

Collapse
 
lazypro profile image
ChunTing Wu • Edited

In the original approach, there is no parent table. The only one table, booking, without the corresponding data for the reservation. Thus, we cannot lock for nothing.

For this practical example, the room list might be stored at the MongoDB or any other data storage. After all, the room list is not the core of this system >.^