Re: Threads in PostgreSQL

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: sri harsha <sriharsha9992(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Threads in PostgreSQL
Date: 2015-12-21 07:48:52
Message-ID: 5677AEE4.9010609@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi,

PostgreSQL is not using threads but it is possible to spawn thread in
your PostgreSQL extensions.
For example, I have used pool of threads in my IMCS extension.
But you need to build your extension with -pthread:

CUSTOM_COPT = -pthread

Also, please take in account that many PostgreSQL functions (even in/out
or comparison functions) are not reentrant: them are storing their state
in global variables.
So you will get race conditions if you are calling such functions from
multiple threads.

Concerning stack overflow, I think that the most probable reason is
trivial infinite recursion.
Did you inspect stack trace in debugger?

On 21.12.2015 09:21, sri harsha wrote:
> Hi,
>
> Is it possible to use threads in Postgresql ?? I am using threads
> in my foreign data wrapper and i get the following error when i use
> the threads .
>
> *ERROR: stack depth limit exceeded*
> *HINT: Increase the configuration parameter "max_stack_depth"
> (currently 2048kB), after ensuring the platform's stack depth limit is
> adequate.*
>
> No matter how much i increase the stack size , the error keeps
> occurring . How do i solve this problem ??
>
>
> Thanks,
> Harsha

In response to

Browse pgsql-general by date

  From Date Subject
Next Message james garner 2015-12-21 07:57:58 dblink connect per socket / specify cluster name
Previous Message Chapman Flack 2015-12-21 07:00:53 Re: Threads in PostgreSQL

Browse pgsql-hackers by date

  From Date Subject
Next Message Jesper Pedersen 2015-12-21 07:50:36 Re: Additional LWLOCK_STATS statistics
Previous Message David Rowley 2015-12-21 07:48:14 Re: Parallel Aggregate