django - Pgbouncer 关闭连接

标签 django postgresql unix pgbouncer

我最近为连接池设置了 pgbouncer。我的 pgbouncer.ini 文件包含

[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

我使用 Django 通过以下配置命中 pgbouncer

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

当我运行该应用程序时,一切似乎都运行良好。但是在 pgbouncer 日志记录中,我得到以下日志,这些日志经常重复发生。

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)

我不知道这是指什么。这会不会是什么阴险的事情?我在配置中搞砸了什么吗?

最佳答案

Django 在每次请求后关闭与数据库的连接,似乎是这样。您可以尝试将 CONN_MAX_AGE = 60 添加到您的设置中并重试吗?

关于django - Pgbouncer 关闭连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45575752/

相关文章:

java - Jdbc Postgresql 没有执行查询

sql - 迁移后 PostgreSQL 性能下降

linux - 用于在内核空间中捕获数据包的缓冲区大小?

mysql - 查看/分析 Django 中的所有数据库访问

Django Haystack 拒绝显示任何结果,即使是荒谬的查询

Django-rest-auth 使用 cookie 而不是 Authorization header

django,在 SQL 中忽略 CharField 默认值

arrays - PostgreSQL 索引 JSONB 数组

linux - Shell脚本时间控制

linux - 将 FreeBSD 作为本地开发服务器