I have a cli php script that is executed whenever an email arrives at a specific address.
When a new email arrives a new instance of the script is executed but because they read/write to the same DB tables sometimes wrong data is written.
My question is if the first script puts a lock on all the tables that it needs and a second/third etc instance of the script is run, will they wait for the tables to be unlocked by the first executed script? If so for how long?
In the end what I'm trying to do is make the scripts do their read/writes one after the other in a serial fashion so as to avoid duplication and errors.
Yes, it will wait. This is done by the database server, the client application is totally unaware that it's happening -- as far as it can tell, the database is just being slow to perform the query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With