pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
7+ messages / 3 participants
[nested] [flat]

* SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
@ 2001-01-05 20:37 Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:01 ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Alex Pilosov @ 2001-01-05 20:37 UTC (permalink / raw)
  To: Dave VanAuken <dave@hawk-systems.com>; +Cc: pgsql-general@postgresql.org

Yes, obviously /storage/* isn't in the install dir, its the source file.
If you are using a port to compile postgres, it'd be in
/usr/ports/databases/postgresql7/work/postgresql-7.0.2/src/include

I'd suggest you do this: add a global backend_shmid_offset in ipc.c,
initialized to current default, and an option to postgres to put a value
there. 

I'm not sure whether this option should be in pg_options or
postmaster.opts, and what's the name of it should be...Comments?

After you are done, send us a patch :)

On Fri, 5 Jan 2001, Dave VanAuken wrote:

> Knew about #1... and I'm not holding my breath for change gicing where
> the development on that angle is heading.
> 
> In the installation directory for the jail i don't have the /storage
> directory, or for that matter the ipc.h file anywhere in the pgsql
> tree (both in the jail and host installations).  The version installed
> was 7.0.2
> 
> What about hacking supplimentary installations and hardcoding new
> offsets for each subsequent installation of pgsql (can't even look
> into that until i detemine where the ipc.h code now exists).
> 
> Appreciate the input...  the best description so far from the pgsql
> pov regarding the situation...  have been working almost entirely from
> the fbsd pov up until not and running out of options.  May be a wash
> for using pgsql in this situation.
> 
> Dave
> 
> -----Original Message-----
> From: pgsql-general-owner@postgresql.org
> [mailto:pgsql-general-owner@postgresql.org]On Behalf Of Alex Pilosov
> Sent: Friday, January 05, 2001 1:50 PM
> To: Dave VanAuken
> Cc: pgsql-general@postgresql.org
> Subject: Re: running pgsql 7 under Jail'ed virtual machine on FreeBSD
> 4.2
> 
> 
> Here's the story about pgsql and jail:
> 
> 1. FreeBSD shared memory is _really_ shared across all jail VMs. I
> think
> its not going to change, as this seems like a great way for processes
> to
> exchange data...But I could be wrong. :)
> 
> 2. Postgres uses some funky math to determine which shmid to use for
> different memory allocations it needs. The problem with that it has no
> idea about jails and will not generate a different shmid for different
> processes, so postgres processes end up stepping on each other's toes.
> 
> See include/storage/ipc.h, definition of SystemPortAddressGetIPCKey,
> and
> you'll understand what I mean.
> 
> To properly fix this, I think this should be done:
> 
> Another (optional) backend parameter which should determine offset
> (hardcoded now to 17491) for allocation of different shmids...
> 
> comments? TODO?
> 
> 
> On Thu, 4 Jan 2001, Dave VanAuken wrote:
> 
> > Have a FreeBSD 4.2 box...  have created two Virtual machines with
> the
> > jail process.
> > Apache and PHp configure and execute fine, but am having some
> > configuration and execution problems with pgsql... not sure if I am
> > missing something or if pgsql just cannot deal with being in the
> jail
> > and sharing the sysv memory
> >
> > Attempting to manually start the postmaster produces the following:
> >
> > %postmaster -i
> > IpcMemoryCreate: shmget failed (Function not implemented)
> key=5432010,
> > size=144, permission=700
> > This type of error is usually caused by an improper
> > shared memory or System V IPC semaphore configuration.
> > For more information, see the FAQ and platform-specific
> > FAQ's in the source directory pgsql/doc or on our
> > web site at http://www.postgresql.org.
> > IpcMemoryIdGet: shmget failed (Function not implemented)
> key=5432010,
> > size=144, permission=0
> > IpcMemoryAttach: shmat failed (Function not implemented) id=-2
> > FATAL 1:  AttachSLockMemory: could not attach segment
> > %
> >
> > Have modified the sysctl.conf file to allow usage of sysv memory,
> but
> > as it is already shared from the host machine, this may be causing
> > pgsql to barf on it.
> >
> > Searching for jail faq's and posts regarding this matter produces
> some
> > close, but not helpful posts regarding chroot'ed environments.
> >
> > Any insights, requests for details, and assistance are appreciated.
> >
> > Dave
> >
> >
> 
> 
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
  2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
@ 2001-01-05 23:01 ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-01-05 23:06   ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:44   ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 7+ messages in thread

From: Tom Lane @ 2001-01-05 23:01 UTC (permalink / raw)
  To: Alex Pilosov <alex@pilosoft.com>; +Cc: Dave VanAuken <dave@hawk-systems.com>; pgsql-general@postgresql.org

Alex Pilosov <alex@pilosoft.com> writes:
> I'd suggest you do this: add a global backend_shmid_offset in ipc.c,
> initialized to current default, and an option to postgres to put a value
> there. 

Don't waste your time.  This issue is gone in current sources.  See
IpcMemoryCreate and IpcSemaphoreCreate in src/backend/storage/ipc/ipc.c.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
  2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:01 ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-01-05 23:06   ` Alex Pilosov <alex@pilosoft.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Alex Pilosov @ 2001-01-05 23:06 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@postgresql.org

On Fri, 5 Jan 2001, Tom Lane wrote:

> Alex Pilosov <alex@pilosoft.com> writes:
> > I'd suggest you do this: add a global backend_shmid_offset in ipc.c,
> > initialized to current default, and an option to postgres to put a value
> > there. 
> 
> Don't waste your time.  This issue is gone in current sources.  See
> IpcMemoryCreate and IpcSemaphoreCreate in src/backend/storage/ipc/ipc.c.
Damn. One of these days I'm going to go and get myself up on postgresql
7.1, so I won't bother you and others with silly things that are fixed in
-current :)

Thanks Tom
-alex




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
  2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:01 ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-01-05 23:44   ` Tom Lane <tgl@sss.pgh.pa.us>
  2001-01-06 01:38     ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-06 02:58     ` RE: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Dave VanAuken <dave@hawk-systems.com>
  1 sibling, 2 replies; 7+ messages in thread

From: Tom Lane @ 2001-01-05 23:44 UTC (permalink / raw)
  To: Alex Pilosov <alex@pilosoft.com>; +Cc: Dave VanAuken <dave@hawk-systems.com>; pgsql-general@postgresql.org

I said:
> Alex Pilosov <alex@pilosoft.com> writes:
>> I'd suggest you do this: add a global backend_shmid_offset in ipc.c,
>> initialized to current default, and an option to postgres to put a value
>> there. 

> Don't waste your time.  This issue is gone in current sources.  See
> IpcMemoryCreate and IpcSemaphoreCreate in src/backend/storage/ipc/ipc.c.

Actually, now that I think about it, you might still have a problem if
a "jail" is what I think it is.  The current code will step past an
existing shmem segment if it appears to be a non-Postgres memory segment
or if it appears to belong to another running postmaster.  However, the
test to see if the segment owner appears to be alive is

        /*
         * If the creator PID is my own PID or does not belong to any
         * extant process, it's safe to zap it.
         */
        if (hdr->creatorPID != getpid())
        {
            if (kill(hdr->creatorPID, 0) == 0 ||
                errno != ESRCH)
            {
		// segment belongs to a live postmaster, so continue
	    }
	}

