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

Commit1b468a1

Browse files
committed
Fix the fallback memory barrier implementation to be reentrant.
This was essentially "broken" since0c8eda6; but until morerecently (14e8803) barriers usage in signal handlers was infrequent.The failure to be reentrant was noticed because the test_shm_mq, whichuses memory barriers at a high frequency, occasionally got stuck on somesolaris buildfarm animals. Turns out, those machines use sun studio12.1, which doesn't yet have efficient memory barrier support. A machinewith a newer sun studio did not fail. Forcing the barrier fallback tobe used on x86 allows to reproduce the problem.The new fallback is to use kill(PostmasterPid, 0) based on the theorythat that'll always imply a barrier due to checking the liveliness ofPostmasterPid on systems old enough to need fallback support. It's hardto come up with a good and performant fallback.I'm not backpatching this for now - the problem isn't active in the backbranches, and we haven't backpatched barrier changes fornow. Additionally master looks entirely different than the back branchesdue to the new atomics abstraction. It seems better to let this rest inmaster, where the non-reentrancy actively causes a problem, and thenconsider backpatching.Found-By: Robert HaasDiscussion: 55626265.3060800@dunslane.net
1 parent5ca6118 commit1b468a1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

‎src/backend/port/atomics.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,32 @@
2020
*/
2121
#defineATOMICS_INCLUDE_DEFINITIONS
2222

23+
#include"miscadmin.h"
2324
#include"port/atomics.h"
2425
#include"storage/spin.h"
2526

27+
#ifdefPG_HAVE_MEMORY_BARRIER_EMULATION
28+
#ifdefWIN32
29+
#error "barriers are required (and provided) on WIN32 platforms"
30+
#endif
31+
#include<sys/types.h>
32+
#include<signal.h>
33+
#endif
34+
2635
#ifdefPG_HAVE_MEMORY_BARRIER_EMULATION
2736
void
2837
pg_spinlock_barrier(void)
2938
{
30-
S_LOCK(&dummy_spinlock);
31-
S_UNLOCK(&dummy_spinlock);
39+
/*
40+
* NB: we have to be reentrant here, some barriers are placed in signal
41+
* handlers.
42+
*
43+
* We use kill(0) for the fallback barrier as we assume that kernels on
44+
* systems old enough to require fallback barrier support will include an
45+
* appropriate barrier while checking the existence of the postmaster
46+
* pid.
47+
*/
48+
(void)kill(PostmasterPid,0);
3249
}
3350
#endif
3451

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp