Subject: port-alpha/35878: Stale SHM entry on NetBSD 3.1
To: None <port-alpha-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: None <tonnerre@thebsh.sygroup.ch>
List: netbsd-bugs
Date: 03/01/2007 07:35:00
>Number:         35878
>Category:       port-alpha
>Synopsis:       Stale SHM entry on NetBSD 3.1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Mar 01 07:35:00 +0000 2007
>Originator:     Tonnerre Lombard
>Release:        NetBSD 3.1_STABLE
>Organization:
	SyGroup GmbH
>Environment:
System: NetBSD thebsh.sygroup-int.ch 3.1_STABLE NetBSD 3.1_STABLE (GENERIC.MP) #0: Wed Jan 10 12:38:57 CET 2007 root@thebsh.sygroup-int.ch:/usr/obj/sys/arch/alpha/compile/GENERIC.MP alpha
Architecture: alpha
Machine: alpha
>Description:
After I stopped PostgreSQL, it seems that there are stale SHM entries around.
First I noticed that a SHM segment was still allocated with id 0. I tried
to deallocate it, and it seems to have changed its id to 65536 by that.

# ipcs -ma 
IPC status from <running system> as of Thu Mar  1 08:27:37 2007

Shared Memory:
T        ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH   SEGSZ  CPID  LPID    ATIME    DTIME    CTIME
m     65536          0 --rw-------    pgsql    pgsql    pgsql    pgsql      1 8298496   224   224  8:23:36 15:20:55  8:23:36

pcrm -M 65536
ipcrm: shmkey(65536): : No such file or directory
# ps waux | grep pgsql | grep -v grep
# 

So apparently, noone is occupying that region because there are no processes
left running as pgsql. (Also, not many others, and none of them could be
using shm at all as far as I know.) Still, the area is occupied and cannot
be rm'd.

Looks like a bug to me? Or is there anything I didn't consider?
>How-To-Repeat:
Start and restart PostgreSQL a couple of times or so. It's not that easy
to reproduce. However, I need to make the database server work again, so
I probably can't debug further into it.

>Fix:

Unknown