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

Server-side functions not working anymore in v3.2.2 #9690

Closed
Funky89 opened this issue Sep 30, 2021 · 13 comments
Closed

Server-side functions not working anymore in v3.2.2 #9690

Funky89 opened this issue Sep 30, 2021 · 13 comments
Assignees
Labels
Milestone

Comments

@Funky89
Copy link

Funky89 commented Sep 30, 2021

OrientDB Version: 3.2.2

Java Version: JDK8

OS: Debian 10

Hello everyone
Having updated from version 2.2.31 to 3.2.2
I have currently done several functions but this one no longer works on 3.2.2

For example:

var db = orient.getGraphNoTx();

var retour = {};
odbCountryCode = odbCountryCode.toUpperCase();
var Clogins = db.getVertexType("Logins_"+ odbCountryCode) || db.createVertexType("Logins_"+ odbCountryCode, "Logins");

I tried by replacing orient.getGraphNoTx() by orient.getDatabase()

Error on parsing script at position #0: Error on execution of the script\nScript: InsertNewLogin\n------^\r\n\tDB name=\"Totoum\"\norg.graalvm.polyglot.PolyglotException: TypeError: invokeMember (getDatabase) on com.orientechnologies.orient.core.command.script.OScriptOrientWrapper@4956c6ae failed due to: Unknown identifier: getDatabase\nTypeError: invokeMember (getDatabase) on com.orientechnologies.orient.core.command.script.OScriptOrientWrapper@4956c6ae failed due to: Unknown identifier: getDatabase"

I tried to put the value in orientdb-server-config.xml

<entry value="false" name="OGlobalConfiguration.SCRIPT_POLYGLOT_USE_GRAAL" />

But in the logs here is what it returns to me:

Ignored storage configuration because not supported: OGlobalConfiguration.SCRIPT_POLYGLOT_USE_GRAAL = null [OClusterBasedStorageConfiguration]

I also read that the problem could come from TinkerPop which has been removed but honestly I am lost in relation to the documentation. I have not found an alternative on the functions that are no longer present
Do you have any information to provide me on the migration from the old functions to the new ones or any other information ?

Best Regards

@calebeaires
Copy link

Same here.

@calebeaires
Copy link

@Funky89 have you find a way?

@Funky89
Copy link
Author

Funky89 commented Dec 15, 2021

@calebeaires

To deactivate GRAAL you have to use :

<entry name="script.polyglot.useGraal" value="false" />

All functions have changed. So we have to replace the old ones with the new ones that are here
https://orientdb.org/docs/3.2.x/java/ref/

For info my old code:

var db = orient.getGraphNoTx();
var Clogins = db.getVertexType("Logins_"+ odbCountryCode) || db.createVertexType("Logins_"+ odbCountryCode, "Logins");

BECOMES :

var gdb = orient.getDatabase();
var Schema = gdb.getMetadata().getSchema ();
var Clogins = Schema.getOrCreateClass ("Logins _" + odbCountryCode, Schema.getClass ("Logins")); 

@tglman tglman added this to the 3.2.x milestone Feb 23, 2022
@tglman
Copy link
Member

tglman commented Dec 23, 2022

Hi All,

The use of the graal runtime for functions should be fixed from 3.2.6, with more improvements in 3.2.14 please upgrade and test again.

Bye

@tglman tglman added the bug label Dec 23, 2022
@tglman tglman modified the milestones: 3.2.x, 3.2.14 Dec 23, 2022
@praveen-mamdge
Copy link

@tglman I am encountering an exception when attempting to use the getDatabase() function in OrientDB Studio with GraalVM enabled. When I execute the script,
let db = orient.getDatabase()

The following exception I see:
{ "errors": [ { "code": 400, "reason": "Bad request", "content": "Error on parsing script at position #10: Error on execution of the script\nScript: TestFunction\n---------------^\r\n\tDB name=\"TestDB\"\norg.graalvm.polyglot.PolyglotException: TypeError: invokeMember (getDatabase) on null failed due to: Message not supported.\nTypeError: invokeMember (getDatabase) on null failed due to: Message not supported." } ] }

However, when I disable GraalVM using the script.polyglot.useGraal = false option, then I don't get any exception.

I am using OrientDB version 3.2.14. Is it possible to use server-side functions with GraalVM, and if so, how can I resolve the error I am experiencing when using getDatabase()?

Please let me know if you need any other information.

@tglman
Copy link
Member

tglman commented Feb 15, 2023

Hi,

the reason for this error is that the method orient.getDatabase() to get the database from a function has been deprecated since a while now is enough just use the variable db that should work with both engines.

Regards

@praveen-mamdge
Copy link

@tglman Thank you, server side script works without any issues.

@tglman
Copy link
Member

tglman commented Feb 15, 2023

Ok, so can I close this issue ?

@praveen-mamdge
Copy link

praveen-mamdge commented Feb 16, 2023

@tglman The scripts gets executed without any issues. Whereas we are facing issue while accessing the data received the query result -

When we execute the command var data = db.command("select from #249:0"), we are not able to access the result, even the object with the given RID is exist but when we try to access the data by logging it on console via stringify it is empty object. If we just log the received record then we get the result as "com.orientechnologies.orient.core.sql.parser.OLocalResultSetLifecycleDecorator@1efe660b" on the console.

Is there any handling we need to do explicitly to access the data received after running the command?

E.g. If we run the following script by disabling the UseGraal setting, we are getting JSON object with the details of record.

var db = orient.getDatabase();
var result = db.command("select from #249:0");
var data = result[0];
return data

Whereas if we run the same script with only change of replacing orient.getDatabase with db variable and enabling the UseGraal setting, we are getting undefined or null result -

var result = db.command("select from #249:0");
var data = result[0];
return data

Please let me know if you need any additional details.

@praveen-mamdge
Copy link

Hi @tglman, will you please provide your inputs on above? If you have need any other details then please let me know.

@tglman
Copy link
Member

tglman commented Feb 20, 2023

Hi @praveen-mamdge ,

So the command seems to return a result set, so you could return it directly or do:

var result = db.command("select from #249:0");
var data = result.next();
result.close();
return data

Regards

@praveen-mamdge
Copy link

praveen-mamdge commented Feb 21, 2023

Thanks @tglman.

There is one observation, now on db object the commit and rollback methods are not available? Ater enabling the graalVM we can see error for db.commit and db.rollback methods. We are getting following error.

{ "errors": [ { "code": 400, "reason": "Bad request", "content": "Error on parsing script at position #1: Error on execution of the script\nScript: TestFunction\n------^\r\n\tDB name=\"MC_InteliNotionDB\"\norg.graalvm.polyglot.PolyglotException: TypeError: invokeMember (rollback) on com.orientechnologies.orient.core.command.script.OScriptDatabaseWrapper@536ebdbf failed due to: Unknown identifier: rollback\nTypeError: invokeMember (rollback) on com.orientechnologies.orient.core.command.script.OScriptDatabaseWrapper@536ebdbf failed due to: Unknown identifier: rollback" } ] }

@tglman
Copy link
Member

tglman commented Sep 5, 2023

Hi,

this should be already fixed in 3.2.22, closing, feel free to reopen if you still have problems.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

5 participants