Fix deadlock with LWLockAcquireWithVar and LWLockWaitForVar.
Fix deadlock with LWLockAcquireWithVar and LWLockWaitForVar.

LWLockRelease should release all backends waiting with LWLockWaitForVar,
even when another backend has already been woken up to acquire the lock,
i.e. when releaseOK is false. LWLockWaitForVar can return as soon as the
protected value changes, even if the other backend will acquire the lock.
Fix that by resetting releaseOK to true in LWLockWaitForVar, whenever
adding itself to the wait queue.

This should fix the bug reported by MauMau, where the system occasionally
hangs when there is a lot of concurrent WAL activity and a checkpoint.
Backpatch to 9.4, where this code was added.

xinzweb/gpdb,50wu/gpdb,jmcatamney/gpdb,lisakowen/gpdb,50wu/gpdb,xinzweb/gpdb,ashwinstar/gpdb,50wu/gpdb,lisakowen/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,50wu/gpdb,adam8157/gpdb,xinzweb/gpdb,ashwinstar/gpdb,ashwinstar/gpdb,lisakowen/gpdb,xinzweb/gpdb,xinzweb/gpdb,adam8157/gpdb,50wu/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,xinzweb/gpdb,lisakowen/gpdb,lisakowen/gpdb,adam8157/gpdb,adam8157/gpdb,jmcatamney/gpdb,adam8157/gpdb,50wu/gpdb,ashwinstar/gpdb,adam8157/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,lisakowen/gpdb,ashwinstar/gpdb,50wu/gpdb,ashwinstar/gpdb,lisakowen/gpdb,adam8157/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,xinzweb/gpdb,xinzweb/gpdb,50wu/gpdb,ashwinstar/gpdb,lisakowen/gpdb,greenplum-db/gpdb,adam8157/gpdb,greenplum-db/gpdb