Обсуждение: stack depth limit exceeded - patch possible?

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

stack depth limit exceeded - patch possible?

От
Alexander Wöhrer
Дата:
Dear PostGre developers,

I'm working on Windows XP SP2 (stack limit set to 3500 kb) and deployed 
successfully my Java 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.

As far as I understand the situation, the check_stack_depth()
is used "just" to provide better stability/security?

I'm not concerned about stability at all - just want to get
my things running for a proof-of-concept research prototype  :) 

My question is now if there is a patched version available of PostGre 
8.3.0 having this stack_depth check disabled?
If so I would be very glad if you can point me to!

If not, can you tell me if

void check_stack_depth(void) in \src\backend\tcop\postgres.c

is the only place where to change something
(in my case just do nothing or report a warning)?

My C developer times are long gone but I would try to make a patched PostGre 8.3 version
myself.

Regards,

Alexander



Re: stack depth limit exceeded - patch possible?

От
Gregory Stark
Дата:
Alexander Wöhrer <woehrer@par.univie.ac.at> writes:

> 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.
>
> As far as I understand the situation, the check_stack_depth()
> is used "just" to provide better stability/security?

That's only going to be the tip of the iceberg. None of the Postgres internal
functions are thread-safe, they don't lock any internal data structures except
those shared with other backends.

If you're going to use Postgres internal API functions then you only have any
hope of doing so from a single thread. And even then people have run into some
problems.

You might look into PL/J which IIUC runs the java stack in a second process
rather than in the server process. Or you could run PL/Java but have it
communicate with your application over a socket, you could send whole
serialized objects over.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's PostGIS support!


Re: stack depth limit exceeded - patch possible?

От
Alexander Wöhrer
Дата:
Dear Gregory,

Thank you very much for you fast answer and your tips.
What is meant by IIUC?

Actually just one thread is accessing the database - the two others do 
send/recieve data.

I will try my luck anyway and try to built PostGre 8.3 without 
check_stack_depth doing anything - will let you know what happens for my 
application.

Best regards,

Alexander

Gregory Stark schrieb:
> Alexander Wöhrer <woehrer@par.univie.ac.at> writes:
>
>   
>> 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.
>>
>> As far as I understand the situation, the check_stack_depth()
>> is used "just" to provide better stability/security?
>>     
>
> That's only going to be the tip of the iceberg. None of the Postgres internal
> functions are thread-safe, they don't lock any internal data structures except
> those shared with other backends.
>
> If you're going to use Postgres internal API functions then you only have any
> hope of doing so from a single thread. And even then people have run into some
> problems.
>
> You might look into PL/J which IIUC runs the java stack in a second process
> rather than in the server process. Or you could run PL/Java but have it
> communicate with your application over a socket, you could send whole
> serialized objects over.
>
>   


Re: stack depth limit exceeded - patch possible?

От
Gregory Stark
Дата:
Alexander Wöhrer <woehrer@par.univie.ac.at> writes:

> Dear Gregory,
>
> Thank you very much for you fast answer and your tips.
> What is meant by IIUC?

"if I understand correctly"

> Actually just one thread is accessing the database - the two others do
> send/recieve data.

Then in theory it should work. But as I mention other people have run into a
number of problems with threads in the backend.

> I will try my luck anyway and try to built PostGre 8.3 without
> check_stack_depth doing anything - will let you know what happens for my
> application.

I'm a bit confused why check_stack_depth matters if you're calling the
Postgres code from the original thread which called Java. If you're not in the
same thread as Postgres then you're still going to be in trouble.

--  Gregory Stark EnterpriseDB          http://www.enterprisedb.com Ask me about EnterpriseDB's 24x7 Postgres support!


Re: stack depth limit exceeded - patch possible?

От
Tom Lane
Дата:
Alexander Wöhrer <woehrer@par.univie.ac.at> writes:
> I will try my luck anyway and try to built PostGre 8.3 without 
> check_stack_depth doing anything - will let you know what happens for my 
> application.

It will crash ... but perhaps not until after it's hopelessly corrupted
your data.  Don't try this on any database you care about.
        regards, tom lane