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

ArcadeDB Studio java.lang.ArrayIndexOutOfBoundsException #1165

Closed
lvca opened this issue Jul 10, 2023 Discussed in #1161 · 16 comments
Closed

ArcadeDB Studio java.lang.ArrayIndexOutOfBoundsException #1165

lvca opened this issue Jul 10, 2023 Discussed in #1161 · 16 comments
Assignees
Labels
bug Something isn't working fixed
Milestone

Comments

@lvca
Copy link
Contributor

lvca commented Jul 10, 2023

Discussed in #1161

Originally posted by happy-kitty July 10, 2023
Trying "General" discussion as I got no response when asked this question at "Q&A".

Running ArcadeDB 23.6.1 in embedded server mode, the root password is set.
I can successfully log in the ArcadeDB Studio, see schema, server settings, metrics etc. SQL query select from schema:types works fine.
Most/all SQL queries throw ArrayIndexOutOfBoundsException, e.g. select count(*) from AnyOfDefinedTypes where AnyOfDefinedTypes is defined, has one bucket and zero or one records in it. Type inheritance isn't used.

Any idea? I ran into the same thing with 23.5.1 - while 23.4.1 works fine.

Here's the exception stack:
java.lang.ArrayIndexOutOfBoundsException: Index 151 out of bounds for length 1
at com.arcadedb.server.security.ServerSecurityDatabaseUser.requestAccessOnFile(ServerSecurityDatabaseUser.java:83)
at com.arcadedb.database.EmbeddedDatabase.checkPermissionsOnFile(EmbeddedDatabase.java:571)
at com.arcadedb.engine.Bucket.iterator(Bucket.java:245)
at com.arcadedb.query.sql.executor.SelectExecutionPlanner.isEmptyNoSubclasses(SelectExecutionPlanner.java:1480)
at com.arcadedb.query.sql.executor.SelectExecutionPlanner.handleClassAsTargetWithIndex(SelectExecutionPlanner.java:1454)
at com.arcadedb.query.sql.executor.SelectExecutionPlanner.handleClassAsTarget(SelectExecutionPlanner.java:1217)
at com.arcadedb.query.sql.executor.SelectExecutionPlanner.handleClassAsTarget(SelectExecutionPlanner.java:1206)
at com.arcadedb.query.sql.executor.SelectExecutionPlanner.handleFetchFromTarget(SelectExecutionPlanner.java:756)
at com.arcadedb.query.sql.executor.SelectExecutionPlanner.createExecutionPlan(SelectExecutionPlanner.java:143)
at com.arcadedb.query.sql.parser.SelectStatement.createExecutionPlan(SelectStatement.java:212)
at com.arcadedb.query.sql.parser.SelectStatement.execute(SelectStatement.java:206)
at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:73)
at com.arcadedb.query.sql.SQLQueryEngine.command(SQLQueryEngine.java:101)
at com.arcadedb.database.EmbeddedDatabase.command(EmbeddedDatabase.java:1293)
at com.arcadedb.server.ServerDatabase.command(ServerDatabase.java:446)
at com.arcadedb.server.http.handler.PostCommandHandler.executeCommand(PostCommandHandler.java:120)
at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:88)
at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:98)
at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:124)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
at java.base/java.lang.Thread.run(Thread.java:834)

@lvca lvca added this to the 23.7.1 milestone Jul 10, 2023
@lvca lvca self-assigned this Jul 10, 2023
lvca added a commit that referenced this issue Jul 10, 2023
@lvca lvca added the fixed label Jul 10, 2023
@lvca
Copy link
Contributor Author

lvca commented Jul 10, 2023

Ok, fixed in the main branch. Please let me know if you still see this issue popping up.

@lvca lvca closed this as completed Jul 10, 2023
@happy-kitty
Copy link

