Thread: BUG #3495: PostgreSQL does not use POSIX SHM or SEM in place of SYSV equivalents

The following bug has been logged online:

Bug reference:      3495
Logged by:          Roger Leigh
Email address:      rleigh@whinlatter.ukfsn.org
PostgreSQL version: 8.2.4
Operating system:   Debian GNU/Linux (glibc 2.6, linux 2.6.22)
Description:        PostgreSQL does not use POSIX SHM or SEM in place of
SYSV equivalents
Details:

PostgreSQL is using the old SYSV shared memory and semaphores, as evidenced
by ipcs:

% sudo ipcs

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0x0052e2c1 0          postgres  600        29384704   2

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0x0052e2c1 0          postgres  600        17
0x0052e2c2 32769      postgres  600        17
0x0052e2c3 65538      postgres  600        17
0x0052e2c4 98307      postgres  600        17
0x0052e2c5 131076     postgres  600        17
0x0052e2c6 163845     postgres  600        17
0x0052e2c7 196614     postgres  600        17

------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages


However, the SYSV memory limit is set in-kernel and while it can be easily
changed, it is rather less flexible than POSIX SHM support:

% df /dev/shm
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   257584         0    257584   0% /dev/shm

On this system, that limit could be increased up to 6 GiB (though the above
would probably be the upper useful limit given that this is VM-backed).

Having the option of utilising either form of shared memory would be rather
useful.


Regards,
Roger

Re: BUG #3495: PostgreSQL does not use POSIX SHM or SEM in place of SYSV equivalents

From
Heikki Linnakangas
Date:
Roger Leigh wrote:
> The following bug has been logged online:

Not a bug, but a feature request...

> PostgreSQL is using the old SYSV shared memory and semaphores, as evidenced
> by ipcs:
> ...
> However, the SYSV memory limit is set in-kernel and while it can be easily
> changed, it is rather less flexible than POSIX SHM support:
> ...
> Having the option of utilising either form of shared memory would be rather
> useful.

A patch to do that submitted was submitted in Spring, but it was not
accepted for 8.3 because there was some issues with it. Search the
archives for more details.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com
Heikki Linnakangas <heikki@enterprisedb.com> writes:
> Roger Leigh wrote:
>> PostgreSQL is using the old SYSV shared memory and semaphores, as evidenced
>> by ipcs:

> A patch to do that submitted was submitted in Spring, but it was not
> accepted for 8.3 because there was some issues with it.

More strongly: it never will be accepted because the POSIX API doesn't
offer the features we need.

You can use POSIX semaphores if you choose (there are compile options
for that), but experience to date says that that degrades performance.
POSIX shared memory is simply not happening.

            regards, tom lane