Fix the fallback memory barrier implementation to be reentrant.
Fix the fallback memory barrier implementation to be reentrant.

This was essentially "broken" since 0c8eda62; but until more
recently (14e8803f) barriers usage in signal handlers was infrequent.

The failure to be reentrant was noticed because the test_shm_mq, which
uses memory barriers at a high frequency, occasionally got stuck on some
solaris buildfarm animals. Turns out, those machines use sun studio
12.1, which doesn't yet have efficient memory barrier support. A machine
with a newer sun studio did not fail.  Forcing the barrier fallback to
be used on x86 allows to reproduce the problem.

The new fallback is to use kill(PostmasterPid, 0) based on the theory
that that'll always imply a barrier due to checking the liveliness of
PostmasterPid on systems old enough to need fallback support. It's hard
to come up with a good and performant fallback.

I'm not backpatching this for now - the problem isn't active in the back
branches, and we haven't backpatched barrier changes for
now. Additionally master looks entirely different than the back branches
due to the new atomics abstraction. It seems better to let this rest in
master, where the non-reentrancy actively causes a problem, and then
consider backpatching.

Found-By: Robert Haas
Discussion: b30e597692359d99cc10438d5db6a1fd36d52cc8@dunslane.net

pavanvd/postgres-xl,xinzweb/gpdb,jmcatamney/gpdb,techdragon/Postgres-XL,jmcatamney/gpdb,adam8157/gpdb,jmcatamney/gpdb,lisakowen/gpdb,lisakowen/gpdb,lisakowen/gpdb,xinzweb/gpdb,yazun/postgres-xl,ashwinstar/gpdb,pavanvd/postgres-xl,50wu/gpdb,adam8157/gpdb,50wu/gpdb,ovr/postgres-xl,lisakowen/gpdb,pavanvd/postgres-xl,greenplum-db/gpdb,ovr/postgres-xl,ovr/postgres-xl,adam8157/gpdb,zeroae/postgres-xl,50wu/gpdb,techdragon/Postgres-XL,yazun/postgres-xl,greenplum-db/gpdb,50wu/gpdb,xinzweb/gpdb,Postgres-XL/Postgres-XL,ashwinstar/gpdb,adam8157/gpdb,xinzweb/gpdb,ovr/postgres-xl,yazun/postgres-xl,xinzweb/gpdb,xinzweb/gpdb,Postgres-XL/Postgres-XL,yazun/postgres-xl,Postgres-XL/Postgres-XL,lisakowen/gpdb,zeroae/postgres-xl,jmcatamney/gpdb,greenplum-db/gpdb,oberstet/postgres-xl,zeroae/postgres-xl,oberstet/postgres-xl,greenplum-db/gpdb,50wu/gpdb,ashwinstar/gpdb,oberstet/postgres-xl,50wu/gpdb,zeroae/postgres-xl,oberstet/postgres-xl,techdragon/Postgres-XL,pavanvd/postgres-xl,yazun/postgres-xl,techdragon/Postgres-XL,ashwinstar/gpdb,pavanvd/postgres-xl,lisakowen/gpdb,Postgres-XL/Postgres-XL,lisakowen/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,xinzweb/gpdb,ashwinstar/gpdb,50wu/gpdb,50wu/gpdb,ashwinstar/gpdb,ovr/postgres-xl,adam8157/gpdb,Postgres-XL/Postgres-XL,ashwinstar/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,zeroae/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,adam8157/gpdb,adam8157/gpdb,xinzweb/gpdb,oberstet/postgres-xl,techdragon/Postgres-XL,lisakowen/gpdb,greenplum-db/gpdb