Subject: [4.2] regression test (fstest) failure

From: [email-masked] (Tom R.Hageman)
Date: Wed, 12 Oct 94 17:02:51 +0100

Well, I've nearly finished my port of postgres 4.2 to NeXTSTEP except for a  
small (yeah:-) nit.

It --sometimes, not always-- fails to pass the regression test, with the  
following error message:

#
# - relative prmdir
#
prmdir relative_dir \
	|| exit 1
p_rmdir: p_errno=1, relative_dir: Error 0
the Inversion file system test causes an error

Symptoms:
- When run repeatedly it failed 70 out of 500 times on my machine (33MHz m68k).   
- On a slower machine it seems to fails more often.
- When I add "sleep 1" before the prmdir the test runs fine.

All this suggests a timing problem (in postmaster?) so I added some code to  
block SIGCHLD signals when a request is being handled in  
postmaster/postmaster.c.  This didn't help (although it should prevent the  
occasional postmaster hangups that I was experiencing.  It is a good idea  
anyway since the SIGCHLD handler manipulates (and frees) global  
datastructures...) so now I'm stumped.

Any ideas?

BTW this is plain 4.2 with aoki's postmaster patches applied.

Thanks in advance,
Tom.

FYI here are my changes to the postmaster:

*** %postmaster.c	Fri Sep  9 01:55:25 1994
--- postmaster.c	Sat Oct  8 15:23:48 1994
*************** ServerLoop(serverFd)
*** 354,357 ****
--- 354,358 ----
      int		nSockets, nSelected, status, newFd;
      PortNode	*prev, *curr;
+     int		orgsigmask = sigblock(0);	/* XXX[TRH] portability */

      nSockets = ServerSock + 1;
*************** ServerLoop(serverFd)
*** 360,363 ****
--- 361,365 ----

      for (;;) {
+ 	sigsetmask(orgsigmask);			/* XXX[TRH] portability */
  	newFd = -1;
  	bcopy((char *) &basemask, (char *) &rmask, sizeof(fd_set));
*************** ServerLoop(serverFd)
*** 372,375 ****
--- 374,385 ----
  	    return(STATUS_ERROR);
  	}
+ 	/* [TRH  8-Oct-94]
+ 	 * To avoid race conditions, block SIGCHLD signals while we are
+ 	 * handling the request. (both reaper() and ConnCreate()
+ 	 * manipulate the BackEnd list, and reaper() calls free() which is
+ 	 * usually non-reentrant.)
+ 	 */
+ 	sigblock(sigmask(SIGCHLD));		/* XXX[TRH] portability */
+ 

  	if (DebugLvl > 1) {
  	    fprintf(stderr, "%s: ServerLoop: %d sockets pending\n",

--
__/__/__/__/  Tom Hageman   <[email-masked]>   [NeXTMail accepted]
  __/ __/_/
 __/__/__/          "...to baldly go where no one has gone before."
__/  _/_/                                             -- star trek TNG

==============================================================================
   To add/remove yourself to/from the POSTGRES mailing list: send mail with 
   the subject line ADD or DEL to "[email-masked]"

   If this fails, send mail to "[email-masked]" and
   a human will deal with it.  DO NOT post to the "postgres" mailing list.
==============================================================================