Przeglądaj źródła

Merge pull request #15175 from jakesmith/hpcc-26205-dfs-followon-crash

HPCC-26205 Ensure logical filename is cleared on attach failure

Reviewed-By: Attila Vamos <attila.vamos@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 4 lat temu
rodzic
commit
58cfb9e09e
1 zmienionych plików z 41 dodań i 23 usunięć
  1. 41 23
      dali/base/dadfs.cpp

+ 41 - 23
dali/base/dadfs.cpp

@@ -4082,20 +4082,29 @@ public:
         PROGLOG("CDistributedFile::attach(%s)",_logicalname);
         LOGPTREE("CDistributedFile::attach root.1",root);
 #endif
-        calculateSkew();
-        parent->addEntry(logicalName,root.getClear(),false,false);
-        killParts();
-        clusters.kill();
-        CFileLock fcl;
-        verifyex(fcl.init(logicalName, DXB_File, RTM_LOCK_READ, defaultTimeout, "CDistributedFile::attach"));
-        conn.setown(fcl.detach());
-        root.setown(conn->getRoot());
-        root->queryBranch(".");     // load branch
-        Owned<IFileDescriptor> fdesc = deserializeFileDescriptorTree(root,&queryNamedGroupStore(),0);
-        setFileAttrs(fdesc,false);
-        setClusters(fdesc);
-        setParts(fdesc,false);
-        setUserDescriptor(udesc, user);
+        try
+        {
+            calculateSkew();
+            parent->addEntry(logicalName,root.getClear(),false,false);
+            killParts();
+            clusters.kill();
+            CFileLock fcl;
+            verifyex(fcl.init(logicalName, DXB_File, RTM_LOCK_READ, defaultTimeout, "CDistributedFile::attach"));
+            conn.setown(fcl.detach());
+            root.setown(conn->getRoot());
+            root->queryBranch(".");     // load branch
+            Owned<IFileDescriptor> fdesc = deserializeFileDescriptorTree(root,&queryNamedGroupStore(),0);
+            setFileAttrs(fdesc,false);
+            setClusters(fdesc);
+            setParts(fdesc,false);
+            setUserDescriptor(udesc, user);
+        }
+        catch (IException *e)
+        {
+            EXCLOG(e, "CDistributedFile::attach");
+            logicalName.clear();
+            throw;
+        }
 #ifdef EXTRA_LOGGING
         LOGFDESC("CDistributedFile::attach fdesc",fdesc);
         LOGPTREE("CDistributedFile::attach root.2",root);
@@ -5784,15 +5793,24 @@ public:
         StringBuffer tail;
         StringBuffer lfn;
         logicalName.set(_logicalname);
-        checkLogicalName(logicalName,user,true,true,false,"attach");
-        parent->addEntry(logicalName,root.getClear(),true,false);
-        conn.clear();
-        CFileLock fcl;
-        verifyex(fcl.init(logicalName, DXB_SuperFile, RTM_LOCK_READ, defaultTimeout, "CDistributedSuperFile::attach"));
-        conn.setown(fcl.detach());
-        assertex(conn.get()); // must have been attached
-        root.setown(conn->getRoot());
-        loadSubFiles(NULL, 0, true);
+        try
+        {
+            checkLogicalName(logicalName,user,true,true,false,"attach");
+            parent->addEntry(logicalName,root.getClear(),true,false);
+            conn.clear();
+            CFileLock fcl;
+            verifyex(fcl.init(logicalName, DXB_SuperFile, RTM_LOCK_READ, defaultTimeout, "CDistributedSuperFile::attach"));
+            conn.setown(fcl.detach());
+            assertex(conn.get()); // must have been attached
+            root.setown(conn->getRoot());
+            loadSubFiles(NULL, 0, true);
+        }
+        catch (IException *e)
+        {
+            EXCLOG(e, "CDistributedSuperFile::attach");
+            logicalName.clear();
+            throw;
+        }
     }
 
     virtual void detach(unsigned timeoutMs=INFINITE, ICodeContext *ctx=NULL) override