WAL not persist released job with new priority if new delay is 0

Author: wuYinCreated Dec 22, 2020Updated Mar 9, 2026

Issue

For release command, WAL doesn't persist job's new priority if delay is 0

Reproducation

  1. start a beanstalkd with binlog ./beantalkd -b /tmp/x

  2. client put 2 jobs with different priority

    put [0 0 0 6]
    job_01
    put [10 0 0 6]
    job_02
  3. client reserved job_1 which has highest priority, and release it with lower priority 20 and no delay

    reserve-with-timeout [10]
    release [1 20 0]
  4. terminate and restart beantalkd with binlog manually

  5. new client reserve job, want higher priority job_02, but got job_01

    reserve-with-timeout [10]
    1 job_01

Cause

Release command handler which in prot.c#L1575, write the released job into WAL only if delay > 0, means update_store is true, see enqueue_job() in prot.c#L530

Other

Maybe this is intentional, after enqueue_job, immediately process_queue to find a waiting connection and deliver the released ready job. But if there is no waiting connections, the released ready job with new priority will be lost if beanstalkd suddenly terminated.