Cygwin PostgreSQL postmaster abort problem

From: Jason Tishler <Jason(dot)Tishler(at)dothill(dot)com>
To: pgsql-ports(at)postgresql(dot)org
Subject: Cygwin PostgreSQL postmaster abort problem
Date: 2000-12-21 19:27:22
Message-ID: 20001221142722.A501@dothill.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-ports

While controlling the PostgreSQL JDBC driver with the following JBDC connection
pool manager:

http://sourceforge.net/projects/protomatter/

I discovered that the Cygwin PostgreSQL postmaster could abort with the
following error message:

/usr/local/pgsql/bin/postmaster: ServerLoop: select failed: No children

After much tracing of the Cygwin code, I determined that the problem was
not in the Cygwin DLL so I started to examine the relevant area of the
PostgreSQL source.

Fairly quickly, I determined and verified that the problem is in
postmaster's reaper(). When postmaster is blocked on a select() and the
JDBC client drops its connections, reaper() is fired (as a signal handler)
to clean up. Since it always calls waitpid() one more time than is
actually needed, errno is inadvertently set to ECHILD which overwrites
the EINTR value set by Cygwin's select(). Hence, when select() returns,
postmaster finds errno set to ECHILD (instead of EINTR) and exits.

The attached minimal patch solves this problem for Cygwin and has been
verified not to break PostgreSQL on Red Hat 6.2 Linux. Note that I did
not surround the added code with Cygwin specific conditional
compilation because I feel that the change is appropriate for all
platforms.

The procedure to apply this patch is as follows:

$ cd postgresql-7.0.3/src/backend/postmaster
$ # save attached patch to current directory
$ patch <Cygwin-1.1.6-PostgreSQL-7.0.3-postmaster.patch

Would someone more intimate with this area of the PostgreSQL source
critically evaluate this patch and let the list know if there is a better
way of fixing this problem?

Thanks,
Jason

--
Jason Tishler
Director, Software Engineering Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corporation Fax: +1 (732) 264-8798
82 Bethany Road, Suite 7 Email: Jason(dot)Tishler(at)dothill(dot)com
Hazlet, NJ 07730 USA WWW: http://www.dothill.com

Attachment Content-Type Size
Cygwin-1.1.6-PostgreSQL-7.0.3-postmaster.patch text/plain 419 bytes

Responses

Browse pgsql-ports by date

  From Date Subject
Next Message Jason Tishler 2000-12-27 18:58:32 Re: Postgresql as complete stand alone service
Previous Message Peter Eisentraut 2000-12-21 18:41:41 Re: [HACKERS] PostgreSQL pre-7.1 Linux/Alpha Status...