Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot drop index because one or more underlying files are not available #1216

Closed
marco-brandizi opened this issue Aug 22, 2023 · 12 comments
Closed
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@marco-brandizi
Copy link

ArcadeDB Version:

23.7.1

OS and JDK Version:

Linux 4.18.0-425.19.2.el8_7.x86_64 - OpenJDK 64-Bit Server VM 17.0.8 (Temurin-17.0.8+7)

Expected behavior

I'm trying to run this SQL script from the web interface (the Studio), to create a number of indexes on an existing database. The script is generated my a Python program of mine, which uses a list of types and fields, but that's not very relevant here.

In 23.4.1, macOS, Java 17, the indexes were created without problems. Here, I was hoping for the same.

Actual behavior

The script fails with the error: Cannot drop index 'CelComp:Concept:Resource[identifier]' because one or more underlying files are not available

Steps to reproduce

  1. Set up Arcade with this DB dump
  2. Start the the server
  3. Open the Studio and the database above
  4. Use the SQL Script option to run the attached .sql
  5. It gives the error above to me.
@lvca lvca self-assigned this Aug 22, 2023
@lvca lvca added the bug Something isn't working label Aug 22, 2023
@marco-brandizi
Copy link
Author

marco-brandizi commented Aug 27, 2023

Maybe I've got something more on this:

Caused by: com.arcadedb.exception.SchemaException: Index with name 'Accession%25253AResource_0_8835859003821190' was not found
        at com.arcadedb.schema.EmbeddedSchema.getIndexByName(EmbeddedSchema.java:474)
        at com.arcadedb.database.TransactionIndexContext.addFilesToLock(TransactionIndexContext.java:216)
        at com.arcadedb.database.TransactionContext.lockFilesInOrder(TransactionContext.java:733)
        at com.arcadedb.database.TransactionContext.commit1stPhase(TransactionContext.java:540)
        at com.arcadedb.database.TransactionContext.commit(TransactionContext.java:121)
        at com.arcadedb.database.EmbeddedDatabase.lambda$commit$2(EmbeddedDatabase.java:363)
        at com.arcadedb.database.EmbeddedDatabase.executeInReadLock(EmbeddedDatabase.java:1361)
        at com.arcadedb.database.EmbeddedDatabase.commit(EmbeddedDatabase.java:358)
        at com.arcadedb.index.lsm.LSMTreeIndex.lambda$build$12(LSMTreeIndex.java:602)
        at com.arcadedb.database.EmbeddedDatabase.lambda$scanBucket$9(EmbeddedDatabase.java:496)
        at com.arcadedb.engine.Bucket.scan(Bucket.java:198)
        at com.arcadedb.database.EmbeddedDatabase.lambda$scanBucket$10(EmbeddedDatabase.java:494)
        at com.arcadedb.database.EmbeddedDatabase.executeInReadLock(EmbeddedDatabase.java:1361)
        at com.arcadedb.database.EmbeddedDatabase.scanBucket(EmbeddedDatabase.java:489)
        at com.arcadedb.database.EmbeddedDatabase.scanBucket(EmbeddedDatabase.java:482)
        at com.arcadedb.index.lsm.LSMTreeIndex.build(LSMTreeIndex.java:596)
        at com.arcadedb.schema.EmbeddedSchema.createBucketIndex(EmbeddedSchema.java:1299)
        ... 31 more

When using the console, I get this message for a few types/fields only. The one above is for:

CREATE INDEX ON `Accession:Resource` ( identifier ) NOTUNIQUE

So, maybe it doesn't like the type name, but I can't understand why.

@lvca
Copy link
Contributor

lvca commented Aug 28, 2023

Are you building it inside a transaction?

@marco-brandizi
Copy link
Author

Are you building it inside a transaction?

I've tried both BEGIN/COMMIT and without transaction demarcation (assuming the Studio or the console auto-commit).

@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

I was able to reproduce the issue. Checking on it.

@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

It looks like the : character is not ArcadeDB schema friendly.

@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

Ok, the issue is definitely with the encoding of the name. It's called multiple times and if the name contains special characters, then the result of encoding is different (encoding an encoded char).

@marco-brandizi
Copy link
Author

Thank you. I guessed the problem might be in the building the index name.

For the moment, I'm using the older 23.4.1, I can possibly switch to other type names in future (at the moment, I need the X:Y syntax to overcome the Gremlin limit of not accepting multiple labels for a node).

While this can be fixed with escaping, in my opinion, it would be good if I could set an explicit index name for automatic indexes too.

@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

I was able to reproduce it with this simple test case:

@Test
  public void testIndexNameSpecialCharacters() {
    VertexType type = database.getSchema().createVertexType("This.is:special");
    type.createProperty("other.special:property", Type.STRING);
    final TypeIndex idx = type.createTypeIndex(Schema.INDEX_TYPE.LSM_TREE, true, "other.special:property");

    database.command("sql", "rebuild index " + idx.getName());
  }

Working to a fix.

By the way: you could use inheritance with ArcadeDB, so you could keep name simpler.

In your use case can you please provide an example of vertex that needs multiple labels?

@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

After some tests, actually it works:

  @Test
  public void testIndexNameSpecialCharactersUsingSQL() {
    database.command("sql", "create vertex type `This.is:special`");
    database.command("sql", "create property `This.is:special`.`other.special:property` string");

    database.async().waitCompletion();

    database.command("sql", "create index on `This.is:special`(`other.special:property`) unique");
    database.command("sql", "rebuild index `This.is:special[other.special:property]`");
  }

So there must be something in your schema that encoded twice the index names. Trying to figure it out.

As a quick workaround, can you use _ as a separator?

@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

Ok, finally able to isolate it with a test case:

  @Test
  public void testIndexNameSpecialCharactersUsingSQL() {
    database.command("sql", "create vertex type `This.is:special`");
    database.command("sql", "create property `This.is:special`.`other.special:property` string");
    database.transaction(() -> {
      database.newVertex("This.is:special").set("other.special:property", "testEncoding").save();
    });

    database.async().waitCompletion();

    database.command("sql", "create index on `This.is:special`(`other.special:property`) unique");
    database.command("sql", "rebuild index `This.is:special[other.special:property]`");

    database.close();

    database = factory.exists() ? factory.open() : factory.create();
    database.command("sql", "rebuild index `This.is:special[other.special:property]`");

    Assertions.assertEquals("testEncoding",
        database.query("sql", "select from `This.is:special` where `other.special:property` = 'testEncoding'").nextIfAvailable()
            .getProperty("other.special:property"));
  }

@marco-brandizi
Copy link
Author

Thanks again. If _ works, I can switch to that.
I can't use Arcade-specific features like inheritance, cause I'm trying to test Gremlin with data that come from graphml and where all the nodes have at least two labels attached. It seems the only way to emulate that in Gremlin is via tricks like this.

lvca added a commit that referenced this issue Aug 29, 2023
@lvca
Copy link
Contributor

lvca commented Aug 29, 2023

Fixed in the latest snapshot. Now the encoding is processed correctly, no need to change to _. ;-)

@lvca lvca closed this as completed Aug 29, 2023
@lvca lvca added this to the 23.9.1 milestone Aug 29, 2023
@lvca lvca added the fixed label Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

2 participants