This is an automated email from the ASF dual-hosted git repository. zhouxj pushed a commit to branch feature/GEODE-10290 in repository https://gitbox.apache.org/repos/asf/geode.git
commit 7db94dedbd1d3b565b7fb2957b5f49f6a9bffc49 Author: zhouxh <gz...@pivotal.io> AuthorDate: Mon May 9 18:14:15 2022 -0700 GEODE-10290: GII requester should remove departed members --- .../internal/cache/InitialImageOperation.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java b/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java index 3c90a4ef14..1526320e97 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java +++ b/geode-core/src/main/java/org/apache/geode/internal/cache/InitialImageOperation.java @@ -358,7 +358,7 @@ public class InitialImageOperation { // remote_rvv will be filled with the versions of unfinished keys // then if recoveredRVV is still newer than the filled remote_rvv, do fullGII remote_rvv = received_rvv.getCloneForTransmission(); - keysOfUnfinishedOps = processReceivedRVV(remote_rvv, recoveredRVV); + keysOfUnfinishedOps = processReceivedRVV(remote_rvv, recoveredRVV, received_rvv); if (internalAfterCalculatedUnfinishedOps != null && internalAfterCalculatedUnfinishedOps.getRegionName().equals(region.getName())) { internalAfterCalculatedUnfinishedOps.run(); @@ -1052,19 +1052,23 @@ public class InitialImageOperation { /** * Compare the received RVV with local RVV and return a set of keys for unfinished operations. * - * @param remoteRVV RVV from provider + * @param remoteRVV RVV from provider to be filled with unfinished operations * @param localRVV RVV recovered from disk + * @param receivedRVV original RVV from provider to remove departed members * @return set for keys of unfinished operations. */ protected Set<Object> processReceivedRVV(RegionVersionVector remoteRVV, - RegionVersionVector localRVV) { + RegionVersionVector localRVV, RegionVersionVector receivedRVV) { if (remoteRVV == null) { return null; } // calculate keys for unfinished ops + Set<VersionSource> foundIds = new HashSet<>(); + foundIds.add(region.getVersionMember()); HashSet<Object> keys = new HashSet<>(); - if (region.getDataPolicy().withPersistence() - && localRVV.isNewerThanOrCanFillExceptionsFor(remoteRVV)) { + boolean isPersistentRegion = region.getDataPolicy().withPersistence(); + if ((isPersistentRegion && localRVV.isNewerThanOrCanFillExceptionsFor(remoteRVV)) + || !remoteRVV.getDepartedMembersSet().isEmpty()) { // only search for unfinished keys when localRVV has something newer // and the region is persistent region Iterator<RegionEntry> it = region.getBestIterator(false); @@ -1077,7 +1081,8 @@ public class InitialImageOperation { if (id == null) { id = myId; } - if (!remoteRVV.contains(id, stamp.getRegionVersion())) { + foundIds.add(id); + if (isPersistentRegion && !remoteRVV.contains(id, stamp.getRegionVersion())) { // found an unfinished operation keys.add(mapEntry.getKey()); remoteRVV.recordVersion(id, stamp.getRegionVersion()); @@ -1100,6 +1105,12 @@ public class InitialImageOperation { } } } + if (foundIds.size() > 0) { + if (localRVV != null) { + localRVV.removeOldMembers(foundIds); + } + receivedRVV.removeOldMembers(foundIds); + } return keys; }