You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uniffle.apache.org by GitBox <gi...@apache.org> on 2022/07/04 11:10:28 UTC

[GitHub] [incubator-uniffle] jerqi commented on a diff in pull request #16: [Bug] Fix NPE problem when process the event if application was cleared already

jerqi commented on code in PR #16:
URL: https://github.com/apache/incubator-uniffle/pull/16#discussion_r912895756


##########
server/src/main/java/org/apache/uniffle/server/ShuffleFlushManager.java:
##########
@@ -135,59 +139,62 @@ public void addToFlushQueue(ShuffleDataFlushEvent event) {
 
   private void flushToFile(ShuffleDataFlushEvent event) {
 
-    Storage storage = storageManager.selectStorage(event);
-    if (!storage.canWrite()) {
-      addPendingEvents(event);
-      return;
-    }
-
     long start = System.currentTimeMillis();
     List<ShufflePartitionedBlock> blocks = event.getShuffleBlocks();
     boolean writeSuccess = false;
     try {
-      if (blocks == null || blocks.isEmpty()) {
-        LOG.info("There is no block to be flushed: " + event);
-      } else if (!event.isValid()) {
-        //  avoid printing error log
-        writeSuccess = true;
-        LOG.warn("AppId {} was removed already, event {} should be dropped", event.getAppId(), event);
-      } else {
-        ShuffleWriteHandler handler = storage.getOrCreateWriteHandler(new CreateShuffleWriteHandlerRequest(
-            storageType,
-            event.getAppId(),
-            event.getShuffleId(),
-            event.getStartPartition(),
-            event.getEndPartition(),
-            storageBasePaths,
-            shuffleServerId,
-            hadoopConf,
-            storageDataReplica));
+      Storage storage = storageManager.selectStorage(event);
+      // storage info maybe null if the application cache was cleared already
+      if (storage != null) {
+        if (!storage.canWrite()) {
+          addPendingEvents(event);

Review Comment:
   Why do we put the code into 
   ```
   try {
   } catch {
   } finally {
   }
   ```
   We release memory in the finally block, when we add the event to PendingEvents, we shouldn't release the event memory.



##########
server/src/main/java/org/apache/uniffle/server/ShuffleFlushManager.java:
##########
@@ -285,7 +292,9 @@ void processPendingEvents() throws Exception {
           pendingEventTimeoutSec, event.getEvent());
       return;
     }
-    if (storage.canWrite()) {
+    // storage maybe null if the application cache was cleared already
+    // add event to flush queue, and it will be released
+    if (storage == null || storage.canWrite()) {

Review Comment:
   when storage equals `null`, why do we need add it to the FlushQueue?



-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@uniffle.apache.org

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