Repository navigation
Description
I am using Celery version "3.1.19" installed using pip3 on a Ubuntu 14.04 server.
I have a celery task that sends emails using Python 3 smtplib. The celery workers are started using celery multi command:
celery multi start worker1 worker2 worker3 worker4 worker5 -A surveys.tasks --time-limit=900 --pidfile="/path/%n.pid" --logfile="/path/%n.log" --loglevel=info
The code that sends the emails is something like this:
@app.task
def queued_tracker_reminder_others_task(*args, **kwargs):
try:
for email_id1, email_id2 in email_id_list;
email_content = MIMEMultipart('alternative')
email_content['Subject'] = 'Subject'
email_content['From'] = '"Email" <email_id1>'
email_content['To'] = '"Email" <email_id2>'
email_body_message_html = 'Email message body in HTML'
email_content.attach(MIMEText(email_body_message_html, 'html'))
server = smtplib.SMTP('domain_name')
server.set_debuglevel(2)
email_context = ssl.create_default_context()
server.starttls(context=email_context)
password = 'some password'
server.login('email_id1', password)
server.send_message(email_content)
server.quit()
sleep(1)
except Exception as e:
raise QueuedTaskError(str(e))So, the above task sends emails to some 400 email IDs. When I execute this task from my Python 3 Django app as queued_tracker_reminder_others_task.delay(), it sends emails to some 100 email IDs and then gives the following error message. If I run this task again, then it'll send emails to another 50 email IDs and then again it gives the below error message. So, each time the task is called, it'll send emails to a random number of email IDs and then it raises SIGIOT error. It does not matter which worker (out of the 5 available workers) executes this task, I'll always get the below error message:
==> worker1.log <==
[2015-12-09 11:40:05,966: INFO/MainProcess] Received task: surveys.tasks.queued_tracker_reminder_others_task[bd91da62-b045-4846-96ba-e3479fefa4fb]
[2015-12-09 11:40:38,612: ERROR/MainProcess] Process 'Worker-2' pid:12222 exited with 'signal 6 (SIGIOT)'
[2015-12-09 11:40:38,651: ERROR/MainProcess] Task surveys.tasks.queued_tracker_reminder_others_task[bd91da62-b045-4846-96ba-e3479fefa4fb] raised unexpected: WorkerLostError('Worker exited prematurely: signal 6 (SIGIOT).',)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/billiard/pool.py", line 1175, in mark_as_worker_lost
human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 6 (SIGIOT).
==> worker4.log <==
[2015-12-09 11:43:27,212: INFO/MainProcess] Received task: surveys.tasks.queued_tracker_reminder_others_task[3f5f56c2-88d1-475e-8a25-472f11eb48d4]
[2015-12-09 11:43:40,851: ERROR/MainProcess] Process 'Worker-2' pid:12232 exited with 'signal 6 (SIGIOT)'
[2015-12-09 11:43:40,890: ERROR/MainProcess] Task surveys.tasks.queued_tracker_reminder_others_task[3f5f56c2-88d1-475e-8a25-472f11eb48d4] raised unexpected: WorkerLostError('Worker exited prematurely: signal 6 (SIGIOT).',)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/billiard/pool.py", line 1175, in mark_as_worker_lost
human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 6 (SIGIOT).
==> worker2.log <==
[2015-12-09 11:45:58,799: INFO/MainProcess] Received task: surveys.tasks.queued_tracker_reminder_others_task[ec92d509-f6d2-4268-a54b-0acd1dde3029]
[2015-12-09 11:47:01,742: ERROR/MainProcess] Process 'Worker-1' pid:12256 exited with 'signal 6 (SIGIOT)'
[2015-12-09 11:47:01,794: ERROR/MainProcess] Task surveys.tasks.queued_tracker_reminder_others_task[ec92d509-f6d2-4268-a54b-0acd1dde3029] raised unexpected: WorkerLostError('Worker exited prematurely: signal 6 (SIGIOT).',)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/billiard/pool.py", line 1175, in mark_as_worker_lost
human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 6 (SIGIOT).
==> worker3.log <==
[2015-12-09 11:51:38,217: INFO/MainProcess] Received task: surveys.tasks.queued_tracker_reminder_others_task[b205871d-b677-4c3b-a753-76c9efa1c6c2]
[2015-12-09 11:51:42,712: ERROR/MainProcess] Process 'Worker-2' pid:12296 exited with 'signal 6 (SIGIOT)'
[2015-12-09 11:51:42,748: ERROR/MainProcess] Task surveys.tasks.queued_tracker_reminder_others_task[b205871d-b677-4c3b-a753-76c9efa1c6c2] raised unexpected: WorkerLostError('Worker exited prematurely: signal 6 (SIGIOT).',)
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/billiard/pool.py", line 1175, in mark_as_worker_lost
human_status(exitcode)),
billiard.exceptions.WorkerLostError: Worker exited prematurely: signal 6 (SIGIOT).
I have tried to set the log level to "debug" but that did not give me any more information as to why the error came in the first place.
The error message always has some line like Process 'Worker-2' pid:12296 exited with 'signal 6 (SIGIOT)'. This PID is not a Linux process PID. It seems to be something used internally by celery. This seems like an issue with celery. Can someone please help in fixing this issue with celery?
Activity
ask commentedon Dec 9, 2015
What makes you think it's not a Linux process PID? Only OS processes can be signaled.
SIGIOT is an alias to SIGABRT, which means the process called the stdc
abort()function.Abort is usually called as a last resort in irrecoverable situations, like running out of memory, or file descriptors.
ask commentedon Dec 9, 2015
You should use gdb to acquire a traceback for the abort. I would guess that you are running out of memory, and that it's occurring from a C extension used by the code in the task.
rigved commentedon Dec 11, 2015
So, I monitored the process table (for processes having celery name in it) while the task was running. The PID that is shown in the log message did not show up in the process table.
I have enabled acks_late, set a long task time limit and tried using rdb from celery.contrib to see if I'm able catch the issue. But it did not help as I do not know where exactly is it getting stuck. rdb doesn't provide post-mortem debugging feature.
So, I ended up calling the function from pdb. I got a full stack trace this time and found the issue. It's not related to celery. The email ID data which I had was faulty. However, I'm wondering why celery did not provide this stack trace.
Anyways, I'm closing this issue. Thanks for pointing me in the right direction and sorry for the trouble.
ask commentedon Dec 11, 2015
celery cannot provide a stacktrace, as it's a C extension programming error