Skip to content

Worker process killed during run_maintenance_tasks() #726

Description

@tdruez
make log SERVICE=worker
scancodeio-worker-1  | INFO 2023-05-11 16:26:44.90 Progress: 90% (307,711/341,901) ETA: 17 seconds
scancodeio-worker-1  | 16:27:09 Sent heartbeat to prevent worker timeout. Next one should arrive within 90 seconds.
scancodeio-worker-1  | 16:28:05 Received message: {'type': 'message', 'pattern': None, 'channel': b'rq:pubsub:42ab127f8898470e95b6db849e3db6e3', 'data': b'{"command": "stop-job", "job_id": "7959f197-87f8-4a0e-ac5d-9c06c41edd3c"}'}
scancodeio-worker-1  | 16:28:05 Received command to stop job 7959f197-87f8-4a0e-ac5d-9c06c41edd3c
scancodeio-worker-1  | 16:28:05 Killed horse pid 29
scancodeio-worker-1  | 16:28:05 Job stopped by user, moving job to FailedJobRegistry
scancodeio-worker-1  | 16:28:05 Handling failed execution of job 7959f197-87f8-4a0e-ac5d-9c06c41edd3c
scancodeio-worker-1  | 16:28:05 Sent heartbeat to prevent worker timeout. Next one should arrive within 480 seconds.
scancodeio-worker-1  | 16:28:05 Cleaning registries for queue: default
scancodeio-worker-1  | INFO Synchronizing QUEUED and RUNNING Run with their related Jobs...
scancodeio-worker-1  | 16:28:06 Worker rq:worker:42ab127f8898470e95b6db849e3db6e3: found an unhandled exception, quitting...
scancodeio-worker-1  | Traceback (most recent call last):
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 98, in inner
scancodeio-worker-1  |     return func(*args, **kwargs)
scancodeio-worker-1  |            ^^^^^^^^^^^^^^^^^^^^^
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/psycopg/cursor.py", line 829, in fetchmany
scancodeio-worker-1  |     self._check_result_for_fetch()
scancodeio-worker-1  | 16:28:06 Registering death
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/psycopg/cursor.py", line 606, in _check_result_for_fetch
scancodeio-worker-1  |     raise e.ProgrammingError("the last operation didn't produce a result")
scancodeio-worker-1  | psycopg.ProgrammingError: the last operation didn't produce a result
scancodeio-worker-1  |
scancodeio-worker-1  | The above exception was the direct cause of the following exception:
scancodeio-worker-1  |
scancodeio-worker-1  | Traceback (most recent call last):
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/rq/worker.py", line 780, in work
scancodeio-worker-1  |     self.run_maintenance_tasks()
scancodeio-worker-1  |   File "/app/scancodeio/worker.py", line 54, in run_maintenance_tasks
scancodeio-worker-1  |     scanpipe_app.sync_runs_and_jobs()
scancodeio-worker-1  |   File "/app/scanpipe/apps.py", line 201, in sync_runs_and_jobs
scancodeio-worker-1  |     if queued_or_running:
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 412, in __bool__
scancodeio-worker-1  |     self._fetch_all()
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1881, in _fetch_all
scancodeio-worker-1  |     self._result_cache = list(self._iterable_class(self))
scancodeio-worker-1  |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 91, in __iter__
scancodeio-worker-1  |     results = compiler.execute_sql(
scancodeio-worker-1  |               ^^^^^^^^^^^^^^^^^^^^^
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1593, in execute_sql
scancodeio-worker-1  |     return list(result)
scancodeio-worker-1  |            ^^^^^^^^^^^^
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 2091, in cursor_iter
scancodeio-worker-1  |     for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 2091, in <lambda>
scancodeio-worker-1  |     for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
scancodeio-worker-1  |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 97, in inner
scancodeio-worker-1  |     with self:
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
scancodeio-worker-1  |     raise dj_exc_value.with_traceback(traceback) from exc_value
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 98, in inner
scancodeio-worker-1  |     return func(*args, **kwargs)
scancodeio-worker-1  |            ^^^^^^^^^^^^^^^^^^^^^
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/psycopg/cursor.py", line 829, in fetchmany
scancodeio-worker-1  |     self._check_result_for_fetch()
scancodeio-worker-1  |   File "/usr/local/lib/python3.11/site-packages/psycopg/cursor.py", line 606, in _check_result_for_fetch
scancodeio-worker-1  |     raise e.ProgrammingError("the last operation didn't produce a result")
scancodeio-worker-1  | django.db.utils.ProgrammingError: the last operation didn't produce a result
scancodeio-worker-1  | 16:28:06 Unsubscribing from channel rq:pubsub:42ab127f8898470e95b6db849e3db6e3

It seems that a pipeline Run was manually stopped. The run_maintenance_tasks is eventually called by the worker, triggering the scanpipe_app.sync_runs_and_jobs().
The exception is raised when evaluating the Django QuerySet:

run_model.objects.queued_or_running()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions