Postgresql – OS X Yosemite Server – Wiki stops working

mac-osxmac-osx-serverpostgresqlwiki

the last couple of days I have noticed that the Wiki-Server on OS X Server seems to crash.

When I call up the wiki's website I get the following message:

Caught exception "Connection to DB failed" [CSDatabaseError] executing route /app-context/wiki:
(
    0   CoreFoundation                      0x00007fff8fb4003c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff8f74d76e objc_exception_throw + 43
    2   CSService                           0x00000001045eb5cf -[CSConnectionPool openConnection] + 3357
    3   CSService                           0x00000001045ebfbe -[CSConnectionPool currentConnection] + 98
    4   CSService                           0x000000010466d687 -[CSAuthService unauthenticatedSession] + 82
    5   CSService                           0x000000010466dc56 -[CSAuthService currentOrNewSession] + 151
    6   CSService                           0x000000010465efad +[CSHTTPRouteHelper setCurrentSessionForRequest:] + 267
    7   CSService                           0x00000001046736aa __27-[CSAppContextService init]_block_invoke234 + 107
    8   CSService                           0x000000010465aaf4 __53-[CSRoutingHTTPConnection httpResponseForMethod:URI:]_block_invoke + 92
    9   CSService                           0x000000010465e0ea -[CSHTTPBackgroundResponse bounce:] + 284
    10  Foundation                          0x00007fff94896dc2 __NSThread__main__ + 1345
    11  libsystem_pthread.dylib             0x00007fff8dba9268 _pthread_body + 131
    12  libsystem_pthread.dylib             0x00007fff8dba91e5 _pthread_body + 0
    13  libsystem_pthread.dylib             0x00007fff8dba741d thread_start + 13
)

After I restart the server everything is back to normal.

It seems to me that the SQL-Server quit. Is there a way for me to restart it using the command line? Because I don't want to have to re-install the Server App because I have very many settings made and it is frankly not worth the time, since I am hoping for the problem to be solved with coming updates.

Thanks

Best Answer

The Wiki service in Server.app uses PostgreSQL as a database. This just happened to me and I was able to fix it without restarting the server.

Turn off Wiki service in Server.app. Verify that the postgresql instance serving the wiki service is not actually running:

% ps auwwx | grep postgr | grep teamserv
    <should show no processes returned>

Check /Library/Server/Wiki/PostgresSocket for stale files and remove them.

I had the following stale file:
  .xpg_ctl.pid -> 80019

The PostgreSQL database cluster is located at

/Library/Server/Wiki/Database.xpg/Cluster.pg

In my case, the pg_hba.conf file was 200K lines, apparently some script that generated it went haywire. I removed everything below the line

local   replication     all                         trust

I then turned on the Wiki service, accessed the wiki and the database started up successfully.

Related Topic