So the question for you is, what will happen if kill() is given a PID
belonging to a process that's in a different "jail"?  Will it return
some kind of permission failure, or will it claim that there is no
such PID (ie, return ESRCH)?  If the latter, we still have a problem ...

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
  2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:01 ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  2001-01-05 23:44   ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-01-06 01:38     ` Alex Pilosov <alex@pilosoft.com>
  1 sibling, 0 replies; 7+ messages in thread

From: Alex Pilosov @ 2001-01-06 01:38 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Dave VanAuken <dave@hawk-systems.com>; pgsql-general@postgresql.org

What'd happen is: Operation not permitted (EPERM, -1), so its not a
problem...

-alex

On Fri, 5 Jan 2001, Tom Lane wrote:

> I said:
> > Alex Pilosov <alex@pilosoft.com> writes:
> >> I'd suggest you do this: add a global backend_shmid_offset in ipc.c,
> >> initialized to current default, and an option to postgres to put a value
> >> there. 
> 
> > Don't waste your time.  This issue is gone in current sources.  See
> > IpcMemoryCreate and IpcSemaphoreCreate in src/backend/storage/ipc/ipc.c.
> 
> Actually, now that I think about it, you might still have a problem if
> a "jail" is what I think it is.  The current code will step past an
> existing shmem segment if it appears to be a non-Postgres memory segment
> or if it appears to belong to another running postmaster.  However, the
> test to see if the segment owner appears to be alive is
> 
>         /*
>          * If the creator PID is my own PID or does not belong to any
>          * extant process, it's safe to zap it.
>          */
>         if (hdr->creatorPID != getpid())
>         {
>             if (kill(hdr->creatorPID, 0) == 0 ||
>                 errno != ESRCH)
>             {
> 		// segment belongs to a live postmaster, so continue
> 	    }
> 	}
> 
> So the question for you is, what will happen if kill() is given a PID
> belonging to a process that's in a different "jail"?  Will it return
> some kind of permission failure, or will it claim that there is no
> such PID (ie, return ESRCH)?  If the latter, we still have a problem ...
> 
> 			regards, tom lane
> 
> 




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* RE: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
  2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:01 ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  2001-01-05 23:44   ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
@ 2001-01-06 02:58     ` Dave VanAuken <dave@hawk-systems.com>
  2001-01-06 03:49       ` Re: RE: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 7+ messages in thread

From: Dave VanAuken @ 2001-01-06 02:58 UTC (permalink / raw)
  To: pgsql-general@postgresql.org

the jail can only address the PID's that operate within itself... in
effect allowing it to f'up its own enviroment only...  thus the
problem with pg trying to allocate dedicated portions of the
host/system wide memory.

will up the 7.0.2 to 7.1 and give her another go around.  Really would
like to work this within a jail'ed environment, but have much to much
code completed based on postgres to consider dumping it just because
of the functionality of the jail.

Dave

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org]On Behalf Of Tom Lane
Sent: Friday, January 05, 2001 6:45 PM
To: Alex Pilosov
Cc: Dave VanAuken; pgsql-general@postgresql.org
Subject: Re: SHM ids (was running pgsql 7 under Jail'ed virtual
machine
on FreeBSD 4.2)


I said:
> Alex Pilosov <alex@pilosoft.com> writes:
>> I'd suggest you do this: add a global backend_shmid_offset in
ipc.c,
>> initialized to current default, and an option to postgres to put a
value
>> there.

> Don't waste your time.  This issue is gone in current sources.  See
> IpcMemoryCreate and IpcSemaphoreCreate in
src/backend/storage/ipc/ipc.c.

Actually, now that I think about it, you might still have a problem if
a "jail" is what I think it is.  The current code will step past an
existing shmem segment if it appears to be a non-Postgres memory
segment
or if it appears to belong to another running postmaster.  However,
the
test to see if the segment owner appears to be alive is

        /*
         * If the creator PID is my own PID or does not belong to any
         * extant process, it's safe to zap it.
         */
        if (hdr->creatorPID != getpid())
        {
            if (kill(hdr->creatorPID, 0) == 0 ||
                errno != ESRCH)
            {
		// segment belongs to a live postmaster, so continue
	    }
	}

So the question for you is, what will happen if kill() is given a PID
belonging to a process that's in a different "jail"?  Will it return
some kind of permission failure, or will it claim that there is no
such PID (ie, return ESRCH)?  If the latter, we still have a problem
...

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: RE: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2)
  2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
  2001-01-05 23:01 ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  2001-01-05 23:44   ` Re: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Tom Lane <tgl@sss.pgh.pa.us>
  2001-01-06 02:58     ` RE: SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Dave VanAuken <dave@hawk-systems.com>
@ 2001-01-06 03:49       ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 7+ messages in thread

From: Tom Lane @ 2001-01-06 03:49 UTC (permalink / raw)
  To: Dave VanAuken <dave@hawk-systems.com>; +Cc: pgsql-general@postgresql.org

"Dave VanAuken" <dave@hawk-systems.com> writes:
> the jail can only address the PID's that operate within itself... in
> effect allowing it to f'up its own enviroment only...

Certainly a jailed process should not be allowed to actually kill()
a process outside the jail.  The question is what error code does it
get?

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2001-01-06 03:49 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-05 20:37 SHM ids (was running pgsql 7 under Jail'ed virtual machine on FreeBSD 4.2) Alex Pilosov <alex@pilosoft.com>
2001-01-05 23:01 ` Tom Lane <tgl@sss.pgh.pa.us>
2001-01-05 23:06   ` Alex Pilosov <alex@pilosoft.com>
2001-01-05 23:44   ` Tom Lane <tgl@sss.pgh.pa.us>
2001-01-06 01:38     ` Alex Pilosov <alex@pilosoft.com>
2001-01-06 02:58     ` Dave VanAuken <dave@hawk-systems.com>
2001-01-06 03:49       ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox