apple / ccs-calendarserver

The Calendar and Contacts Server.
https://www.calendarserver.org
Apache License 2.0
486 stars 136 forks source link

Create PostgreSQL DB on run CalendarServer - could not create shared memory segment #329

Closed macosforgebot closed 9 years ago

macosforgebot commented 13 years ago

donaldinos@… originally submitted this as ticket:421


This issue occurs on execute ./run from command line on FreeBSD 8

2011-03-14 16:37:37+0100 [-] Unhandled Error
        Traceback (most recent call last):
          File "/usr/local/lib/python2.6/site-packages/twisted/internet/_baseprocess.py", line 60, in maybeCallProcessEnded
            proto.processEnded(Failure(reason))
          File "/usr/local/src/AppleCalendarServer/CalendarServer/txdav/base/datastore/subpostgres.py", line 153, in processEnded
            self.deferred.callback(''.join(self.output))
          File "/usr/local/lib/python2.6/site-packages/twisted/internet/defer.py", line 318, in callback
            self._startRunCallbacks(result)
          File "/usr/local/lib/python2.6/site-packages/twisted/internet/defer.py", line 424, in _startRunCallbacks
            self._runCallbacks()
        --- <exception caught here> ---
          File "/usr/local/lib/python2.6/site-packages/twisted/internet/defer.py", line 441, in _runCallbacks
            self.result = callback(self.result, *args, **kw)
          File "/usr/local/src/AppleCalendarServer/CalendarServer/txdav/base/datastore/subpostgres.py", line 407, in doCreate
            raise RuntimeError("Unable to initialize postgres database: %s" % (result,))
        exceptions.RuntimeError: Unable to initialize postgres database: The files belonging to this database system will be owned by user "XXXXXX".
        This user must also own the server process.

 The database cluster will be initialized with locale C.

        creating directory /usr/local/src/AppleCalendarServer/CalendarServer/data/Data/Database/cluster ... ok
        creating subdirectories ... ok
        selecting default max_connections ... 10
        selecting default shared_buffers/max_fsm_pages ... 400kB/20000
        creating configuration files ... ok
        creating template1 database in /usr/local/src/AppleCalendarServer/CalendarServer/data/Data/Database/cluster/base/1 ... FATAL:  could not create shared memory segment: Cannot allocate memory
        DETAIL:  Failed system call was shmget(key=1, size=1818624, 03600).
        HINT:  This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory or swap space. To reduce the request size (currently 1818624 bytes), reduce PostgreSQL's shared_buffers parameter (currently 50) and/or its max_connections parameter (currently 10).
                The PostgreSQL documentation contains more information about shared memory configuration.
        child process exited with exit code 1
        initdb: removing data directory "/usr/local/src/AppleCalendarServer/CalendarServer/data/Data/Database/cluster"
macosforgebot commented 13 years ago

@wsanchez originally submitted this as comment:1:⁠ticket:421

macosforgebot commented 13 years ago

@wsanchez originally submitted this as comment:2:⁠ticket:421

macosforgebot commented 13 years ago

@dreness originally submitted this as comment:3:⁠ticket:421


Hello,

Different OSes have different defaults for shared memory settings. Here's a link to the postgres documentation around shared memory and how it is configured on various OSes: http://www.postgresql.org/docs/9.0/interactive/kernel-resources.html

I don't have any FreeBSD stuff set up at the moment so I can't test this, but you should be able to raise shmall, shmmax, and semmap as shown in the documentation. You may have to experiment a bit to find suitable values. Please let us know what works for you.

Since changing these settings requires superuser access, this isn't something that Calendar Server could or should do for you automatically. The end result of this could be that we simply improve our documentation to make sure users know to set shared memory settings appropriately.

Cheers, -dre

macosforgebot commented 13 years ago

@wsanchez originally submitted this as comment:4:⁠ticket:421


Hrm, so that's not usually the sort of this we can adjust unless we are root, so I don't know that we can fix this in the run script; developers may need to do this on their own.

Perhaps, though, we can detect it and emit some instructional info, like when there is no caldavd-dev.plist.

macosforgebot commented 12 years ago

@wsanchez originally submitted this as comment:5:⁠ticket:421

macosforgebot commented 9 years ago

@wsanchez originally submitted this as comment:9:⁠ticket:421


Out of scope for us