Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  11 Apr 2013, Thorsten Lux, Forum, Persistent ipcrm error 
    Reply  11 Apr 2013, Konstantin Olchanski, Forum, Persistent ipcrm error 
    Reply  11 Apr 2013, Stefan Ritt, Forum, Persistent ipcrm error 
       Reply  12 Apr 2013, Thorsten Lux, Forum, Persistent ipcrm error 
          Reply  12 Apr 2013, Stefan Ritt, Forum, Persistent ipcrm error 
             Reply  12 Apr 2013, Thorsten Lux, Forum, Persistent ipcrm error 
    Reply  12 Apr 2013, Thorsten Lux, Forum, Persistent ipcrm error 
       Reply  12 Apr 2013, Stefan Ritt, Forum, Persistent ipcrm error 
Message ID: 874     Entry time: 11 Apr 2013     In reply to: 873
Author: Konstantin Olchanski 
Topic: Forum 
Subject: Persistent ipcrm error 
> [system.c:308:ss_shm_open,ERROR] Shared memory segment with key 0x4d008002 already exists, 
please remove it manually: ipcrm -M 0x4d008002
> [midas.c:1950:cm_connect_experiment1,ERROR] cannot open database
> Unexpected error #304

For the record, the SYSV shared memory with it's keys and segments has always been brittle and hard to 
debug with problems such as you describe.

Also SYSV shared memory suffers from key aliasing - shared memory segments created with different 
names all map into the same key, collide and nothing works. You may not see this if all the files are 
located on a local disk, but if the .SHM files are located on an NFS disk, it can happen (and did happen in 
T2K).

For this reason, since around August 2010, MIDAS also implements the POSIX shared memory and for new 
MIDAS installations, POSIX shared memory is the default. (On MacOS, POSIX shared memory was always 
the default because MacOS has very small maximum SYSV shared memory size).

The type of shared memory is set by the contents of .SHM_TYPE.TXT and it is possible to switch between 
SYSV and POSIX shared memory at will. (Ask me).

MIDAS still uses SYSV semaphores because they have a built-in feature to automatically unlock the 
semaphore if the program that locked it dies for any reason. POSIX semaphores do not have this built-in 
feature and we would have to implement some kind of detection and recovery for the case when a 
semaphore is locked by a program that died (and will never unlock it back).

K.O.

P.S. I will address the rest of Prof. Thorsten's question in a private email.

P.P.S. Please post elog messages in the "plain" format. NOT HTML or ELCODE.
ELOG V3.1.4-2e1708b5