The problem remains,
The following sequence works only if the timeout is 4 or more seconds:

                    server = new ArcadeDBServer(buildDbConfig(lDbConfig));
                    server.start();
                    db = server.getOrCreateDatabase(dbName);
                    //TODO Remove when ArcadeDB issue is fixed in R23.7.1:
                    // https://github.com/ArcadeData/arcadedb/discussions/1165
                    try {
                        Thread.sleep(3000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    ArcadeDbInitializer.getInstance().createSchema(db, lDbConfig);

If not, the exception is thrown at the Studio login time:

2023-08-15 11:58:47.450 INFO  [SecurityGroupFileRepository$1] Server groups configuration changed, reloading it...<nsp-arcadedb> Error on command execution (PostQueryHandler)
java.lang.ArrayIndexOutOfBoundsException: Index 1321 out of bounds for length 1
	at com.arcadedb.server.security.ServerSecurityDatabaseUser.requestAccessOnFile(ServerSecurityDatabaseUser.java:83)
	at com.arcadedb.database.EmbeddedDatabase.checkPermissionsOnFile(EmbeddedDatabase.java:570)
	at com.arcadedb.engine.Bucket.count(Bucket.java:276)
	at com.arcadedb.database.EmbeddedDatabase.lambda$countType$6(EmbeddedDatabase.java:433)
	at com.arcadedb.database.EmbeddedDatabase.executeInReadLock(EmbeddedDatabase.java:1361)
	at com.arcadedb.database.EmbeddedDatabase.countType(EmbeddedDatabase.java:428)
	at com.arcadedb.query.sql.executor.FetchFromSchemaTypesStep.syncPull(FetchFromSchemaTypesStep.java:75)
	at com.arcadedb.query.sql.executor.LimitExecutionStep.syncPull(LimitExecutionStep.java:48)
	at com.arcadedb.query.sql.executor.SelectExecutionPlan.fetchNext(SelectExecutionPlan.java:44)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:44)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.query.sql.parser.SelectStatement.execute(SelectStatement.java:207)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:85)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:69)
	at com.arcadedb.query.sql.SQLQueryEngine.query(SQLQueryEngine.java:82)
	at com.arcadedb.database.EmbeddedDatabase.query(EmbeddedDatabase.java:1329)
	at com.arcadedb.server.ServerDatabase.query(ServerDatabase.java:473)
	at com.arcadedb.server.http.handler.PostQueryHandler.executeCommand(PostQueryHandler.java:38)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:91)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:98)
	at com.arcadedb.server.http.handler.AbstractHandler.handleRequest(AbstractHandler.java:125)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
	at java.base/java.lang.Thread.run(Thread.java:834)

@lvca lvca reopened this Aug 15, 2023
lvca added a commit that referenced this issue Aug 16, 2023
…rofiled resource is accessed during the rebuild of policies

Related to issue #1165
@lvca
Copy link
Contributor Author

lvca commented Aug 16, 2023

I can't reproduce this. Did you create additional users/groups?

@happy-kitty
Copy link

happy-kitty commented Aug 16, 2023

No, I didn't. The only security/access related thing I did was setting arcadedb.server.rootPassword

@happy-kitty
Copy link

FYI, I run the embedded server DB on a Linux box with 6 Xeon cores and 64GB of RAM using openJDK 11.0.20

@decentropy
Copy link

Getting ArrayIndexOutOfBoundsException frequently as well... both on Docker and running locally.

I am calling via remote url, and just running simple cypher commands,e.g. 'MATCH (n) RETURN COUNT(n) AS count'

