4

I ran initdb, tried to create a new superuser with createuser -sdrP myuser

The error I'm getting is

createuser: could not connect to database postgres: FATAL: semctl(3342342, 3, SETVAL, 0) failed: Invalid argument

I can't find anything about this anywhere on the internet. I've tried deinstalling, removing the data directory, and trying again but no dice. I'm at my wits end.

I'm running inside a jail, which is running FreeBSD 9.2-RELEASE-p10. And yes, I've set allow.sysvipc=1

1
  • Kernel / OS compatibility issues? Sep 21, 2015 at 1:00

1 Answer 1

3

PostgreSQL is most likely not finding the semaphore it created previously. It is possible another (unrelated) process is deleting the semaphores (perhaps a script calling ipcrm).

Use ipcs -s to list sempahores immediately after starting PostgreSQL and then again when you experience the problem. Unless another process is actively deleting the semaphores faster than you can run the ipcs -s test after PostgreSQL startup, you should be able to determine if the PostgreSQL semaphores are in fact being deleted by comparing the two sempahore listings.

This doesn't tell you which (root) process is the culprit, but it does point you in the right direction. With any luck, the offending process is a script in which case you could search for root executed scripts that perform ipcrm calls.

4
  • Should the IDs be changing? It always lists semaphores with the same 8 keys, but the IDs change every time I try createuser. For that matter, how many should there be? If I stop PostgreSQL the last one disappears only to reappear when I restart it. Should there be only one? Sep 20, 2015 at 23:51
  • The number of semaphores will vary depending on the number of database connections and the postgresql setting for maximum maximum auto vacuum workers. However, PostgreSQL docs also suggest "If running in FreeBSD jails by enabling sysctl's security.jail.sysvipc_allowed, postmasters running in different jails should be run by different operating system users". This might be relevant to you. See FreeBSD section within postgresql.org/docs/9.4/static/kernel-resources.html Sep 21, 2015 at 1:35
  • @DieKatzchen I've reversed the suggested ipcs test sequence. The IDs might change when PostgreSQL is restarted, but they should be consistent for the same process instance. Sep 21, 2015 at 2:11
  • 1
    That was it. I was running postmasters in different jails with the same username. I was reconstructing an existing (and falling apart) jail in a new jail but I left the old jail running so I could switch back and forth with pgadmin. Whoops! Sep 21, 2015 at 11:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .