stack depth limit exceeded problem.

From: Thomas Hallgren <thhal(at)mailblocks(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: stack depth limit exceeded problem.
Date: 2005-09-23 11:19:12
Message-ID: thhal-0M30PBNNj8bQdPq3v1hY+Wm4FCVXgqW@mailblocks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I have a problem with PL/Java that, if it's going to have a good
solution, requires your help.

PL/Java runs a JVM. Since a JVM is multi threaded, PL/Java goes to
fairly extreme measures to ensure that only one thread at a time can
access the backend. So far, this have worked well but there is one small
problem. Here's a use-case:

Someone loads a library that contains a method that spawns a new thread.
That thread is the first to access some class. The class loader will now
make an attempt to load it. PL/Java uses SPI to load classes so a call
is made to SPI. This call is not made from the main thread that
originally called the PL/Java function. That thread is suspended at this
point.

Now, the check_stack_depth() in postgres.c is called. The new thread has
a stack of it's own of course, so it fails.

I know that multi threading is very controversial and I'm in no way
asking that the backend should support it. What I would like is a
workaround for my problem. The easiest way would be if I could change
the stack_base_ptr temporarily when this happens, a try/catch that kicks
in when I detect a call from a thread other then main. The only other
solution is to set the max_stack_depth to a ridiculously high value and
effectively turn stack checking off. I don't want to do that.

Any opinions on this?

Kind regards,
Thomas Hallgren

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paesold 2005-09-23 11:43:40 Re: What has happened to pgxs?
Previous Message Simon Riggs 2005-09-23 10:56:32 Re: R: Table Partitioning is in 8.1