From 09fda54100e5fa73ddcfa71645fac8c76fd51e38 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Fri, 25 Mar 2011 23:55:03 +0200 Subject: [PATCH] Turn on tcp_keepalive by default. This gives pgbouncer same behaviour as Postgres, as Postgres does it unconditionally. Noticed by Hubert Depesz Lubaczewski. --- doc/config.txt | 7 ++++++- etc/pgbouncer.ini | 2 +- src/main.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/config.txt b/doc/config.txt index 95dcd62..10faebc 100644 --- a/doc/config.txt +++ b/doc/config.txt @@ -395,7 +395,12 @@ Default: not set ==== tcp_keepalive ==== -Default: not set +Turns on basic keepalive with OS defaults. + +On Linux, the system defaults are tcp_keepidle=7200, tcp_keepintvl=75, +tcp_keepcnt=9. They are probably similar on other OS-es. + +Default: 1 ==== tcp_keepcnt ==== diff --git a/etc/pgbouncer.ini b/etc/pgbouncer.ini index cc53b8c..e3c452d 100644 --- a/etc/pgbouncer.ini +++ b/etc/pgbouncer.ini @@ -182,7 +182,7 @@ log_pooler_errors = 1 ;tcp_socket_buffer = 0 ;; whether tcp keepalive should be turned on (0/1) -;tcp_keepalive = 0 +;tcp_keepalive = 1 ;; following options are linux-specific. ;; they also require tcp_keepalive=1 diff --git a/src/main.c b/src/main.c index da0c121..b7597a7 100644 --- a/src/main.c +++ b/src/main.c @@ -202,7 +202,7 @@ CF_ABS("pkt_buf", CF_INT, cf_sbuf_len, CF_NO_RELOAD, "2048"), CF_ABS("sbuf_loopcnt", CF_INT, cf_sbuf_loopcnt, 0, "5"), CF_ABS("tcp_defer_accept", DEFER_OPS, cf_tcp_defer_accept, 0, NULL), CF_ABS("tcp_socket_buffer", CF_INT, cf_tcp_socket_buffer, 0, "0"), -CF_ABS("tcp_keepalive", CF_INT, cf_tcp_keepalive, 0, "0"), +CF_ABS("tcp_keepalive", CF_INT, cf_tcp_keepalive, 0, "1"), CF_ABS("tcp_keepcnt", CF_INT, cf_tcp_keepcnt, 0, "0"), CF_ABS("tcp_keepidle", CF_INT, cf_tcp_keepidle, 0, "0"), CF_ABS("tcp_keepintvl", CF_INT, cf_tcp_keepintvl, 0, "0"), -- 2.39.5