Explorar o código

HPCC-11302 - Fix implicit super file creation transaction retry

Hitting a timeout and retrying caused the automatically creted
superfile to be missing to any transaction steps that relied on
it.

Signed-off-by: Jake Smith <jake.smith@lexisnexis.com>
Jake Smith %!s(int64=11) %!d(string=hai) anos
pai
achega
b6acd2a705
Modificáronse 1 ficheiros con 12 adicións e 11 borrados
  1. 12 11
      dali/base/dadfs.cpp

+ 12 - 11
dali/base/dadfs.cpp

@@ -5387,9 +5387,6 @@ public:
 
     void attach(const char *_logicalname,IUserDescriptor *user)
     {
-        // will need more thought but this gives limited support for anon
-        if (isAnon())
-            return;
         assertex(!conn.get()); // already attached
         CriticalBlock block (sect);
         StringBuffer tail;
@@ -5407,9 +5404,6 @@ public:
 
     void detach(unsigned timeoutMs=INFINITE)
     {   
-        // will need more thought but this gives limited support for anon
-        if (isAnon())
-            return;
         assertex(conn.get()); // must be attached
         CriticalBlock block(sect);
         checkModify("CDistributedSuperFile::detach");
@@ -7496,6 +7490,15 @@ class CCreateSuperFileAction: public CDFAction
     IUserDescriptor *user;
     bool interleaved, created;
 
+    void clearSuper()
+    {
+        if (created)
+        {
+            created = false;
+            super->detach();
+        }
+        super.clear();
+    }
 public:
     CCreateSuperFileAction(CDistributedFileDirectory *_parent,
                            IUserDescriptor *_user,
@@ -7525,7 +7528,6 @@ public:
                 created = true;
                 transaction->addFile(super);
             }
-            addFileLock(super);
         }
         return super.getLink();
     }
@@ -7535,6 +7537,7 @@ public:
         // Attach the file to DFS, if wasn't there already
         if (created)
             super->attach(logicalname.get(), user);
+        addFileLock(super);
         if (lock())
             return true;
         unlock();
@@ -7547,15 +7550,13 @@ public:
     void retry()
     {
         // on retry, we need to remove the file so next lock doesn't fail
-        if (created)
-            super->detach();
+        clearSuper();
         CDFAction::retry();
     }
     void rollback()
     {
         state = TAS_FAILURE;
-        if (created)
-            super->detach();
+        clearSuper();
         CDFAction::rollback();
     }
 };