Thread: Re: [Pljava-dev] stack depth limit exceeded - patch possible?

Re: [Pljava-dev] stack depth limit exceeded - patch possible?

From
Kris Jurka
Date:

On Sat, 12 Apr 2008, Alexander W�hrer wrote:

> I'm working on Windows XP SP2 (stack limit 3500 kb) and deployed
> successfully my application (doing some external Web service calling)
> inside PostGre 8.3.0.
>
> Unfortunatelly, the application needs at least 3 Threads and will run
> for quite some time.
>
> I found this comment
>
> http://pgfoundry.org/pipermail/pljava-dev/2005/000491.html
>
> by Thomas Hallgren where he mentioned that PostGre only defines
> one stack and therefor pl/java has no way of telling PostGre
> about multiple thread stack pointers.
>
> My question is now if there is a patched version available of PostGre
> 8.3.0 having this stack_depth check disabled?

This was fixed in postgresql/pljava shortly after the referenced
discussion.  As requested, postgresql 8.1+ allows modification of
stack_base_ptr so pljava can set it as desired.

Kris Jurka

Re: [Pljava-dev] stack depth limit exceeded - patch possible?

From
Alexander Wöhrer
Date:
Dear Kris,

am I understanding this correctly that pl/java sets it for the main Java
thread, so other threads spawned by this main thread and using postgres
SPI functionality will run into stack_depth_problems?

I have read only access in this application, so maybe my envisioned
patched version (check_stack_depth doing nothing) will work for my proof
of concept tests.

Can you suggest another workaround?

Regards,

Alexander Wöhrer

>
>
> On Sat, 12 Apr 2008, Alexander Wöhrer wrote:
>
>> I'm working on Windows XP SP2 (stack limit 3500 kb) and deployed
>> successfully my application (doing some external Web service calling)
>> inside PostGre 8.3.0.
>>
>> Unfortunatelly, the application needs at least 3 Threads and will run
>> for quite some time.
>>
>> I found this comment
>>
>> http://pgfoundry.org/pipermail/pljava-dev/2005/000491.html
>>
>> by Thomas Hallgren where he mentioned that PostGre only defines
>> one stack and therefor pl/java has no way of telling PostGre
>> about multiple thread stack pointers.
>>
>> My question is now if there is a patched version available of PostGre
>> 8.3.0 having this stack_depth check disabled?
>
> This was fixed in postgresql/pljava shortly after the referenced
> discussion.  As requested, postgresql 8.1+ allows modification of
> stack_base_ptr so pljava can set it as desired.
>
> Kris Jurka




Re: [Pljava-dev] stack depth limit exceeded - patch possible?

From
Kris Jurka
Date:

On Mon, 14 Apr 2008, Alexander Wöhrer wrote:

> am I understanding this correctly that pl/java sets it for the main Java
> thread, so other threads spawned by this main thread and using postgres
> SPI functionality will run into stack_depth_problems?

pljava sets the stack_base_ptr for each thread just before it calls into
the backend using SPI and resets it when that thread finishes using SPI.
Only one thread can access the backend at a time, so multi-threaded pljava
code is safe and this mangling of the stack_base_ptr keeps the backend
happy.

> Can you suggest another workaround?
>

Are you having any actual problems or is this all theoretical?  I don't
believe you should be having any issues, but if you're having a real
problem, please post a self-contained test case so we can look into it.

Kris Jurka