It works for a bit then, gets stuck on this error (on a query that run okay before.. .then I have to restart ArcadeDB for it to work again.

@lvca
Copy link
Contributor Author

lvca commented Nov 20, 2023

From an initial analysis, this issue is related to the concurrent change of schema: the concurrent thread reads a hybrid of the old and new schema causing such an exception.

@decentropy do you have the stack trace of the exception when that happens? It would be very valuable to understand if the issue is in the Cypher module or somewhere else. Cypher and Gremlin both implicitly create new types from queries, so this is a validation of the analysis mentioned above.

@lvca
Copy link
Contributor Author

lvca commented Nov 20, 2023

Good news! I was able to create a multi-threads test case where a schema is updated while the security is continuously modified. Working on a fix.

@lvca
Copy link
Contributor Author

lvca commented Nov 20, 2023

@happy-kitty in your case, the database is created on db = server.getOrCreateDatabase(dbName); or it already exists?

lvca added a commit that referenced this issue Nov 20, 2023
@lvca
Copy link
Contributor Author

lvca commented Nov 20, 2023

The issue has been fixed. Not 100% sure if @happy-kitty case is different from @decentropy. Please comment this issue if you see the same issue again.

@lvca lvca closed this as completed Nov 20, 2023
@lvca lvca modified the milestones: 23.7.1, 23.11.1 Nov 20, 2023
@decentropy
Copy link

@decentropy do you have the stack trace of the exception when that happens?

Sure here you go... just happened again with query "MATCH (n) RETURN COUNT(n) AS count" called via remote/HTTP. It occasionally crashes, and I haven't figured out a pattern or cause.

com.arcadedb.exception.CommandParsingException: Error on executing Cypher query
	at com.arcadedb.cypher.query.CypherQueryEngine.command(CypherQueryEngine.java:80)
	at com.arcadedb.cypher.query.CypherQueryEngine.query(CypherQueryEngine.java:64)
	at com.arcadedb.database.EmbeddedDatabase.query(EmbeddedDatabase.java:1364)
	at com.arcadedb.server.ServerDatabase.query(ServerDatabase.java:489)
	at com.arcadedb.server.http.handler.PostQueryHandler.executeCommand(PostQueryHandler.java:38)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:96)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:99)
	at com.arcadedb.server.http.handler.AbstractServerHttpHandler.handleRequest(AbstractServerHttpHandler.java:126)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 64 out of bounds for length 57
	at com.arcadedb.server.security.ServerSecurityDatabaseUser.requestAccessOnFile(ServerSecurityDatabaseUser.java:83)
	at com.arcadedb.database.EmbeddedDatabase.checkPermissionsOnFile(EmbeddedDatabase.java:590)
	at com.arcadedb.engine.Bucket.iterator(Bucket.java:249)
	at com.arcadedb.query.sql.executor.FetchFromClusterExecutionStep.syncPull(FetchFromClusterExecutionStep.java:57)
	at com.arcadedb.query.sql.executor.FetchFromClustersExecutionStep$1.hasNext(FetchFromClustersExecutionStep.java:95)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:45)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.query.sql.parser.SelectStatement.execute(SelectStatement.java:186)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:77)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:61)
	at com.arcadedb.query.sql.SQLQueryEngine.query(SQLQueryEngine.java:92)
	at com.arcadedb.database.EmbeddedDatabase.query(EmbeddedDatabase.java:1357)
	at com.arcadedb.gremlin.ArcadeGraph.vertices(ArcadeGraph.java:242)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.lambda$new$0(GraphStep.java:70)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:158)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:155)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.hasNext(ExpandableStepIterator.java:47)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep.processAllStarts(ReducingBarrierStep.java:110)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep.processNextStart(ReducingBarrierStep.java:140)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:155)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:55)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.ScalarMapStep.processNextStart(ScalarMapStep.java:39)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:155)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)
	at com.arcadedb.gremlin.ArcadeGremlin$2.hasNext(ArcadeGremlin.java:105)
	at com.arcadedb.query.sql.executor.IteratorResultSet.hasNext(IteratorResultSet.java:37)
	at com.arcadedb.cypher.ArcadeCypher.execute(ArcadeCypher.java:75)
	at com.arcadedb.cypher.query.CypherQueryEngine.command(CypherQueryEngine.java:77)
	... 14 more

@happy-kitty
Copy link

If I remember correctly, in my case the DB gets created. We put ArcadeDB on hold because of this

@lvca
Copy link
Contributor Author

lvca commented Nov 20, 2023

@decentropy can you try with the latest snapshot in the main branch?

@decentropy
Copy link

@decentropy can you try with the latest snapshot in the main branch?

Using 23.11.1 (for a couple hours)...
I'll let you know if it crashes again, but so far it's looking good.

@decentropy
Copy link

sorry to say it does still crash with cypher (on 23.11.1)

com.arcadedb.exception.CommandParsingException: Error on executing Cypher query
	at com.arcadedb.cypher.query.CypherQueryEngine.command(CypherQueryEngine.java:80)
	at com.arcadedb.cypher.query.CypherQueryEngine.query(CypherQueryEngine.java:64)
	at com.arcadedb.database.EmbeddedDatabase.query(EmbeddedDatabase.java:1362)
	at com.arcadedb.server.ServerDatabase.query(ServerDatabase.java:489)
	at com.arcadedb.server.http.handler.PostQueryHandler.executeCommand(PostQueryHandler.java:38)
	at com.arcadedb.server.http.handler.PostCommandHandler.execute(PostCommandHandler.java:111)
	at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:99)
	at com.arcadedb.server.http.handler.AbstractServerHttpHandler.handleRequest(AbstractServerHttpHandler.java:127)
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:859)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 64 out of bounds for length 57
	at com.arcadedb.server.security.ServerSecurityDatabaseUser.requestAccessOnFile(ServerSecurityDatabaseUser.java:83)
	at com.arcadedb.database.EmbeddedDatabase.checkPermissionsOnFile(EmbeddedDatabase.java:588)
	at com.arcadedb.engine.EmbeddedBucket.iterator(EmbeddedBucket.java:262)
	at com.arcadedb.query.sql.executor.FetchFromClusterExecutionStep.syncPull(FetchFromClusterExecutionStep.java:57)
	at com.arcadedb.query.sql.executor.FetchFromClustersExecutionStep$1.hasNext(FetchFromClustersExecutionStep.java:95)
	at com.arcadedb.query.sql.parser.LocalResultSet.fetchNext(LocalResultSet.java:45)
	at com.arcadedb.query.sql.parser.LocalResultSet.<init>(LocalResultSet.java:40)
	at com.arcadedb.query.sql.parser.SelectStatement.execute(SelectStatement.java:188)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:77)
	at com.arcadedb.query.sql.parser.Statement.execute(Statement.java:61)
	at com.arcadedb.query.sql.SQLQueryEngine.query(SQLQueryEngine.java:92)
	at com.arcadedb.database.EmbeddedDatabase.query(EmbeddedDatabase.java:1355)
	at com.arcadedb.gremlin.ArcadeGraph.vertices(ArcadeGraph.java:244)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.lambda$new$0(GraphStep.java:70)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep.processNextStart(GraphStep.java:158)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:155)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.hasNext(ExpandableStepIterator.java:47)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep.processAllStarts(ReducingBarrierStep.java:110)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ReducingBarrierStep.processNextStart(ReducingBarrierStep.java:140)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:155)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:55)
	at org.apache.tinkerpop.gremlin.process.traversal.step.map.ScalarMapStep.processNextStart(ScalarMapStep.java:39)
	at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:155)
	at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:192)
	at com.arcadedb.gremlin.ArcadeGremlin$2.hasNext(ArcadeGremlin.java:108)
	at com.arcadedb.query.sql.executor.IteratorResultSet.hasNext(IteratorResultSet.java:37)
	at com.arcadedb.cypher.ArcadeCypher.execute(ArcadeCypher.java:75)
	at com.arcadedb.cypher.query.CypherQueryEngine.command(CypherQueryEngine.java:77)
	... 14 more

@lvca
Copy link
Contributor Author

lvca commented Dec 12, 2023

Fixed by #1341

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

3 participants