Dec 17, 2014, 6:55 PM
Post #8 of 13
I can think of a few ways this could be implemented.
Re: [ttamlrep] simultaneous exection of script on webpage
[In reply to]
Your delete the record suggestion would work well, but I would choose to mark records perhaps as "being processed", then "processed" under a status column instead. This way you can simply select records that have a null or "unprocessed" status. I would only consider deleting or archiving records if the table became too large.
Another option would be to store a past datetime in another table or other. Select records by ascending order of date that were created after this datetime. Once your script has finished, update the datetime to the datetime of the newest record you selected, OR, after each single record has been processed, update the datetime to the datetime of that record.
Ensure you lock your script when it begins and unlock it when it ends, this will prevent manual or overlapping cron runs which otherwise may attempt to re-process records currently being processed. You may also want to consider marking those records that error-ed or took too long to complete etc etc etc perhaps a threshold number of times, they can then be analyzed, then processed manually if need be.
If you need a more detailed implementation plan, feel free to ask. I probably haven't covered all possible race conditions above.
(This post was edited by Zhris on Dec 17, 2014, 6:57 PM)