1

I recently set up pgbouncer for connection pooling. My pgbouncer.ini file contains

[databases]
mydb = host=localhost port=5432 user=user dbname=mydb

[pgbouncer]
auth_type = any
auth_file = /etc/pgbouncer/users.txt
listen_addr = 127.0.0.1
listen_port = 6432

pool_mode = session

server_reset_query = DISCARD ALL

; total number of clients that can connect
max_client_conn = 100

default_pool_size = 20

I use Django to hit pgbouncer with the following config

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'mydb',
        'USER': 'user',
        'PASSWORD': '',
        'HOST': 'localhost',
        'PORT': '6432',
    },
}

when I run the app everything seems to work fine. But in the pgbouncer logging I get the following logs, which happen repeatedly and often.

2017-08-08 14:36:25.626 1215 WARNING tune_socket(11) failed: Invalid argument
2017-08-08 14:36:25.626 1215 LOG C-0x7ff2d081b590: (nodb)/(nouser)@unix:6432 closing because: client unexpected eof (age=0)

I have no idea what this refers to. Could this be anything insidious? Have I messed up something in the config?

Jonathan Viccary
  • 722
  • 1
  • 9
  • 27

1 Answers1

0

Django closes the connection to the db after every request, that seems the case. Can you try to add CONN_MAX_AGE = 60 to your settings and try again?

Mattia Procopio
  • 631
  • 8
  • 16