- Add ${PTHREAD_LIBS} to LDFLAGS, this makes plv8 [1] extension work [2] - While here, fix some portlint errors. [1] http://pgxn.org/dist/plv8/ [2] http://code.google.com/p/plv8js/issues/detail?id=34 Please note that I haven't tested on other versions PostgreSQL, but I guess they may need same fix. Port maintainer (pgsql@FreeBSD.org) is cc'd. Generated with FreeBSD Port Tools 0.99_6 (mode: change, diff: ports)
Responsible Changed From-To: freebsd-ports-bugs->pgsql Over to maintainer (via the GNATS Auto Assign Tool)
State Changed From-To: open->feedback Hi. I tried to reproduce this using the latest pg92, but failed. Perhaps it got fixed due to some other change? Can you please try again and see if you can still make it fail with unmodified ports from svn/portsnap? Thanks, Palle
Responsible Changed From-To: pgsql->lwhsu Take as reminder.
I've tested with latest postgresql92-server and postgresql93-server, both of them still have the same issue. Following is my test steps: 1) pkg install postgresql92-server 2) pkg install postgresql-plv8js for postgresql93, add this line in /etc/make.conf: DEFAULT_VERSIONS=pgsql=9.3 and build manually from databases/postgresql-plv8js 3) psql -U pgsql -c "create extension plv8" postgres 4) psql -U pgsql postgres, then input example from: http://pgxn.org/dist/plv8/ CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[]) RETURNS text AS $$ var o = {}; for(var i=0; i<keys.length; i++){ o[keys[i]] = vals[i]; } return JSON.stringify(o); $$ LANGUAGE plv8 IMMUTABLE STRICT; If postgresql-server is built without LDFLAGS+= -L${LOCALBASE}/lib ${PTHREAD_LIBS} , server will hang in 4), and cannot be stopped normally. I also found that in config.log, there are: configure: using LDFLAGS= -L/usr/local/lib -Wl,-rpath,/usr/lib:/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/lib -Wl,--as-needed although we have CONFIGURE_ENV+= PTHREAD_LIBS="${PTHREAD_LIBS}" in Makefile. And with LDFLAGS+= -L${LOCALBASE}/lib ${PTHREAD_LIBS} , it becomes: configure: using LDFLAGS= -L/usr/local/lib -pthread -Wl,-rpath,/usr/lib:/usr/local/lib -L/usr/local/lib -L/usr/local/lib -L/usr/lib -L/usr/local/lib -Wl,--as-needed Maybe there is problem in postgresql's configuration system? I'll try to find out. However, can we have this patch for now?
Created attachment 147974 [details] postgresql-pthread.diff - Add ${PTHREAD_LIBS} to LDFLAGS, this makes plv8 [1] extension work [2] - While here, fix some portlint errors. - Add LICENSE [1] http://pgxn.org/dist/plv8/ [2] http://code.google.com/p/plv8js/issues/detail?id=34
(In reply to Li-Wen Hsu from comment #4) > I also found that in config.log, there are: > > configure: using LDFLAGS= -L/usr/local/lib > -Wl,-rpath,/usr/lib:/usr/local/lib -L/usr/local/lib -L/usr/local/lib > -L/usr/lib -L/usr/local/lib -Wl,--as-needed > > although we have CONFIGURE_ENV+= PTHREAD_LIBS="${PTHREAD_LIBS}" in Makefile. > > And with LDFLAGS+= -L${LOCALBASE}/lib ${PTHREAD_LIBS} , it becomes: > > configure: using LDFLAGS= -L/usr/local/lib -pthread > -Wl,-rpath,/usr/lib:/usr/local/lib -L/usr/local/lib -L/usr/local/lib > -L/usr/lib -L/usr/local/lib -Wl,--as-needed > > Maybe there is problem in postgresql's configuration system? I'll try to > find out. However, can we have this patch for now? It turns out that I've asked this in #postgresql this February: 18:35 < lwhsu> koobs: hmm, yes we have them in configure_env, but don't know why it doesn't pass to LDFLAGS 18:36 < RhodiumToad> lwhsu: it's not supposed to pass to LDFLAGS 18:36 < RhodiumToad> lwhsu: the pg makefiles add the PTHREAD_* vars only when building the client, not the server Maybe it's time to revert https://svnweb.freebsd.org/changeset/ports/247147 ?
Hi, Sorry, I just cannot reproduce the problem? I did this cd /usr/ports/databases/postgresql92-server make clean install cd ../postgresql-plv9js make clean install NOCLEANDEPENDS=YES service postgresql initdb psql -U pgsql -c "create extension plv8" postgres psql -U pgsql postgres and then $ psql -U pgsql postgres psql (9.2.9) Type "help" for help. postgres=# \d plv8_t postgres=# \d plv8_t postgres=# \d plv8_test Did not find any relation named "plv8_test". postgres=# \d No relations found. postgres=# CREATE OR REPLACE FUNCTION plv8_test(keys text[], vals text[]) postgres-# RETURNS text AS $$ postgres$# var o = {}; postgres$# for(var i=0; i<keys.length; i++){ postgres$# o[keys[i]] = vals[i]; postgres$# } postgres$# return JSON.stringify(o); postgres$# $$ LANGUAGE plv8 IMMUTABLE STRICT; CREATE FUNCTION postgres=# postgres=# \df plv8_test List of functions Schema | Name | Result data type | Argument data types | Type --------+-----------+------------------+--------------------------+-------- public | plv8_test | text | keys text[], vals text[] | normal (1 row) postgres=# \q palle:postgresql92-client$ ps axU pgsql PID TT STAT TIME COMMAND 18912 ?? Is 0:00,00 postgres: checkpointer process (postgres) 18913 ?? Ss 0:00,02 postgres: writer process (postgres) 18914 ?? Ss 0:00,00 postgres: wal writer process (postgres) 18915 ?? Is 0:00,00 postgres: autovacuum launcher process (postgres) 18916 ?? Ss 0:00,00 postgres: stats collector process (postgres) 18910 2 S 0:00,02 /usr/local/bin/postgres -D /usr/local/pgsql/data palle:postgresql92-client$ Maybe it depends on the system version or hardware? What kind of hardware (sysctl hw.ncpu)? and OS version are you on? Palle
(In reply to Palle Girgensohn from comment #7) > Hi, Thanks for the reply! > Sorry, I just cannot reproduce the problem? (deleted) > Maybe it depends on the system version or hardware? What kind of hardware > (sysctl hw.ncpu)? and OS version are you on? I use 10.0-RELEASE on may hardware, and all have the same results. I just tried again in a vanilla installed VirtualBox VM: FreeBSD FreeBSD-10-postgresql 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014 root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 # sysctl -a hw | head hw.machine: amd64 hw.model: Intel(R) Core(TM) i7-3740QM CPU @ 2.70GHz hw.ncpu: 2 hw.byteorder: 1234 hw.physmem: 1050087424 hw.usermem: 813461504 hw.pagesize: 4096 hw.floatingpoint: 1 hw.machine_arch: amd64 hw.realmem: 1073676288 and it hangs at "CREATE OR REPLACE FUNCTION" part. What's the platform you're testing on? Li-Wen
With hw-ncpu > 1, I can reproduce the problem.
A commit references this bug: Author: girgen Date: Wed Nov 12 09:53:44 UTC 2014 New revision: 372487 URL: https://svnweb.freebsd.org/changeset/ports/372487 Log: Revert r247147. We need -pthread in LDFLAGS for threaded extensions like plv8js to work. PR: 175783 Submitted by: Li-Wen Hsu <lwhsu@FreeBSD.org> Changes: head/databases/postgresql84-client/Makefile head/databases/postgresql84-server/Makefile head/databases/postgresql90-client/Makefile head/databases/postgresql91-server/Makefile head/databases/postgresql92-server/Makefile head/databases/postgresql93-client/Makefile head/databases/postgresql94-client/Makefile
The issue is fixed by girgen in r372487.