Reputation: 11
I need to create and store a single instance of an object in the AppEngine datastore (there will never need to be more than one object). It is the last run time for a cron job that I am scheduling. The idea is that the cron job will only pick up those rows that have been created/updated since its last run for processing, and will update the last run time after it has completed, What is the best way to do this considering concurrency issues as well - in case a previous job has not finished running?
Upvotes: 0
Views: 139
Reputation: 2237
If I understand your question correctly, it sounds like you could just create a 'job bookkeeping' entity that records whether a job is currently running, along with any necessary state about what you are processing with the job.
Then, access that bookkeeping entity using a transaction, so that only one process can do a read + update on it at a time. That will let you safely check whether another job is still running before starting a new job.
(The datastore is non-relational, so I am guessing with your mention of 'rows', you instead mean entities of some Kind that you need to process? Your bookkeeping entity could store some state about which of these entities you'd processed so far, that would let you query for new ones to process).
Upvotes: 1