Преглед на файлове

HPCC-10800 Deleting files from one cluster may leave incorrect dali info

If a file is present on multiple clusters, and is deleted from the
first, then the directory information in dali is not properly adjusted.

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman преди 11 години
родител
ревизия
d9b3238b03
променени са 1 файла, в които са добавени 14 реда и са изтрити 0 реда
  1. 14 0
      dali/base/dadfs.cpp

+ 14 - 0
dali/base/dadfs.cpp

@@ -3379,6 +3379,7 @@ public:
             else
                 t->removeProp("@group");
             t->setPropInt("@numclusters",clusters.ordinality());
+            t->setProp("@directory", directory);
             if (t==tc)
                 break;
             t = tc; // now fix cache
@@ -3416,7 +3417,20 @@ public:
         if (i!=NotFound) {
             if (clusters.ordinality()==1)
                 throw MakeStringException(-1,"CFileClusterOwner::removeCluster cannot remove sole cluster %s",clustername);
+            // If the cluster is the 'default' one we need to update the directory too
+            StringBuffer oldBaseDir;
+            char pathSepChar = getPathSepChar(directory.get());
+            DFD_OS os = SepCharBaseOs(pathSepChar);
+            clusters.item(i).getBaseDir(oldBaseDir, os);
+            unsigned oldLen = oldBaseDir.length();
             clusters.remove(i);
+            if (oldLen && strncmp(directory, oldBaseDir, oldLen)==0 && (directory[oldLen]==pathSepChar || directory[oldLen]=='\0'))
+            {
+                StringBuffer newBaseDir;
+                clusters.item(0).getBaseDir(newBaseDir, os);
+                newBaseDir.append(directory.get() + oldBaseDir.length());
+                directory.set(newBaseDir);
+            }
             saveClusters();
             return true;
         }