Skip to main content

OpenBSD, postgresql and semaphore failures during initdb

Today I upgraded my postgresql database instance on OpenBSD. Did a pg_dumpall, removed the old packages and then added the new ones (latest version 8.1.9 for OpenBSD 4.0 – yes I’m behind).

During the initialisation of the new DB, I got the following error:
<br /> creating directory /var/postgresql/data/pg_tblspc ... ok<br /> selecting default max_connections ... 10<br /> selecting default shared_buffers ... 50<br /> creating configuration files ... ok<br /> creating template1 database in /var/postgresql/data/base/1 ... FATAL: could not create semaphores: No space left on device<br /> DETAIL: Failed system call was semget(1, 17, 03600).<br />
The PostgreSQL documentation talks about this extensively. However I don’t want to recompile my kernel away from GENERIC. What else can I do?

AFAIK It is not possible to pass the max_connections to initdb.

After some searching, I found the solution. It looks like the problem is that the semaphores from the old installation are still hanging around, and never got cleaned up. You can use ipcs and ipcrm to clean then up and run your initdb again.

First list the existing semaphores:
` server:~# ipcs Message Queues: T ID KEY MODE OWNER GROUP