I tried to build PostgreSQL with the following step to see backends hung during the regression test. The problem has been reproduced on two machine but both of these are the same type of hardware and software. I also tried to recreate the problem on other machines, on older version of AIX but I couldn't.
I tried to build PostgreSQL with the following step to see backends hung
during the regression test. The problem has been reproduced on two machine
but both of these are the same type of hardware and software. I also tried
to recreate the problem on other machines, on older version of AIX but I
couldn't.

After looked through pgsql-hackers mailing list, I focused on spin lock
issue to solve the problem. The easiest and may not be the best solution
for the problem is to give up HAS_TEST_AND_SET. This actually works.

One another and better solution for the problem is to use _check_lock() and
_clear_lock() as spin lock.  Important thing here is to define S_UNLOCK()
with _clear_lock().  This will solve the so called "Compiler bug" issue
someone wrote on the mailing list.

We have some other API such as cs(), compare_and_swap() and fetch_and_or()
to do test and set on AIX, but any of these didn't solve my problem.  I
wrote tiny testing program to see if we have any bug of these API of AIX,
but I couldn't see any problem except for compare_and_swap(). It seems that
you can not use compare_and_swap() for the purpose, as it would not work as
spin lock on any SMP machines I tested.  I don't know the reason why cs()
nor fetch_and_or()/fetch_and_and() will not work with PostgreSQL on p690.
These worked with my testing program on all machines I tested.

Tomoyuki Niijima

yazun/postgres-xl,zeroae/postgres-xl,lisakowen/gpdb,CraigHarris/gpdb,royc1/gpdb,ovr/postgres-xl,adam8157/gpdb,yazun/postgres-xl,zaksoup/gpdb,janebeckman/gpdb,CraigHarris/gpdb,rubikloud/gpdb,rvs/gpdb,jmcatamney/gpdb,xinzweb/gpdb,postmind-net/postgres-xl,Quikling/gpdb,rvs/gpdb,xuegang/gpdb,xuegang/gpdb,foyzur/gpdb,yazun/postgres-xl,0x0FFF/gpdb,Chibin/gpdb,rvs/gpdb,ahachete/gpdb,rvs/gpdb,Quikling/gpdb,arcivanov/postgres-xl,cjcjameson/gpdb,greenplum-db/gpdb,chrishajas/gpdb,royc1/gpdb,cjcjameson/gpdb,rvs/gpdb,xuegang/gpdb,kaknikhil/gpdb,edespino/gpdb,tpostgres-projects/tPostgres,randomtask1155/gpdb,royc1/gpdb,randomtask1155/gpdb,Chibin/gpdb,Quikling/gpdb,cjcjameson/gpdb,Chibin/gpdb,jmcatamney/gpdb,yuanzhao/gpdb,lpetrov-pivotal/gpdb,foyzur/gpdb,arcivanov/postgres-xl,kaknikhil/gpdb,atris/gpdb,yuanzhao/gpdb,ashwinstar/gpdb,janebeckman/gpdb,chrishajas/gpdb,ashwinstar/gpdb,lintzc/gpdb,lintzc/gpdb,tangp3/gpdb,snaga/postgres-xl,ashwinstar/gpdb,lpetrov-pivotal/gpdb,cjcjameson/gpdb,0x0FFF/gpdb,greenplum-db/gpdb,zaksoup/gpdb,kmjungersen/PostgresXL,pavanvd/postgres-xl,ahachete/gpdb,cjcjameson/gpdb,arcivanov/postgres-xl,randomtask1155/gpdb,kaknikhil/gpdb,lisakowen/gpdb,jmcatamney/gpdb,Chibin/gpdb,randomtask1155/gpdb,tangp3/gpdb,0x0FFF/gpdb,xinzweb/gpdb,greenplum-db/gpdb,Postgres-XL/Postgres-XL,yazun/postgres-xl,janebeckman/gpdb,postmind-net/postgres-xl,greenplum-db/gpdb,chrishajas/gpdb,edespino/gpdb,ovr/postgres-xl,Chibin/gpdb,CraigHarris/gpdb,rubikloud/gpdb,lisakowen/gpdb,royc1/gpdb,royc1/gpdb,Chibin/gpdb,edespino/gpdb,rvs/gpdb,atris/gpdb,xuegang/gpdb,royc1/gpdb,lpetrov-pivotal/gpdb,tangp3/gpdb,foyzur/gpdb,50wu/gpdb,randomtask1155/gpdb,xuegang/gpdb,postmind-net/postgres-xl,lintzc/gpdb,rubikloud/gpdb,kaknikhil/gpdb,0x0FFF/gpdb,xinzweb/gpdb,lintzc/gpdb,jmcatamney/gpdb,rubikloud/gpdb,oberstet/postgres-xl,pavanvd/postgres-xl,lisakowen/gpdb,snaga/postgres-xl,jmcatamney/gpdb,lintzc/gpdb,janebeckman/gpdb,Postgres-XL/Postgres-XL,xinzweb/gpdb,adam8157/gpdb,kaknikhil/gpdb,tpostgres-projects/tPostgres,adam8157/gpdb,kmjungersen/PostgresXL,rubikloud/gpdb,50wu/gpdb,xuegang/gpdb,foyzur/gpdb,lisakowen/gpdb,greenplum-db/gpdb,zeroae/postgres-xl,Quikling/gpdb,rvs/gpdb,janebeckman/gpdb,lintzc/gpdb,yuanzhao/gpdb,xinzweb/gpdb,greenplum-db/gpdb,postmind-net/postgres-xl,arcivanov/postgres-xl,chrishajas/gpdb,zeroae/postgres-xl,kmjungersen/PostgresXL,yuanzhao/gpdb,lisakowen/gpdb,lpetrov-pivotal/gpdb,lpetrov-pivotal/gpdb,oberstet/postgres-xl,janebeckman/gpdb,jmcatamney/gpdb,lintzc/gpdb,zeroae/postgres-xl,kaknikhil/gpdb,lisakowen/gpdb,xuegang/gpdb,rubikloud/gpdb,adam8157/gpdb,0x0FFF/gpdb,adam8157/gpdb,techdragon/Postgres-XL,ahachete/gpdb,cjcjameson/gpdb,yuanzhao/gpdb,CraigHarris/gpdb,cjcjameson/gpdb,arcivanov/postgres-xl,lintzc/gpdb,Quikling/gpdb,0x0FFF/gpdb,kaknikhil/gpdb,chrishajas/gpdb,techdragon/Postgres-XL,atris/gpdb,randomtask1155/gpdb,tangp3/gpdb,edespino/gpdb,ahachete/gpdb,edespino/gpdb,CraigHarris/gpdb,50wu/gpdb,atris/gpdb,tpostgres-projects/tPostgres,rubikloud/gpdb,tangp3/gpdb,royc1/gpdb,xinzweb/gpdb,edespino/gpdb,CraigHarris/gpdb,zaksoup/gpdb,ahachete/gpdb,cjcjameson/gpdb,cjcjameson/gpdb,xinzweb/gpdb,zaksoup/gpdb,rvs/gpdb,zeroae/postgres-xl,0x0FFF/gpdb,lpetrov-pivotal/gpdb,snaga/postgres-xl,janebeckman/gpdb,ashwinstar/gpdb,kmjungersen/PostgresXL,ashwinstar/gpdb,Quikling/gpdb,zaksoup/gpdb,rvs/gpdb,snaga/postgres-xl,ovr/postgres-xl,janebeckman/gpdb,lisakowen/gpdb,50wu/gpdb,edespino/gpdb,ovr/postgres-xl,foyzur/gpdb,Chibin/gpdb,zaksoup/gpdb,janebeckman/gpdb,oberstet/postgres-xl,Chibin/gpdb,atris/gpdb,Chibin/gpdb,ovr/postgres-xl,pavanvd/postgres-xl,tangp3/gpdb,edespino/gpdb,rubikloud/gpdb,adam8157/gpdb,xuegang/gpdb,janebeckman/gpdb,tpostgres-projects/tPostgres,yazun/postgres-xl,xinzweb/gpdb,atris/gpdb,50wu/gpdb,yuanzhao/gpdb,xuegang/gpdb,Quikling/gpdb,snaga/postgres-xl,yuanzhao/gpdb,royc1/gpdb,adam8157/gpdb,tangp3/gpdb,edespino/gpdb,techdragon/Postgres-XL,ashwinstar/gpdb,CraigHarris/gpdb,ashwinstar/gpdb,yuanzhao/gpdb,yuanzhao/gpdb,yuanzhao/gpdb,techdragon/Postgres-XL,adam8157/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,ahachete/gpdb,edespino/gpdb,chrishajas/gpdb,kaknikhil/gpdb,kmjungersen/PostgresXL,lpetrov-pivotal/gpdb,Postgres-XL/Postgres-XL,randomtask1155/gpdb,rvs/gpdb,oberstet/postgres-xl,chrishajas/gpdb,foyzur/gpdb,arcivanov/postgres-xl,zaksoup/gpdb,zaksoup/gpdb,50wu/gpdb,lintzc/gpdb,pavanvd/postgres-xl,randomtask1155/gpdb,50wu/gpdb,techdragon/Postgres-XL,kaknikhil/gpdb,Quikling/gpdb,tpostgres-projects/tPostgres,jmcatamney/gpdb,pavanvd/postgres-xl,ahachete/gpdb,cjcjameson/gpdb,50wu/gpdb,CraigHarris/gpdb,atris/gpdb,foyzur/gpdb,Quikling/gpdb,postmind-net/postgres-xl,0x0FFF/gpdb,foyzur/gpdb,CraigHarris/gpdb,ahachete/gpdb,jmcatamney/gpdb,tangp3/gpdb,Chibin/gpdb,chrishajas/gpdb,Postgres-XL/Postgres-XL,oberstet/postgres-xl,greenplum-db/gpdb,Postgres-XL/Postgres-XL,kaknikhil/gpdb,atris/gpdb,Quikling/gpdb,lpetrov-pivotal/gpdb