[pgpool-hackers: 40] Re: [pgpool-II 0000002]: Client connection hangs in daemon mode

Yugo Nagata nagata at sraoss.co.jp
Mon Mar 5 13:46:21 JST 2012


Hi,

I found the cause of the problem and fixed it.

Before daemonizing, openlog() opens syslog connection socket and gets
a file descriptor (fd). Then in daemonizing process, the fd is closed
as well as others. After daemonizing, pool_passwd is opened for md5
authentication and the same fd is assigned. In md5 authentication process,
syslog() is called for logging. However it fails since the used fd is
not for socket but for file. So, syslog() closed the fd and reopen new
socket using the same fd again. Then in trying to read pool_passwd, it
fails because the using fd is not for the pool_passwd file but for syslog
connection socket and then gets hangup.

I fixed the problem by calling closelog() to close syslog connection safely
before daemonizing and calling openlog() to reopen syslog connection
after daemonizing and the fix is committed already.

On Fri, 10 Feb 2012 13:45:52 +0900
Yugo Nagata <nagata at sraoss.co.jp> wrote:

> I had a similar problem in daemon mode and when log_destination = 'syslog'.
> But, it seems there is no problem in foreground mode (with -n option) or when log_destination ='stderr'.
> I will work on this issue and report back to the list.
> 
> Yugo Nagata
> 
> > 
> > The following issue has been SUBMITTED. 
> > ====================================================================== 
> > http://www.pgpool.net/mantisbt/view.php?id=2 
> > ====================================================================== 
> > Reported By:                tuomas
> > Assigned To:                
> > ====================================================================== 
> > Project:                    pgpool-II
> > Issue ID:                   2
> > Category:                   Bug
> > Reproducibility:            always
> > Severity:                   major
> > Priority:                   normal
> > Status:                     new
> > ====================================================================== 
> > Date Submitted:             2012-02-06 22:39 JST
> > Last Modified:              2012-02-06 22:39 JST
> > ====================================================================== 
> > Summary:                    Client connection hangs in daemon mode
> > Description: 
> > The issues happens at least with md5 pool authentication enabled
> > 
> > pgpool version 3.1.2
> > postgresql 9.1
> > 
> > pg_hba.conf:
> > host    all             all             0.0.0.0/0               md5
> > 
> > pool_hba.conf:
> > host    all             all             0.0.0.0/0               md5
> > 
> > pgpool.conf:
> > streaming master-slave configuration is used. ssl = off in pgpool and server.
> > enable_pool_hba = on
> > authentication_timeout = 5
> > 
> > user/password pair generated by pg_md5 is in pool_passwd.
> > 
> > when trying to connect to pgpool, by i.e.
> > $ psql --host=127.0.0.1 --user=username -d template1
> > 
> > The "pgpool: accept connection" and the psql process just hang up forever.
> > Nothing happens, no errors in pgpool or stdout/err.
> > 
> > In postgresql server log is an error:
> > 2012-02-06 13:15:38.636 UTC LOG:  connection received: host=10.x.x.x port=45207
> > 2012-02-06 13:15:38.639 UTC LOG:  could not receive data from client: Connection
> > reset by peer
> > 2012-02-06 13:15:38.639 UTC LOG:  unexpected EOF within message length word
> > 
> > In debug mode I get the following to syslog:
> > Feb  6 13:33:57 qa01 pgpool[18845]: I am 18845 accept fd 6
> > Feb  6 13:33:57 qa01 pgpool[18845]: connection received: host=localhost
> > port=46606
> > Feb  6 13:33:57 qa01 pgpool[18845]: Protocol Major: 1234 Minor: 5679 database: 
> > user:
> > Feb  6 13:33:57 qa01 pgpool[18845]: SSLRequest from client
> > Feb  6 13:33:57 qa01 pgpool[18845]: pool_ssl: SSL requested but SSL support is
> > not available
> > Feb  6 13:33:57 qa01 pgpool[18845]: read_startup_packet: application_name: psql
> > Feb  6 13:33:57 qa01 pgpool[18845]: Protocol Major: 3 Minor: 0 database: yyy
> > user: xxx
> > 
> > Nothing after that.
> > 
> > Strangely enough, everything seem to work fine if i run pgpool in foreground
> > mode with -n.
> > 
> > 
> > 
> > 
> > ====================================================================== 
> > 
> > Issue History 
> > Date Modified    Username       Field                    Change               
> > ====================================================================== 
> > 2012-02-06 22:39 tuomas         New Issue                                    
> > ======================================================================
> > 
> _______________________________________________
> pgpool-hackers mailing list
> pgpool-hackers at pgpool.net
> http://www.pgpool.net/mailman/listinfo/pgpool-hackers
> 
> 
> -- 
> Yugo Nagata <nagata at sraoss.co.jp>
> SRA OSS, Inc. Japan
> _______________________________________________
> pgpool-hackers mailing list
> pgpool-hackers at pgpool.net
> http://www.pgpool.net/mailman/listinfo/pgpool-hackers


-- 
Yugo Nagata <nagata at sraoss.co.jp>
SRA OSS, Inc. Japan


More information about the pgpool-hackers mailing list