I wrote:
> One possibility for fixing it is that maybe we should be making an
> effort to execute Tcl_Finalize() before exiting the backend.  If so,
> having pltcl set up an on_proc_exit callback to do it would be the
> appropriate thing.  This is all speculation though.

Just for grins I tried this, and I can see by strace'ing that it changes
the process-shutdown-time behavior quite a lot: the secondary thread now
exits first, apparently after being told to via a message from the
primary.  So I think this might indeed be something good to do.  Would
you try the attached patch and see if it changes the behavior on your
systems?  (This patch is very ugly and will draw compiler warnings, but
don't worry about that yet.)

                        regards, tom lane

Index: pltcl.c
RCS file: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v
retrieving revision 1.108
diff -c -r1.108 pltcl.c
*** pltcl.c     4 Oct 2006 00:30:14 -0000       1.108
--- pltcl.c     28 Jan 2007 21:45:40 -0000
*** 26,31 ****
--- 26,32 ----
  #include "fmgr.h"
  #include "nodes/makefuncs.h"
  #include "parser/parse_type.h"
+ #include "storage/ipc.h"
  #include "tcop/tcopprot.h"
  #include "utils/builtins.h"
  #include "utils/lsyscache.h"
*** 245,250 ****
--- 246,253 ----
        if (!pltcl_be_init_done)
+                       on_proc_exit(Tcl_Finalize, 0);
                if (SPI_connect() != SPI_OK_CONNECT)
                        elog(ERROR, "SPI_connect failed");

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Reply via email to