procrastinate-org / procrastinate

PostgreSQL-based Task Queue for Python
https://procrastinate.readthedocs.io/
MIT License
852 stars 52 forks source link

builtin_tasks.remove_old_jobs error #1075

Closed ewjoachim closed 3 months ago

ewjoachim commented 3 months ago

Discussed in https://github.com/procrastinate-org/procrastinate/discussions/1073

Originally posted by **@vedanthshetty-739** June 14, 2024 Hi Team, I'm using Procrastinate in one of my project. earlier i was using version 0.29.1 now moved to 2.30.0. Now I'm getting error while calling this built in `remove_old_jobs` to clean Procrastinate record., while debugging I found it's failing in sql query. error: `WHERE job.status = ANY(ARRAY['succeeded','failed'])` Could you please let us know on this issue once.
ewjoachim commented 3 months ago
earlier i was using version 0.29.1 now moved to 2.30.0.

Woo, let me know how the future looks like (the latest released version is 2.3.0) :)

Jokes apart: can you let us know the version of the PG server, and the exact error (you mentionned where the error is, which is great, but I need to know what the error is as well)

vedanthshetty-739 commented 3 months ago

@ewjoachim Thanks for the reply. I'm currently using postgres:16-alpine used postgres:11-alpine as well, in both the version i'm getting the same error.

Here is the complete traceback:

Traceback` (most recent call last):\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/procrastinate/contrib/aiopg/aiopg_connector.py\", line 31, in wrap_exceptions\n yield\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/contextlib2/__init__.py\", line 125, in inner\n return await func(*args, **kwds)\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/procrastinate/contrib/aiopg/aiopg_connector.py\", line 62, in wrapped\n return await coro(*args, **kwargs)\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/procrastinate/contrib/aiopg/aiopg_connector.py\", line 246, in execute_query_async\n await cursor.execute(query, self._wrap_json(arguments))\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/aiopg/connection.py\", line 426, in execute\n await self._conn._poll(waiter, timeout)\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/aiopg/connection.py\", line 881, in _poll\n await asyncio.wait_for(self._waiter, timeout)\n File \"/opt/conda/envs/env/lib/python3.9/asyncio/tasks.py\", line 479, in wait_for\n return fut.result()\n File \"/opt/conda/envs/env/lib/python3.9/asyncio/futures.py\", line 201, in result\n raise self._exception\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/aiopg/connection.py\", line 788, in _ready\n state = self._conn.poll()\npsycopg2.errors.UndefinedFunction: operator does not exist: procrastinate_job_status = text\nLINE 10: WHERE job.status = ANY(ARRAY['succeeded','failed'])\n ^\nHINT: No operator matches the given name and argument types. You might need to add explicit type casts.\n\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"/usr/src/python-app/async_jobs/scheduled_system_jobs.py\", line 81, in cleanup_old_jobs\n await builtin_tasks.remove_old_jobs(\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/procrastinate/builtin_tasks.py\", line 32, in remove_old_jobs\n await context.app.job_manager.delete_old_jobs(\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/procrastinate/manager.py\", line 202, in delete_old_jobs\n await self.connector.execute_query_async(\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/contextlib2/__init__.py\", line 125, in inner\n return await func(*args, **kwds)\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/contextlib2/__init__.py\", line 246, in __aexit__\n await self.gen.athrow(typ, value, traceback)\n File \"/opt/conda/envs/env/lib/python3.9/site-packages/procrastinate/contrib/aiopg/aiopg_connector.py\", line 35, in wrap_exceptions\n raise exceptions.ConnectorException from exc\nprocrastinate.exceptions.ConnectorException: \n Database error.\n "

ewjoachim commented 3 months ago

So the issue is No operator matches the given name and argument types. You might need to add explicit type casts

ewjoachim commented 3 months ago

https://github.com/procrastinate-org/procrastinate/releases/tag/2.4.0

I believe it should be fixed in the new release. Feel free to reopen if not.