From 5f48e23c4d116154d82dbaaeecb165e5a700aabe Mon Sep 17 00:00:00 2001 From: Suranjan Kumar Date: Fri, 16 Aug 2019 19:25:57 +0530 Subject: [PATCH] Instead of sync on PersistentMemberManager using CopyOnWrite structure There was a deadlock with revoke and unblock where revoke was taking lock on PersistentMemberManager and then requires lock on PersistenceAdvisorImpl. The intialization thread takes lock PersistenceAdvisorImpl and then to check whether the diskid is unblocked and requires lock on PersistentmemberManager --- .../internal/cache/persistence/PersistentMemberManager.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/PersistentMemberManager.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/PersistentMemberManager.java index 82a9f17f6..b439f1cbb 100644 --- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/PersistentMemberManager.java +++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/cache/persistence/PersistentMemberManager.java @@ -30,6 +30,7 @@ import com.gemstone.gemfire.distributed.internal.ProfileListener; import com.gemstone.gemfire.distributed.internal.membership.InternalDistributedMember; import com.gemstone.gemfire.i18n.LogWriterI18n; +import com.gemstone.gemfire.internal.CopyOnWriteHashSet; import com.gemstone.gemfire.internal.cache.GemFireCacheImpl; import com.gemstone.gemfire.internal.i18n.LocalizedStrings; import com.gemstone.gemfire.internal.util.TransformUtils; @@ -47,7 +48,7 @@ public class PersistentMemberManager { private Map pendingRevokes = new HashMap(); - private final Set doNotWait = new HashSet(); + private final Set doNotWait = new CopyOnWriteHashSet(); private volatile boolean unblockNonHostingBuckets = false; private static final Object TOKEN = new Object(); @@ -69,7 +70,7 @@ public void revokeMember(PersistentMemberPattern pattern) { } public boolean doNotWaitOnMember(PersistentMemberID id) { - synchronized (this) { + if (this.unblockNonHostingBuckets) { for (PersistentMemberPattern p : this.doNotWait) { if (p.matches(id)) return true;