Thread: PostgreSQL hang on FreeBSD,with CFLAGS='-O2 -pthread' workaround

hi~ pg hackers,
I find some problems when use pg on FreeBSD.On FreeBSD,If installed extension which pthread  lib is used,for example plv8,pljava,imcs etc,when query touch these extenstions,the PG backend will hang.

there is a solution,which configure postgresql with CFLAGS='-O2 -pthread' and compile pg from source ,then install the extension.But this solution is not offical documented and not easy to use(you must compile pg from source).It  may make some extension developers or user waste much time to solve it,and make people complain that PG or FreeBSD not stable.

Is it a PG problem and can we fix it? 

I will also report this to the FreeBSD mail list.  

ref:



Re: PostgreSQL hang on FreeBSD,with CFLAGS='-O2 -pthread' workaround

From
Tom Lane
Date:
Jov <amutu@amutu.com> writes:
> I find some problems when use pg on FreeBSD.On FreeBSD,If installed
> extension which pthread  lib is used,for example plv8,pljava,imcs etc,when
> query touch these extenstions,the PG backend will hang.

> there is a solution,which configure postgresql with CFLAGS='-O2 -pthread'
> and compile pg from source ,then install the extension.But this solution is
> not offical documented and not easy to use(you must compile pg from
> source).It  may make some extension developers or user waste much time to
> solve it,and make people complain that PG or FreeBSD not stable.

> Is it a PG problem and can we fix it?

Sounds more like a bug with FreeBSD's libc and/or libpthread.

In general, we do not and will not support any third-party code that
causes multiple threads to become instantiated inside a PG backend.
So long as these libraries aren't actually forking new threads, you'd
think the presence of libpthread in them would be a non-issue.  It
sounds like the mere presence of libpthread may be changing behavior
somewhere, which I would argue to be a bug in either libpthread or
whatever is changing behavior.

As for building PG itself with -pthread: not bloody likely.  That
would send *entirely* the wrong message about whether threading
is permitted.
        regards, tom lane