Arb*_*ain 9 django postgresql django-models django-views postgresql-9.1
File "/usr/local/lib/python3.7/dist-packages/psycopg2/__init__.py", line 126, in connect conn = _connect(dsn, connection_factory=connection_factory, **kwasync)
django.db.utils.OperationalError: FATAL: remaining connection slots are reserved for non-replication superuser connections
Run Code Online (Sandbox Code Playgroud)
根据 Postgres 文档,当 Django 与 Postgres DB 建立的连接数量超过默认连接限制时,就会发生此错误。
#settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'xxxxx',
'USER': 'xxxxx',
'PASSWORD':'xxxxx',
'HOST':'localhost',
'PORT':'5432',
}
Run Code Online (Sandbox Code Playgroud)
小智 1
我相信这是由于 Django 框架不进行数据库池而发生的。查看 Django 文档(https://docs.djangoproject.com/en/3.2/ref/databases/#transaction-pooling-and-server-side-cursors)我可以找到对用户 pgBouncer 的建议(http://www .pgbouncer.org/)来处理这个问题。
| 归档时间: |
|
| 查看次数: |
8901 次 |
| 最近记录: |