[LC Server] using a stack as a small database to store contacts emails - how to deal with concurrent inputs?

Robert Mann rman at free.fr
Tue Apr 28 22:00:09 EDT 2015

Quick & dirty live code server semaphore 

context : using a server stack as dynamic data storage medium in relation to
a site. 

How secure would that be, in terms of avoiding loss of data?

We have 2 server server stacks :
a) a siteStack which receives http request & builds pages, including the
b) a storageStack, where the data from the form is sent by the siteStack 

The story :
1) when triggered, the siteStack starts a session with a unique random
session identifier, which identifies each running instance of the siteStack
—> sessionId 

2) when the siteStack receives the data of the « form » with the user datas
— it makes a —> timeStamp and 
— opens up the file « storageStackSemaphore.txt » and checks if the color is
if it is GREEN then 
- write in it : « color is RED from sessionId at TimeStamp and saves » 
- then loads storageStack with a start using command 
- then sends « storeMe with the name of the semaphore file, the timeStamp,
the sessionId, and the data» to the storageStack 

Else repeat x times until color is green (wait for a while and retry) [with
a security x times to avoid any lost process] 

3) storageStack « storeMe » handler with : 3 params: semaphoreName,
timeStamp, sessionId, data» 
— opens up storageStackSemaphore and checks the color (RED or GREEN) 

i) if RED and SessionId corresponds to the one received as parameter : 
- deal with data and 
- save the storageStack 
- write off the « RED » semaphore in the storageStackSemaphore.txt writing
back « GREEN » into it and saving it. DONE (possibly unload storageStack
from memory) 

ii) else : (at that point I don’t figure exactly what could or not have
happened and how safe that procedure is!?), so… 
• CASE [RED and other sessionId] = another process did it at exactly the
same time -> redo from 2) 
• CASE [GREEN] ?? another process started and completed faster... ?? -> redo
from 2) 

SO : send a msg error to the siteStack and ask it to redo the operation from
point 2) 

The the timeStamp would not be needed? 
thanks for any hint since i’m not too sure how the server stuff would handle

good day.. RObert 

View this message in context: http://runtime-revolution.278305.n4.nabble.com/LC-Server-using-a-stack-as-a-small-database-to-store-contacts-emails-how-to-deal-with-concurrent-inp-tp4691609p4691610.html
Sent from the Revolution - User mailing list archive at Nabble.com.

More information about the use-livecode mailing list