Обсуждение: Puzzling behaviour running C Function

Поиск
Список
Период
Сортировка

Puzzling behaviour running C Function

От
George Weaver
Дата:
Hi,
 
I am running PostrgreSQL 8.1 on Win X/P.
 
I have written a function in C (my first) that performs a select followed by an update.
 
The function compiles properly, installs properly and works as expected.
 
However, if I start a new shell session and install the function and immediately call the function several times consecutively, after anywhere from 3 to 7 function calls the server disconnects:
 
        server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
        The connection to the server was lost. Attempting reset: Failed.
 
On the other hand, if I install the function, end the session, start a new session and call the function, I can literally call it  a 100 times without problem.
 
On a stripped down version of the function which simply performs the select, I found that this behaviour did not occur if FOR UPDATE was not included in the select statement, but in the full function, removing FOR UPDATE only prolonged the number of times I could run the function before the server disconnected.
 
Any idea what might be causing this?
   
Thanks,
George

Re: Puzzling behaviour running C Function

От
Tom Lane
Дата:
George Weaver <gweaver@shaw.ca> writes:
> However, if I start a new shell session and install the function and =
> immediately call the function several times consecutively, after =
> anywhere from 3 to 7 function calls the server disconnects:

>         server closed the connection unexpectedly

Getting a stack trace from this core dump should be your first
investigative move.

            regards, tom lane

Re: Puzzling behaviour running C Function

От
George Weaver
Дата:
Original Message From: "Tom Lane"

> George Weaver <gweaver@shaw.ca> writes:
>> However, if I start a new shell session and install the function and =
>> immediately call the function several times consecutively, after =
>> anywhere from 3 to 7 function calls the server disconnects:
>
>>         server closed the connection unexpectedly
>
> Getting a stack trace from this core dump should be your first
> investigative move.

Hi Tom,

I cannot find any core dump.  Do I have to change the configuration in order
to have one generated?

Thanks,
George



Re: Puzzling behaviour running C Function

От
George Weaver
Дата:
> I cannot find any core dump.  Do I have to change the configuration in
> order to have one generated?

Hi Tom;

Looking over my original e-mail, I wasn't very clear where I was running the
function.  The problem occurs using psql in  a DOS shell to install and run
the function (It happens if I do the same thing in pgAdmin as well).  What
is happening is that after the function is called several times via psql,
the server disconnects the  psql session.  However, if I exit from psql and
the DOS window after installing the function, and then start a new psql
session in a new DOS window, I don't experience any problem calling the
function repeatedly.

Regards,
George