phpqueueamqpgearmanmom

Will gearman execute jobs in exactly the same order after the restart?


I use gearman as an interface between a C++ app and a PHP app. My jobs are order-dependent. With the in-memory queue they executed in the same order that they were added (by 1 worker certanly). I want to persist my queue. Will gearman execute jobs in persistent queue in the same order that they were added after the crash or the restart?


Solution

  • it actually does. It will continue where it left off and try to finish the remaining jobs. Depending on your project and queue ... you might need to add failsafes for the job which actually failed. Depending where your job crashed it could already have written data (to a database for example) but will retry if the job restarts.

    quote of official docu

    If a job server crashes or is restarted between these two calls for a job, the jobs are reloaded during the next job server start. When the job server starts up, it will call a replay callback function in the module to provide a list of all jobs that were not complete. This is used to populate the internal memory queue of jobs to be run. Once this replay is complete, the job server finishes its initialization and the jobs are now runnable once workers connect (the queue should be in the same state as when it crashed).