Postgres SSL SYSCALL error: EOF detected with python and psycopg

前端 未结 7 1806
误落风尘
误落风尘 2020-12-15 03:40

Using psycopg2 package with python 2.7 I keep getting the titled error: psycopg2.DatabaseError: SSL SYSCALL error: EOF detected

It only occurs when I add a WHE

相关标签:
7条回答
  • 2020-12-15 03:50

    In my case that was OOM killer (query is too heavy)

    Check dmesg:

    dmesg | grep -A2 Kill
    

    In my case:

    Out of memory: Kill process 28715 (postgres) score 150 or sacrifice child
    
    0 讨论(0)
  • 2020-12-15 03:53

    Very similar answer to what @FoxMulder900 did, except I could not get his first select to work. This works, though:

    WITH long_running AS (
        SELECT pid, now() - pg_stat_activity.query_start AS duration, query, state
        FROM pg_stat_activity
        WHERE (now() - pg_stat_activity.query_start) > interval '1 minutes'
          and state = 'active'
    )
    SELECT * from long_running;
    

    If you want to kill the processes from long_running just comment out the last line and insert SELECT pg_cancel_backend(long_running.pid) from long_running ;

    0 讨论(0)
  • 2020-12-15 04:02

    I ran into this problem when running a slow query in a Droplet on a Digital Ocean instance. All other SQL would run fine and it worked on my laptop. After scaling up to a 1 GB RAM instance instead of 512 MB it works fine so it seems that this error could occur if the process is running out of memory.

    0 讨论(0)
  • 2020-12-15 04:04

    I got this error running a large UPDATE statement on a 3 million row table. In my case it turned out the disk was full. Once I had added more space the UPDATE worked fine.

    0 讨论(0)
  • 2020-12-15 04:08

    This issue occurred for me when I had some rogue queries running causing tables to be locked indefinitely. I was able to see the queries by running:

    SELECT * from STV_RECENTS where status='Running' order by starttime desc;
    

    then kill them with:

    SELECT pg_terminate_backend(<pid>);
    
    0 讨论(0)
  • 2020-12-15 04:11

    You may need to express % as %% because % is the placeholder marker. http://initd.org/psycopg/docs/usage.html#passing-parameters-to-sql-queries

    0 讨论(0)
提交回复
热议问题