Re: Connect from background worker thread to database - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Connect from background worker thread to database
Date
Msg-id 20131124130650.GB4403@alap2.anarazel.de
Whole thread Raw
In response to Connect from background worker thread to database  (Олексій Васильєв<leopard_ne@inbox.ru>)
Responses Re[2]: [HACKERS] Connect from background worker thread to database  (Олексій Васильєв<leopard_ne@inbox.ru>)
Re[2]: [HACKERS] Connect from background worker thread to database  (Alexey Vasiliev <leopard_ne@inbox.ru>)
List pgsql-hackers
Hi,

On 2013-11-24 16:27:06 +0400, Олексій Васильєв wrote:
> This is part where I try to connect to database:  https://github.com/le0pard/pg_web/blob/master/src/pg_web.c#L92-L132
,but SPI functions give error in log (it is commented):
 
> 
> 2013-11-24 02:57:43 UTC ERROR:  stack depth limit exceeded
> 2013-11-24 02:57:43 UTC HINT:  Increase the configuration parameter "max_stack_depth" (currently 2048kB), after
ensuringthe platform's stack depth limit is adequate.
 
> 2013-11-24 02:57:43 UTC CONTEXT:  SQL statement "SELECT COUNT(*) FROM pg_class;"
> 
> Because I doing something in wrong way. I will appreciate for any help: where I doing wrong, link to the article how
todo it, just a tip, pull request - anything. Google search and PostgreSQL sources reading  so far helped me to this
point.

At the very least you're calling InitPostgres() instead of
BackgroundWorkerInitializeConnection() which you have commented out. And
the latter should only be called once in every worker.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Олексій Васильєв
Date:
Subject: Connect from background worker thread to database
Next
From: Peter Eisentraut
Date:
Subject: Re: [PATCH] Report exit code from external recovery commands properly