![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
At least in 2.6 it seems to avoid reuse of ids by keeping a global counter that is incremented every time a segment is created which ranges from 0..128k that it multiplies by 32k and adds to the array index (which is reused quickly). So it doesn't seem plausible that there was an id collision unless this was different in 2.4.20. However looking at his list of ids they're all separated by multiples of 32769 which is what you would expect from this algorithm at least until they start being reused. |
#12
| |||
| |||
|
|
Oh I missed the fact that you were talking about after a reboot. So the algorithm I described would produce exactly the same sequence of ids after any reboot given the same sequence of creation and deletions. Even if there's a different sequence as long as the n'th creation is for the m'th array slot it would get the same id. So collisions would be very common. |
#13
| |||
| |||
|
|
The shared memory block would certainly not still exist after a system reboot, so what we have here is a misleading error message. Looking at the code, the most plausible explanation appears to be that shmctl(IPC_STAT) is failing (which it ought to) and returning some errno code different from EINVAL (which is the case we are expecting to see). I believe the attached patch will fix this problem for you, at least on the assumption that you are starting only one postmaster at system boot. |
#14
| |||
| |||
|
|
I noticed that ipcs on my linux box has a command-line option to list the pid that created the segment. Not sure if such a library exists in usable form, but looking for segments owned by the downed postmaster's pid would seem to be what is needed. Just a thought... |
#15
| |||
| |||
|
|
"Ed L." <pgsql (AT) bluepolka (DOT) net> writes: I noticed that ipcs on my linux box has a command-line option to list the pid that created the segment. Not sure if such a library exists in usable form, but looking for segments owned by the downed postmaster's pid would seem to be what is needed. Just a thought... [ thinks about it... ] Nah, it's still not bulletproof, because in a system reboot situation you can't trust the old PID either. It could easy be that the other guy gets both the PID and the shmem ID that belonged to you last time. |
|
I've committed changes for 8.0 that mark a shmem segment with the inode of the associated data directory; that should be a stable enough ID to handle all routine-reboot cases. (If you had to restore your whole filesystem from backup tapes, it might be wrong, but you're going to be doing such recovery manually anyway ...) |
![]() |
| Thread Tools | |
| Display Modes | |
| |