about Rev cgi and MySQL

Nicolas Cueto niconiko at gmail.com
Mon Nov 2 18:47:39 EST 2009


Just curious about something. But I don't know the technical
vocabulary, so please forgive this verbose (and confusing?)
explanation.

I think it essentially has do with user queues.


I have a Rev.cgi script on the On-Rev server that works in this 3-step sequence:

(STEP 1) uses SELECT to retrieve data from a MySQL table

(STEP 2) does stuff based on that retrieved data in order to alter it

(STEP 3) uses UPDATE to put that now-altered data back into the same MySQL table


My question is about data mishaps that could happen during STEP 2 --
specially if it happens to take a long time (a few seconds?) -- should
it happen to come about that a new user calls a Rev.cgi which is still
working on a previous user's call.


The chaos sequence I have in mind is this:

USER 1 : STEP 1 --> Rev.cgi retrieves data from SQL table at time X ( = tData)
USER 1 : STEP 2 --> Rev.cgi works with tData to make tData_User1 (but
no UPDATE yet)

... but during USER 1 : STEP 2 ...

USER 2 : STEP 1 -->   Rev.cgi retrieves data from SQL table at time
X+1 (still = tData)
USER 2 : STEP 2 --> Rev.cgi works on tData to make tData_User2 (but no
UPDATE yet)
USER 1 : STEP 3 --> updates SQL table with tData.User1
USER 2 : STEP 3 --> updates SQL table with tData.User2

In this chaos scenario of mine -- if indeed this is how things
actually happen between servers, which I'm hoping it's not -- the
problem is the state of tData at USER 2 : STEP2. It should not be
tData but actually tData_User1.


So, is there something in-built in SQL or Rev.cgi that handles queues
in such a way that prevents this kind of queue chaos, whether it's 2
or 2 million users calling in at the "same" time

Or do I have to take care of this myself somehow, by, say, proper scripting?

Thank you.

--
Nicolas Cueto



More information about the use-livecode mailing list