2015-02-10 129 views
1

我有一個兩個簡單的週期性芹菜任務,運行在晚上,一個在凌晨2點,其他在凌晨3點,並從時間以下拋出異常關於djcelery_periodictask表的死鎖,我不太明白。看來,一個任務試圖,而其他則仍持有其共享鎖更新djcelery_periodictask死鎖時更新`djcelery_periodictask`表

deadlock detected Detail: Process 32353 waits for ShareLock on transaction 39280165; blocked by process 32306. Process 32306 waits for ShareLock on transaction 39280166; blocked by process 32353. 
Process 32353: 
UPDATE "djcelery_periodictask" SET "name" = 'app.tasks.task1', "task" = 'app.tasks.task1', "interval_id" = NULL, "crontab_id" = 4, "args" = '[]', "kwargs" = '{}', "queue" = NULL, "exchange" = NULL, "routing_key" = NULL, "expires" = NULL, "enabled" = true, "last_run_at" = '2015-02-10 03:00:00.001297+01:00', "total_run_count" = 117, "date_changed" = '2015-02-10 02:00:00.010033+00:00', "description" = '' WHERE "djcelery_periodictask"."id" = 4 
Process 32306: 
UPDATE "djcelery_periodictask" SET "name" = 'app.tasks.task2', "task" = 'app.tasks.task2', "interval_id" = NULL, "crontab_id" = 6, "args" = '[]', "kwargs" = '{}', "queue" = NULL, "exchange" = NULL, "routing_key" = NULL, "expires" = NULL, "enabled" = true, "last_run_at" = '2015-02-10 02:00:00.014189+01:00', "total_run_count" = 63, "date_changed" = '2015-02-10 02:00:00.015097+00:00', "description" = '' WHERE "djcelery_periodictask"."id" = 6 
Hint: See server log for query details. Query: 
UPDATE "djcelery_periodictask" SET "name" = 'app.tasks.task2', "task" = 'appt.tasks.task2', "interval_id" = NULL, "crontab_id" = 4, "args" = '[]', "kwargs" = '{}', "queue" = NULL, "exchange" = NULL, "routing_key" = NULL, "expires" = NULL, "enabled" = true, "last_run_at" 

怎麼能有兩個上僅包含幾個行陷入僵局表一個簡單的更新?

回答

0

我的問題是,我有我所有的工人開始-B參數,打開每一個工人在一個週期性的任務調度:

-B, --beat   Also run the celery beat periodic task scheduler. 
         Please note that there must only be one instance of 
         this service. 

其結果是,該計劃的任務被多次啓動,都在同時,嘗試更新djcelery_periodictask表時創建死鎖。