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

Commitc124e36

Browse files
committed
Retry DSM control segment creation if Windows indicates access denied.
Otherwise, attempts to run multiple postmasters running on the samemachine may fail, because Windows sometimes returns ERROR_ACCESS_DENIEDrather than ERROR_ALREADY_EXISTS when there is an existing segment.Hitting this bug is much more likely because of another defect notfixed by this patch, namely that dsm_postmaster_startup() usesrandom() which returns the same value every time. But that's nota reason not to fix this.Kyotaro Horiguchi and Amit Kapila, reviewed by Michael PaquierDiscussion: <CAA4eK1JyNdMeF-dgrpHozDecpDfsRZUtpCi+1AbtuEkfG3YooQ@mail.gmail.com>
1 parentf0a86df commitc124e36

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,7 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
671671
{
672672
DWORDsize_high;
673673
DWORDsize_low;
674+
DWORDerrcode;
674675

675676
/* Shifts >= the width of the type are undefined. */
676677
#ifdef_WIN64
@@ -686,27 +687,31 @@ dsm_impl_windows(dsm_op op, dsm_handle handle, Size request_size,
686687
size_high,/* Upper 32 bits of size */
687688
size_low,/* Lower 32 bits of size */
688689
name);
690+
691+
errcode=GetLastError();
692+
if (errcode==ERROR_ALREADY_EXISTS||errcode==ERROR_ACCESS_DENIED)
693+
{
694+
/*
695+
* On Windows, when the segment already exists, a handle for the
696+
* existing segment is returned. We must close it before
697+
* returning. However, if the existing segment is created by a
698+
* service, then it returns ERROR_ACCESS_DENIED. We don't do
699+
* _dosmaperr here, so errno won't be modified.
700+
*/
701+
if (hmap)
702+
CloseHandle(hmap);
703+
return false;
704+
}
705+
689706
if (!hmap)
690707
{
691-
_dosmaperr(GetLastError());
708+
_dosmaperr(errcode);
692709
ereport(elevel,
693710
(errcode_for_dynamic_shared_memory(),
694711
errmsg("could not create shared memory segment \"%s\": %m",
695712
name)));
696713
return false;
697714
}
698-
_dosmaperr(GetLastError());
699-
if (errno==EEXIST)
700-
{
701-
/*
702-
* On Windows, when the segment already exists, a handle for the
703-
* existing segment is returned. We must close it before
704-
* returning. We don't do _dosmaperr here, so errno won't be
705-
* modified.
706-
*/
707-
CloseHandle(hmap);
708-
return false;
709-
}
710715
}
711716
else
712717
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp