You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mb...@apache.org on 2020/07/19 22:10:49 UTC

[asterixdb] 06/07: [NO ISSUE][STO] Use Index Resolved Path

This is an automated email from the ASF dual-hosted git repository.

mblow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git

commit c476a98360abcde9cfaca5dc1a84658f3482c886
Author: Murtadha Hubail <mh...@apache.org>
AuthorDate: Tue Jul 14 13:38:25 2020 +0300

    [NO ISSUE][STO] Use Index Resolved Path
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - When attempting to drop an existing index before recreating
      it, use the index resolved path based on the NC io devices
      resolver.
    
    Change-Id: I201ff17dc6deb02032d5e8603b28b7711ed0efab
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/7183
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Murtadha Hubail <mh...@apache.org>
    Reviewed-by: Till Westmann <ti...@apache.org>
---
 .../storage/am/common/build/IndexBuilder.java      | 27 +++++++++++-----------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/build/IndexBuilder.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/build/IndexBuilder.java
index f62860a..45bfed1 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/build/IndexBuilder.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/build/IndexBuilder.java
@@ -47,6 +47,7 @@ public class IndexBuilder implements IIndexBuilder {
     protected final IResourceFactory localResourceFactory;
     protected final boolean durable;
     private final IResourceIdFactory resourceIdFactory;
+    private final String resourceRelPath;
 
     /*
      * Ideally, we should not pass resource id factory to the constructor since we can obtain it through
@@ -62,6 +63,7 @@ public class IndexBuilder implements IIndexBuilder {
         this.localResourceFactory = localResourceFactory;
         this.durable = durable;
         this.resourceRef = resourceRef;
+        resourceRelPath = resourceRef.getRelativePath();
     }
 
     @Override
@@ -72,35 +74,34 @@ public class IndexBuilder implements IIndexBuilder {
             // physical artifact that the LocalResourceRepository is managing (e.g. a file containing the resource Id).
             // Once the index has been created, a new resource Id can be generated.
             ILocalResourceRepository localResourceRepository = storageManager.getLocalResourceRepository(ctx);
-            LocalResource lr = localResourceRepository.get(resourceRef.getRelativePath());
+            LocalResource lr = localResourceRepository.get(resourceRelPath);
             long resourceId = lr == null ? -1 : lr.getId();
             if (resourceId != -1) {
-                localResourceRepository.delete(resourceRef.getRelativePath());
+                localResourceRepository.delete(resourceRelPath);
             }
             resourceId = resourceIdFactory.createId();
             IResource resource = localResourceFactory.createResource(resourceRef);
             lr = new LocalResource(resourceId, ITreeIndexFrame.Constants.VERSION, durable, resource);
-            IIndex index = lcManager.get(resourceRef.getRelativePath());
+            IIndex index = lcManager.get(resourceRelPath);
             if (index != null) {
                 //how is this right?????????? <needs to be fixed>
                 //The reason for this is to handle many cases such as:
                 //1. Crash while delete index is running (we don't do global cleanup on restart)
                 //2. Node leaves and then join with old data
-                LOGGER.log(Level.WARN,
-                        "Removing existing index on index create for the index: " + resourceRef.getRelativePath());
-                lcManager.unregister(resourceRef.getRelativePath());
+                LOGGER.log(Level.WARN, "Removing existing index on index create for the index: " + resourceRelPath);
+                lcManager.unregister(resourceRelPath);
                 index.destroy();
             } else {
-                if (resourceRef.getFile().exists()) {
+                final FileReference resolvedResourceRef = ctx.getIoManager().resolve(resourceRelPath);
+                if (resolvedResourceRef.getFile().exists()) {
                     // Index is not registered but the index file exists
                     // This is another big problem that we need to disallow soon
                     // We can only disallow this if we have a global cleanup after crash
                     // on reboot
-                    LOGGER.log(Level.WARN,
-                            "Deleting " + resourceRef.getRelativePath()
-                                    + " on index create. The index is not registered"
-                                    + " but the file exists in the filesystem");
-                    IoUtil.delete(resourceRef);
+                    LOGGER.warn(
+                            "Deleting {} on index create. The index is not registered but the file exists in the filesystem",
+                            resolvedResourceRef);
+                    IoUtil.delete(resolvedResourceRef);
                 }
                 index = resource.createInstance(ctx);
             }
@@ -110,7 +111,7 @@ public class IndexBuilder implements IIndexBuilder {
             } catch (IOException e) {
                 throw HyracksDataException.create(e);
             }
-            lcManager.register(resourceRef.getRelativePath(), index);
+            lcManager.register(resourceRelPath, index);
         }
     }
 }