Fixed deadlock when partition eviction run in different threads.
@@ -809,6 +809,9 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
boolean created = false;
+ ctx.database().checkpointReadLock();
+
+ try {
lock.writeLock().lock();
try {
@@ -860,6 +863,10 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
finally {
lock.writeLock().unlock();
}
+ }
+ finally {
+ ctx.database().checkpointReadUnlock();
+ }
if (created && ctx.pageStore() != null) {
try {
@@ -1544,6 +1551,9 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
return false;
}
+ ctx.database().checkpointReadLock();
+
+ try {
lock.writeLock().lock();
try {
@@ -1660,6 +1670,10 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
lock.writeLock().unlock();
}
}
+ finally {
+ ctx.database().checkpointReadUnlock();
+ }
+ }
/** {@inheritDoc} */
@Override public void onExchangeDone(GridDhtPartitionsExchangeFuture fut, AffinityAssignment assignment, boolean updateRebalanceVer) {
@@ -1775,6 +1789,9 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
/** {@inheritDoc} */
@Override public boolean detectLostPartitions(AffinityTopologyVersion resTopVer, DiscoveryEvent discoEvt) {
+ ctx.database().checkpointReadLock();
+
+ try {
lock.writeLock().lock();
try {
@@ -1861,9 +1878,16 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
lock.writeLock().unlock();
}
}
+ finally {
+ ctx.database().checkpointReadUnlock();
+ }
+ }
/** {@inheritDoc} */
@Override public void resetLostPartitions(AffinityTopologyVersion resTopVer) {
+ ctx.database().checkpointReadLock();
+
+ try {
lock.writeLock().lock();
try {
@@ -1895,6 +1919,10 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
lock.writeLock().unlock();
}
}
+ finally {
+ ctx.database().checkpointReadUnlock();
+ }
+ }
/** {@inheritDoc} */
@Override public Collection<Integer> lostPartitions() {
@@ -1930,6 +1958,9 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
@Override public Set<UUID> setOwners(int p, Set<UUID> owners, boolean haveHistory, boolean updateSeq) {
Set<UUID> result = haveHistory ? Collections.<UUID>emptySet() : new HashSet<UUID>();
+ ctx.database().checkpointReadLock();
+
+ try {
lock.writeLock().lock();
try {
@@ -1986,6 +2017,10 @@ public class GridDhtPartitionTopologyImpl implements GridDhtPartitionTopology {
finally {
lock.writeLock().unlock();
}
+ }
+ finally {
+ ctx.database().checkpointReadUnlock();
+ }
return result;
}
