This seems to be an OOM exception, thus leads to db disconnection.
OperationalError: (psycopg2.OperationalError) SSL SYSCALL error: EOF detected
Retrying with exponential backoff could help.
Ref: https://stackoverflow.com/questions/24130305/postgres-ssl-syscall-error-eof-detected-with-python-and-psycopg https://github.com/psycopg/psycopg2/issues/533 https://dba.stackexchange.com/questions/175085/postgresql-ssl-syscall-error-eof-detected