django-q
django-q copied to clipboard
psycopg2.OperationalError: SSL SYSCALL error: EOF detected django Qcluster
Hi I'm trying to run a function as a background job from Django Qcluster and that jobs run for more than an hour based on the response of that job I update my Postgres table but when I get response from Qcluster and try to update the table it gives me this error
psycopg2.OperationalError: SSL SYSCALL error: EOF detected.
Qcluster settings:
Q_CLUSTER = { 'name': 'sampleapp', 'workers': 8, 'recycle': 500, 'compress': True, 'save_limit': 250, 'queue_limit': 500, 'cpu_affinity': 1, 'label': 'Django Q', 'max_attempts': 1, 'attempt_count': 1, 'catch_up': False, 'redis': { 'host': '127.0.0.1', 'port': 6379, 'db': 0, } }
Django==3.1.7
django-q==1.3.9
Here is the complete stacktrace:
SSL SYSCALL error: EOF detected
15:36:35 [Q] ERROR Failed [kentucky-montana-west-alaska] - connection already closed : Traceback (most recent call last): File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params)
psycopg2.OperationalError: SSL SYSCALL error: EOF detected
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/connector/sync_utils.py", line 1361, in run_data_sync if not table_pipeline_json.count(): File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/query.py", line 411, in count return self.query.get_count(using=self.db) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 515, in get_count number = obj.get_aggregation(using, ['__count'])['__count'] File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/sql/query.py", line 500, in get_aggregation result = compiler.execute_sql(SINGLE) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1156, in execute_sql cursor.execute(sql, params) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 98, in execute return super().execute(sql, params) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/sentry_sdk/integrations/django/__init__.py", line 500, in execute return real_execute(self, sql, params) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 66, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers return executor(sql, params, many, context) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/utils.py", line 84, in _execute return self.cursor.execute(sql, params)
django.db.utils.OperationalError: SSL SYSCALL error: EOF detected
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 237, in _cursor return self._prepare_cursor(self.create_cursor(name)) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 236, in create_cursor cursor = self.connection.cursor()
psycopg2.InterfaceError: connection already closed
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django_q/cluster.py", line 381, in worker res = f(*task['args'], **task['kwargs']) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/connector/sync_utils.py", line 1858, in run_data_sync save_batch_error(parent_batch_obj, response, integration_obj) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/batchesapi/utils.py", line 13, in save_batch_error batch_obj.save() File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/base.py", line 753, in save self.save_base(using=using, force_insert=force_insert, File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/base.py", line 790, in save_base updated = self._save_table( File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/base.py", line 872, in _save_table updated = self._do_update(base_qs, using, pk_val, values, update_fields, File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/base.py", line 926, in _do_update return filtered._update(values) > 0 File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/query.py", line 803, in _update return query.get_compiler(self.db).execute_sql(CURSOR) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1522, in execute_sql cursor = super().execute_sql(result_type) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1154, in execute_sql cursor = self.connection.cursor() File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 259, in cursor return self._cursor() File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 237, in _cursor return self._prepare_cursor(self.create_cursor(name)) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/utils.py", line 90, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/base/base.py", line 237, in _cursor return self._prepare_cursor(self.create_cursor(name)) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) File "/mnt/c/lyftrondatasync/LyftrondatasyncAPI/venv/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 236, in create_cursor cursor = self.connection.cursor()
django.db.utils.InterfaceError: connection already closed
Hi guys anyone has any idea how to fix above error?
Hi,
Are you running with CONN_MAX_AGE > 0 in django setttings ?
If yes please check https://github.com/Koed00/django-q/pull/604 It could easily be the same issue that can translate in a variety of error messages.