POSIX shared memory support
От | Chris Marcellino |
---|---|
Тема | POSIX shared memory support |
Дата | |
Msg-id | 6C946C32-2887-416B-8DD3-EFAB9C13A4E8@apple.com обсуждение исходный текст |
Ответы |
Re: POSIX shared memory support
(Tom Lane <tgl@sss.pgh.pa.us>)
Re: POSIX shared memory support (Magnus Hagander <magnus@hagander.net>) |
Список | pgsql-patches |
Recapitulating and addressing some of the issues with my previous attempt at this feature: PostgreSQL currently uses the System V shared memory APIs to access shared memory. On Mac OS X and other BSDs, the default System V shared memory limits are often very low and require adjustment for acceptable performance. Par- ticularly, when Postgres is included as part of larger end-user friendly software products, these kernel settings are often difficult to change programatically. The System V shared memory facilities provide a method to determine who is attached to a shared memory segment. This is used to prevent backends that were orphaned by crashed or killed database processes from corrupting the data- base as it is restarted. The same effect can be achieved with using the POSIX APIs, but since the POSIX library does not have a way to check who is attached to a segment, atomic segment creation must be used to ensure exclusive access to the database. In order for this to work, the key name used to open and create the shared memory segment must be unique for each data directory. This is done by using a strong hash of the canonical form of the data directory’s pathname. This also re- moves any risk of other applications, or other databases’ memory segments colliding with the current shared memory segment, which conveniently simplifies the logic. The algorithm changes are described by the before and after flowchart PDF included in the tarball below. There is also a Windows version of this patch included, which can replace the current SysV-to-Win32 shared memory layer as it currently does not check for orphaned backends in the database. If this is used, src/backend/port/win32/shmem.c and its makefile reference can be removed. Included is a patch for the configure.in file to opt-in all of the supported platforms to use this POSIX shared memory layer except those that are explicitly excluded (of course, this could be done in reverse if desired). Notably, NetBSD and OpenBSD do not support the POSIX shared memory calls and their template patches are included. Other platforms should be tested and excluded as needed. In addition, the documentation section 16.4.1 ‘Shared Memory and Sema- phores’ could be largely pruned and updated to reflect use of the POSIX calls. The patches are available here (the postings were being silently dropped when I attached this large of a file): http://homepage.mac.com/cmarcellino/postgres-posix-shmem.tar Please let me know if there is a better way to post this. Thanks for your feedback, Chris Marcellino
В списке pgsql-patches по дате отправления: