Subject: Postgres can't keep up???

From: [email-masked] (Munir Cochinwala)
Date: Thu, 2 Apr 92 11:41:34 -0800

Hi,

I have a libpq program as follows:

main (argc, argv)
int argc;
char *argv[];
{
    char *status;
    char my_buf[10000];
    FILE *fp;

    bzero(my_buf, 10000);
    fp = fopen("test.log","r");
    PQsetdb ("kasey");
    
    while ((fgets(my_buf, 9999, fp)) != NULL){

         status = PQexec (my_buf);
         printf("status of update %s\n", status);
         bzero(my_buf, 10000);
    	 PQreset ();
         sleep(2);
    }
    
    PQfinish ();
}

The file "test.log" consists of transactions, one per line:
Example: begin append(...) append (....) replace .. end

Note: There is no read in any transaction. All transactions consist of 
appends, deletes and replace only.

The problem is as follows:

If I eliminate "sleep(2)" then the program aborts with one of the following
messages:

>> backend not responding >>
  or 
NOTICE:Apr  2 13:49:53:I have been signalled by the postmaster.

NOTICE:Apr  2 13:49:53:Some backend process has died unexpectedly and possibly

NOTICE:Apr  2 13:49:53:corrupted shared memory.  The current transaction was

NOTICE:Apr  2 13:49:53:aborted, and I am going to exit.  Please resend the

NOTICE:Apr  2 13:49:53:last query. -- The postgres backend

The last line in the above message keeps on repeating.

If I get rid of reset in the program, then the status returned by the first
transaction is CBEGIN, the status returned by the second transaction is
CEND and then the program stops without any message.

Could somebody explain the above behavior?

Thanks, 

Munir Cochinwala

---

From: postarch (Postgres Mailing Archive)
Date: Fri, 03 Apr 92 13:51:59 PST

> appends, deletes and replace only.

Don't do PQreset() in your while loop.  This causes the existing connection
to the backend to be closed, and the next PQexec then has to re-open one.
Every time a new connection is made you are starting another backend process.

> NOTICE:Apr  2 13:49:53:Some backend process has died unexpectedly and possibl
 +y
> The last line in the above message keeps on repeating.

The repeating NOTICE was a problem with the front-end reading messages from
an "undead" socket (i.e. after the backend has crashed).  It will go away in
the new release.  Are other users running concurrently?

> Could somebody explain the above behavior?

I could not get this to happen.  Make sure you are running the queries
you think you are running.

Jeff Meredith
[email-masked]