Hello,
I have a problem with a SRF. In the first call, another external
function is called. This function returns some allocated memory, and
allocate/free more memory during its execution (I think there's no
memory leaks in it...). Before calling the function, I change to a
memory context appropiate for multiple calls. This is:
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);
Just like in the example from
http://www.postgresql.org/docs/8.4/interactive/xfunc-c.html (section
34.9.10)
In each sequential call, I access one of the elements returned by the
external function in first call. Everything works fine, until the last
call:
if (call_cntr < max_calls)
{
// everything works fine here
// BuildTupleFromCStrings, HeapTupleGetDatum...
}
else
{
// crashes here!!!
SRF_RETURN_DONE(funcctx);
}
At this point (SRF_RETURN_DONE) I get this error:
WARNING: terminating connection because of crash of another server process
DETAIL: The postmaster has commanded this server process to roll back
the current transaction and exit, because another server process
exited abnormally and possibly corrupted shared memory.
HINT: In a moment you should be able to reconnect to the database and
repeat your command.
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: Succeeded.
In the log file:
2010-05-20 17:00:36 CEST LOG: 00000: system logger process (PID
24896) was terminated by signal 9: Killed
2010-05-20 17:00:36 CEST LOCATION: LogChildExit, postmaster.c:2727
2010-05-20 17:00:36 CEST LOG: 00000: background writer process (PID
8702) was terminated by signal 9: Killed
2010-05-20 17:00:36 CEST LOCATION: LogChildExit, postmaster.c:2727
2010-05-20 17:00:37 CEST LOG: 00000: terminating any other active
server processes
2010-05-20 17:00:37 CEST LOCATION: HandleChildCrash, postmaster.c:2554
2010-05-20 17:00:37 CEST WARNING: 57P02: terminating connection
because of crash of another server process
2010-05-20 17:00:37 CEST DETAIL: The postmaster has commanded this
server process to roll back the current transaction and exit, because
another server process exited abnormally and possibly corrupted shared
memory.
2010-05-20 17:00:37 CEST HINT: In a moment you should be able to
reconnect to the database and repeat your command.
2010-05-20 17:00:37 CEST LOCATION: quickdie, postgres.c:2495
What could be the problem? It doesn't crash always. Depends on my
input data (the data used by the external function I call at the
begginning)
Thanks in advance, and best regards,
Jorge
----
http://www.gis4free.org/blog