[GitHub] [geode] DonalEvans commented on a change in pull request #5014: GEODE-8035: Parallel Disk Store Recovery when Cluster Restarts

2020-04-28 Thread GitBox


DonalEvans commented on a change in pull request #5014:
URL: https://github.com/apache/geode/pull/5014#discussion_r416931125



##
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/DiskStoreFactoryImpl.java
##
@@ -144,7 +144,10 @@ public DiskStore create(String name) {
 // As a simple fix for 41290, only allow one DiskStore to be created
 // at a time per cache by syncing on the cache.

Review comment:
   This comment is no longer entirely accurate.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [geode] DonalEvans commented on a change in pull request #5014: GEODE-8035: Parallel Disk Store Recovery when Cluster Restarts

2020-04-28 Thread GitBox


DonalEvans commented on a change in pull request #5014:
URL: https://github.com/apache/geode/pull/5014#discussion_r416930455



##
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheCreation.java
##
@@ -521,12 +521,12 @@ void create(InternalCache cache)
 
 cache.initializePdxRegistry();
 
-for (DiskStore diskStore : diskStores.values()) {
+diskStores.values().parallelStream().forEach(diskStore -> {

Review comment:
   Would it be possible to put a bound on the number of threads used here? 
In cases with large numbers of disk stores this might cause resource issues if 
unbounded, but maybe we never have so many disk stores that it will matter.

##
File path: 
geode-core/src/main/java/org/apache/geode/internal/cache/GemFireCacheImpl.java
##
@@ -1086,6 +1088,32 @@ public static GemFireCacheImpl getForPdx(String reason) {
 clientMetadataService = clientMetadataServiceFactory.apply(this);
   }
 
+  public void lockDiskStore(String diskStoreName) {
+CountDownLatch countDownLatch = diskStoreLatches.get(diskStoreName);
+if (countDownLatch == null) {
+  countDownLatch = diskStoreLatches.putIfAbsent(diskStoreName, new 
CountDownLatch(1));
+  if (countDownLatch != null) {
+try {
+  countDownLatch.await();
+} catch (InterruptedException e) {
+  throw new InternalGemFireError(e);
+}
+  }
+} else {
+  try {
+countDownLatch.await();
+  } catch (InterruptedException e) {
+throw new InternalGemFireError(e);
+  }
+}
+  }
+
+  public void unlockDiskStore(String diskStoreName) {
+if (diskStoreLatches.get(diskStoreName) != null) {
+  diskStoreLatches.get(diskStoreName).countDown();
+}

Review comment:
   I think there is a small possibility of a race condition causing an NPE 
here if the latch associated with `diskStoreName` is removed after the first 
`get()` call. Would it be possible to change this method to use only one 
`get()` call?





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org