A Locking Problem

I have been aware for quite some time that, occasionally, plays of music made by AMP would not get recorded in the PLAYS table as they should. It's difficult to know precisely why: when you're developing the code and saving changes to the script as it's playing something, it could well be that your editing has caused the 'record in PLAYS' bit of code to get skipped.

Or it could be a locking issue. Putting it at its simplest, databases cannot have one person modifying data whilst simultaneously allowing a second person to read that data. If I am in the process of withdrawing £5000 from my bank account just as a credit check is being performed, do we let the credit agency see the £5000 in the account? Or do we see it missing the £5000, even though I might be about to type 'Cancel' at the ATM? To resolve these data concurrency issues, all databases implement a form of 'locking': if I am going to withdraw money from my account, we lock the data until my withdrawal is complete, so that no-one can see it, either with or without the £5000, then when I'm finished at the ATM, we unlock and people can read the definite results. [...] 

Continue Reading