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

Query works on Studio, fails using REST API ( ... is not idempotent) #1589

Open
ExtReMLapin opened this issue May 10, 2024 · 4 comments
Open

Comments

@ExtReMLapin
Copy link

Hello it's me again

ArcadeDB Version:

ArcadeDB Server v24.5.1-SNAPSHOT (build 71472c4c05ae9278d0d5d71a919b31883e1ea767/1713899543605/main) is starting up... creating nodes and reading nodes

OS and JDK Version:

Running on Linux 5.15.0-100-generic - OpenJDK 64-Bit Server VM 11.0.22 for creating nodes and reading nodes

Expected behavior

Query should execute and not fail.

Actual behavior

Error :

{"error":"Cannot execute command","detail":"Query \u0027create vertex type CHUNK\u0027 is not idempotent","exception":"java.lang.IllegalArgumentException"}

mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]: java.lang.IllegalArgumentException: Query 'create vertex type CHUNK' is not idempotent
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at com.arcadedb.query.sql.SQLQueryEngine.query(SQLQueryEngine.java:92)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at com.arcadedb.database.LocalDatabase.query(LocalDatabase.java:1371)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at com.arcadedb.server.ServerDatabase.query(ServerDatabase.java:489)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at com.arcadedb.server.http.handler.GetQueryHandler.execute(GetQueryHandler.java:61)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at com.arcadedb.server.http.handler.DatabaseAbstractHandler.execute(DatabaseAbstractHandler.java:100)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at com.arcadedb.server.http.handler.AbstractServerHttpHandler.handleRequest(AbstractServerHttpHandler.java:127)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.RoutingHandler.handleRequest(RoutingHandler.java:93)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.handlers.PathHandler.handleRequest(PathHandler.java:104)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.Connectors.executeRootHandler(Connectors.java:393)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.protocol.http.HttpReadListener.handleEventWithNoRunningRequest(HttpReadListener.java:265)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.protocol.http.HttpReadListener.handleEvent(HttpReadListener.java:136)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:162)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:100)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at io.undertow.server.protocol.http.HttpOpenListener.handleEvent(HttpOpenListener.java:57)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:291)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.ChannelListeners$10.handleEvent(ChannelListeners.java:286)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.nio.QueuedNioTcpServer2.acceptTask(QueuedNioTcpServer2.java:178)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.nio.WorkerThread.safeRun(WorkerThread.java:612)
mai 10 09:31:51 cfia-IDEXTEND server.sh[1388]:         at org.xnio.nio.WorkerThread.run(WorkerThread.java:479)

Steps to reproduce

curl -X GET http://localhost:2480/api/v1/query/test/sql/create%20vertex%20type%20CHUNK --user root:rootroot

Do it using Studio and it works

firefox_zbU8AUz3s5.mp4

Yes I also tried the if not exist, it doesn't help, that was my original query.

@gramian
Copy link
Collaborator

gramian commented May 10, 2024

Hi,
this is by design. To send a command (anything that changes the databases, ie adding a vertex type), you need to use the command endpoint (see https://docs.arcadedb.com/#HTTP-API ). The query endpoint can only be used to read from a database, neither create, update, nor delete are allowed. The studio always uses the command endpoint.

@gramian gramian self-assigned this May 10, 2024
@ExtReMLapin
Copy link
Author

Alright thanks !

@ExtReMLapin
Copy link
Author

Just to be sure @gramian you meant Change the database schema, right ? Because we've been using this same endpoint (/query) to do everything in cypher, create nodes, relations etc, so technically READ, CREATE and UPDATE

Reading the documentation :

This command allows executing idempotent commands, like SELECT and MATCH:

It sounds like yes, I should be in "READ ONLY" using this endpoint, however we can create nodes and edges using Cypher, sounds like something that was missed in the documentation ? Or do you not have the required functions in OpenCypher to detect idempotency ?

@gramian gramian reopened this May 10, 2024
@gramian
Copy link
Collaborator

gramian commented May 10, 2024

Hmm, that would indeed be a bug. For SQL and SQLscript the query endpoint allows only READ operations. I am not using Cypher or Gremlin so I am referring this to @lvca .

@gramian gramian removed their assignment May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants