Using one Worker at a time :
If you run only one Worker and it has to process a bunch of records, you may run into a race to access the same record when a new Worker is launched and the precedent one has not finished its job.
You can check if a pid file exists at construct phase and, if not, create it.
It will be deleted at the end of the process.
As the items are processed in order, you can optimize the database access by dropping the markItemAsBeingProcessed($item) function.
You can also launch more than one Worker at a time. There are different ways to do it (exec, pnctl_fork, curl_multi_exec, gearman, fsockopen...).
Alexander Skakunov - 2016-03-10 19:11:01 - In reply to message 1 from Lionel F. Lebeau
Yes, the jobs need to be marked when they are given to a particular worker.
If you go with database solution like I did, you can use SELECT...FOR UPDATE query just for that.
Other solutions support this too of course.