重启后gearman会以完全相同的顺序执行作业吗?

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

我使用 gearman 作为 C++ 应用程序和 PHP 应用程序之间的接口。我的工作取决于订单。在内存队列中,它们的执行顺序与添加的顺序相同(肯定是 1 个工作人员)。我想坚持我的队列。 gearman 会按照崩溃或重启后添加的相同顺序执行持久队列中的作业吗?

确实如此。它将从中断处继续并尝试完成剩余的工作。根据您的项目和队列...您可能需要为实际失败的作业添加故障保护。根据您的作业崩溃的位置,它可能已经写入数据(例如写入数据库),但如果作业重新启动将重试。

引用官方文档

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).