Forum OpenACS Q&A: Re: OpenACS/.LRN on Apple's OS X Panther

Collapse
Posted by russ m on
There's 2 questions I have about running a production site on OSX, and they're both about Postgres. I haven't actually looked into either of these issues, but would want to before deploying on OSX...

Configuring Postgres on OSX with --enable-thread-safety throws an error. Apparently this only affects thread safety of libpq when opening database connections, so if AOLserver opens the pooled database connections in the main thread it's not an issue for us...

checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
configure: error:
Cannot enable threads on your platform.
Please report your platform threading info to the PostgreSQL mailing lists
so it can be added to the next release.  Report all compile flags, link flags,
functions, or libraries required for threading support.
See the comment at the top of src/port/thread.c for more information.

Also, there was discussion on the PG mailing lists a while ago (around PG 7.2 / OSX 10.1) that PG wasn't able to shut down cleanly when OSX is shut down - http://archives.postgresql.org/pgsql-hackers/2002-04/msg01514.php. There's no mention of a fix in the Postgres release notes since then, but the problem looks to have been in OSX rather than PG so it may have gone away between 10.1 and 10.3...

Finally, stock PG doesn't correctly build shared libraries on OSX, so everything ends up statically linked. The Fink PG install patches this to work correctly, but the patches don't seem to have made it back to the main PG tree. (I know this isn't really a problem, but while I'm bitching)...

Collapse
Posted by Andrew Piskorski on
I'm no Postgres expert but AFAIK, you should not be building PostgreSQL with any special --enable-thread-safety switches, unless you're doing it for some bizarre Mac OS-X specific reason. PostgreSQL's thread safety options have nothing at all to do with connecting to PostgreSQL from AOLserver, and never did.
Collapse
Posted by russ m on
--enable-thread-safety is new in PG 7.4, and is described in the release notes like this -
libpq and ECPG applications are now fully thread-safe
While previous libpq releases already supported threads, this release improves thread safety by fixing some non-thread-safe code that was used during database connection startup. The configure option --enable-thread-safety must be used to enable this feature.
and the install guide -
--enable-thread-safety
Make the client libraries thread-safe. This allows concurrent threads in libpq and ECPG programs to safely control their private connection handles.
Since nspostgres gets it's Postgres-ness from libpq, there is a potential issue if libpq is not thread safe and 2 threads silmultaneously try to open connections to the database. I don't know in detail how nspostgres handles recycling database connections, and given that database connections are long-lived in AOLserver it's probably pretty hard to trigger any lossage through this if it's even possible at all, but still...