facebookarchive / bistro

Bistro is a flexible distributed scheduler, a high-performance framework supporting multiple paradigms while retaining ease of configuration, management, and monitoring.
https://bistro.io
MIT License
1.03k stars 158 forks source link

cron schedule day_of_week with single item gets error: dow 3 carried to 3 #14

Closed ghost closed 7 years ago

ghost commented 7 years ago

cron schedule day_of_week with single item gets error, "dow 3 carried to 3".

These examples get the error (with today being Tuesday):

"day_of_week": 3,
"day_of_week": [3],
"day_of_week": [3,3],
"day_of_week":["tue"],
"day_of_week":"tue",
"day_of_week":"tuesday",

But multiple days of week works fine (runs the task):

"day_of_week": [1,3],
"day_of_week": ["mon","tue"],

Example error message:

E0516 09:20:18.108150 31104 Monitor.cpp:141] Updating monitor histogram (/home/username/src/bistro/bistro/monitor/Monitor.cpp:60): dow 3 carried to 3 E0516 09:20:19.658288 31107 Bistro.cpp:75] Main loop (/home/username/src/bistro/bistro/Bistro.cpp:48): Error getting nodes: dow 3 carried to 3

Example configuration that produces the error:

{
  "bistro_settings": {
    "resources": {
      "instance": {"concurrency": {"limit": 10, "default": 1}},
      "level1": {
        "my_resource": {"limit": 3, "default": 0}
      }
    },
    "nodes": {
      "levels": ["level1", "level2"],
      "node_sources": [
        {
          "source": "manual",
          "prefs": {
            "node1": []
          }
        },
        {
          "source": "add_time",
          "prefs": {
            "parent_level": "level1",
            "schedule": [
              {
                "cron": {
                  "hour": 8,
                  "minute": 50,
                  "day_of_week": 3,
                  "dst_fixes": ["unskip", "repeat_use_only_early"]
                },
                "lifetime": 6000,
                "tags": ["tag_job2"]
              }
            ]
          }
        }
      ]
    },
    "enabled" : true
  },
  "bistro_job->job2" : {
    "owner" : "test",
    "enabled" : true,
    "command" : ["/bs/job_script.sh"],
    "priority": 1,
    "resources": {
      "my_resource": 1
    },
    "filters": {
      "level2": {
        "tag_whitelist": ["tag_job2"]
      }
    }
  }
}

Example scheduler startup:

#!/bin/bash
cd $HOME/src/bistro/bistro

# Start the scheduler in one terminal
./cmake/Debug/server/bistro_scheduler \
  --server_port=6789 \
  --http_server_port=6790 \
  --config_file=$HOME/bs/config.json \
  --clean_statuses \
  --CAUTION_startup_wait_for_workers=700 \
  --instance_node_name=scheduler

Example worker startup:

cd $HOME/src/bistro/bistro
./cmake/Debug/worker/bistro_worker \
  --server_port=27182 \
  --scheduler_host=:: \
  --scheduler_port=6789 \
  --worker_command="$HOME/bs/default_task.sh" \
  --data_dir=/tmp/bistro_worker
snarkmaster commented 7 years ago

Thanks for the bug report! I'll land a patch and unit test shortly, but the fix is easy -- change >= to > on this line:

https://github.com/facebook/bistro/blob/master/bistro/cron/StandardCrontabItem.cpp#L298

It was simply an over-zealous assertion.