Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit389869a

Browse files
committed
Harden dsm_impl.c against unexpected EEXIST.
Previously, we trusted the OS not to report EEXIST unless we'd passed inIPC_CREAT | IPC_EXCL or O_CREAT | O_EXCL, as appropriate. Solaris'sshm_open() can in fact do that, causing us to crash because we didn'tereport and then we blithely assumed the mapping was successful.Let's treat EEXIST just like any other error, unless we're actuallytrying to create a new segment. This applies to shm_open(), where thisbehavior has been seen, and also to the equivalent operations for oursysv and mmap modes just on principle.Based on the underlying reason for the error, namely contention on alock file managed by Solaris librt for each distinct name, this problemis only likely to happen on 15 and later, because the new shared memorystats system produces shm_open() calls for the same path frompotentially large numbers of backends concurrently duringauthentication. Earlier releases only shared memory segments between asmall number of parallel workers under one Gather node. You couldprobably hit it if you tried hard enough though, and we should have beenmore defensive in the first place. Therefore, back-patch to allsupported releases.Per build farm animal margay. This isn't the end of the story, though,it just changes random crashes into random "File exists" errors; morework needed for a green build farm.Reviewed-by: Robert Haas <robertmhaas@gmail.com>Discussion:https://postgr.es/m/CA%2BhUKGKqKrCV5xKWfh9rnm%3Do%3DDwZLTLtnsj_XpUi9g5%3DV%2B9oyg%40mail.gmail.com
1 parent33bd469 commit389869a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/backend/storage/ipc/dsm_impl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size request_size,
261261
if ((fd=shm_open(name,flags,PG_FILE_MODE_OWNER))==-1)
262262
{
263263
ReleaseExternalFD();
264-
if (errno!=EEXIST)
264+
if (op==DSM_OP_ATTACH||errno!=EEXIST)
265265
ereport(elevel,
266266
(errcode_for_dynamic_shared_memory(),
267267
errmsg("could not open shared memory segment \"%s\": %m",
@@ -500,7 +500,7 @@ dsm_impl_sysv(dsm_op op, dsm_handle handle, Size request_size,
500500

501501
if ((ident=shmget(key,segsize,flags))==-1)
502502
{
503-
if (errno!=EEXIST)
503+
if (op==DSM_OP_ATTACH||errno!=EEXIST)
504504
{
505505
intsave_errno=errno;
506506

@@ -822,7 +822,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
822822
flags=O_RDWR | (op==DSM_OP_CREATE ?O_CREAT |O_EXCL :0);
823823
if ((fd=OpenTransientFile(name,flags))==-1)
824824
{
825-
if (errno!=EEXIST)
825+
if (op==DSM_OP_ATTACH||errno!=EEXIST)
826826
ereport(elevel,
827827
(errcode_for_dynamic_shared_memory(),
828828
errmsg("could not open shared memory segment \"%s\": %m",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp