psycopg2 + pgbouncer + gevent 응용 프로그램이 있습니다. 비동기 응용 프로그램, 즉 하나의 프로세스가 여러 요청을 처리합니다. 데이터베이스에 대한 비동기식 액세스는 psycopg2의 최신 버전에 나타났습니다 (2.2가 아닌 경우). 그러나 이번 릴리스에서는 pgbouncer와 많은 단절이있는 버그를 소개합니다. pgbouncer 로그에서 는 항목이 :psycopg2 + pgbouncer. gevent 오류가있는 비동기 모드
2011-10-04 12:16:38.972 4590 LOG C-0x1b3f490: database/[email protected]:43849 login successful: db=database user=user
2011-10-04 12:16:38.972 4590 LOG C-0x1b3f0a0: database/[email protected]:43850 login successful: db=database user=user
2011-10-04 12:16:38.973 4590 LOG C-0x1b40840: database/[email protected]:43802 closing because: client close request (age=0)
2011-10-04 12:16:38.973 4590 LOG S-0x1b5cd80: database/[email protected]:5432 closing because: unclean server (age=0)
2011-10-04 12:16:38.976 4590 LOG C-0x1b3ef50: database/[email protected]:43825 closing because: client close request (age=0)
2011-10-04 12:16:38.976 4590 LOG S-0x1b5e520: database/[email protected]:5432 closing because: unclean server (age=0)
2011-10-04 12:16:38.977 4590 LOG S-0x1b5e520: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.979 4590 LOG C-0x1b3f340: database/[email protected]:43791 closing because: client close request (age=0)
2011-10-04 12:16:38.979 4590 LOG S-0x1b5d410: database/[email protected]:5432 closing because: unclean server (age=0)
2011-10-04 12:16:38.980 4590 LOG S-0x1b5d410: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.983 4590 LOG S-0x1b5cd80: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.987 4590 LOG S-0x1b5dbf0: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.990 4590 LOG S-0x1b5c1b0: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.992 4590 LOG C-0x1b3ff10: database/[email protected]:43854 login successful: db=database user=user
2011-10-04 12:16:38.995 4590 LOG S-0x1b5c450: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.996 4590 LOG C-0x1b3f340: database/[email protected]:43855 login successful: db=database user=user
2011-10-04 12:16:38.996 4590 LOG C-0x1b3ee00: database/[email protected]:43828 closing because: client close request (age=0)
2011-10-04 12:16:38.998 4590 LOG S-0x1b5c300: database/[email protected]:5432 new connection to server
2011-10-04 12:16:38.999 4590 LOG C-0x1b3f1f0: database/[email protected]:43805 closing because: client close request (age=0)
2011-10-04 12:16:38.999 4590 LOG S-0x1b5daa0: database/[email protected]:5432 closing because: unclean server (age=0)
2011-10-04 12:16:39.010 4590 LOG C-0x1b41410: database/[email protected]:43655 closing because: client close request (age=1)
2011-10-04 12:16:39.010 4590 LOG S-0x1b5d2c0: database/[email protected]:5432 closing because: unclean server (age=1)
2011-10-04 12:16:39.011 4590 LOG S-0x1b5d2c0: datab+ase/[email protected]:5432 new connection to server
2011-10-04 12:16:39.014 4590 LOG C-0x1b3fc70: database/[email protected]:43818 closing because: client close request (age=0)
2011-10-04 12:16:39.014 4590 LOG S-0x1b5d170: database/[email protected]:5432 closing because: unclean server (age=0)
2011-10-04 12:16:39.042 4590 LOG C-0x1b40990: database/[email protected]:43822 closing because: client close request (age=0)
2011-10-04 12:16:39.042 4590 LOG S-0x1b5de90: database/[email protected]:5432 closing because: unclean server (age=0)
2011-10-04 12:16:39.043 4590 LOG C-0x1b40060: database/[email protected]:43820 closing because: client close request (age=0)
2011-10-04 12:16:39.043 4590 LOG S-0x1b5e280: database/[email protected]:5432 closing because: unclean server (age=0)
어쩌면 부정 서버에 대한 메시지를 피하기 위해, pgbouncer를 구성 할 수있는 방법이있다? Information about a bug처럼 치료할 수있는 패치가 있습니다. 우분투 저장소의 모든 패키지는 프로덕션 시스템에 패치를 적용합니다. 좋은 옵션은 아닙니다. 내 구성 pgboucner :
[pgbouncer]
logfile = /var/log/postgresql/pgbouncer.log
pidfile = /var/run/postgresql/pgbouncer.pid
listen_addr = *
listen_port = 6432
unix_socket_dir = /var/run/postgresql
pool_mode = session
server_reset_query = DISCARD ALL;
server_check_query = select 1
server_check_delay = 10
max_client_conn = 1000
default_pool_size = 200
log_connections = 1
log_disconnections = 1
흠. 연결을 닫으면 각 요청마다 db에 다시 연결해야합니까? 지속성 연결을 사용할 수 있다고 생각합니다. – exabiche
아니, 사실은 커밋 또는 롤백 중 하나라고 생각합니다. 우리가보고 한 바에 따르면, "트랜잭션 중"상태의 pgpool에 연결이 반환되면 "부정한 서버"가보고됩니다. 시스템을 떠나는 연결의''.status'' 속성을 모니터링 해보십시오. – piro
나는 '가까운'방법을 사용 - '닫힌 연결을 사용할 수 없습니다'와 같은 버그가 있습니다. 그렇다면 내가 '커밋'방법을 사용 - 부정한 서버 붕괴에 대한 오류 메시지를하지만, pgbouncer 로그에서 나는 db에 연결하고 연결 해제에 관한 많은 메시지를 받았습니다. 퍼시스턴스 연결을 사용할 수 있습니까? http://pastebin.com/GNpNJrPk – exabiche