dimanche 31 août 2014

Celerybeat schedule executing task multiple times?


Vote count:

0




I have a task calculate_common_locations which runs once via CELERYBEAT_SCHEDULE. The task simply calls a function in the database:



@app.task
def calculate_common_locations():
db.execute("SELECT * FROM calculate_centroids('b')")


This is the entry in CELERYBEAT_SCHEDULE:



CELERYBEAT_SCHEDULE = {
'common_locations': {
'task': 'clients.tasks.calculate_common_locations',
'schedule': crontab(hour=23, day_of_week='sun'), #every week
},
[..]
}


I got an IntegrityError because the function was executed twice, see the currently running queries:


enter image description here


There is two different backends connecting (at different times, see backend_start) but executing the same task at exactly the same time (xact_start, query_start).


I am using pgbouncer to reuse celery connections. Could that be an issue? What else could cause celery to execute the task twice?


This is how celery gets started (via supervisord):



celery worker --beat --app=cloud.celery app:app --concurrency=10 -l INFO -s /home/foo/run/celerybeat-schedule --pidfile=/home/foo/run/celerybeat.pid


asked 34 secs ago







Celerybeat schedule executing task multiple times?

Aucun commentaire:

Enregistrer un commentaire