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

Error on using custom JS Function: OCommandScriptException #8940

Closed
creisle opened this issue Jul 3, 2019 · 5 comments
Closed

Error on using custom JS Function: OCommandScriptException #8940

creisle opened this issue Jul 3, 2019 · 5 comments
Assignees
Labels
Milestone

Comments

@creisle
Copy link

creisle commented Jul 3, 2019

OrientDB Version: 3.0.20

Java Version:

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

OS: centos07

Behavior

  • References to deleted or renamed functions do not throw errors
  • previously the function I am trying to call worked. However after editing and deleting unrelated functions, now any custom function will throw an error
  • Stack trace shows functions that have been deleted

I'm not sure I can reproduce this reliably b/c I am unsure how I got here since the functions causing the issues have been deleted and no longer exist

com.orientechnologies.orient.core.command.script.OCommandScriptException: ScriptManager: error <eval>:220:7 Expected ; but found displayRecord select displayRecord(*) from (select expand(out('ImpliedBy')) from 83:2775) ^ in <eval> at line number 220 at column number 7. Function previewStatement(ridParam): 
215: return 'name'; 
216: } 
217: 
218: function previewStatement(ridParam) { 
219: // format the conditions 
220: >>> select displayRecord(*) from (select expand(out('ImpliedBy')) from 83:2775) 
221: SELECT [] as conditions, 
222: previewOntology(relevance.sourceId, relevance.name)[0].preview as relevance, 
223: previewOntology(appliesTo.sourceId, appliesTo.name)[0].preview as object, 
224: previewEvidenceList(:ridParam)[0].evidence as evidence 
225: FROM (SELECT expand(:ridParam)) DB name="development"

I tried renaming the functions instead of editing the old ones to test if it just wasn't updating the functions. but it appears no matter what I do, the invalid function is called instead of the current one. despite the fact that it has been deleted

Steps to Reproduce Related? Problem

But I can reproduce what I think might be related to the problem?

create function calledByOtherFunction 'return 1;' IDEMPOTENT TRUE LANGUAGE JavaScript
create function callsOtherFunction 'return calledByOtherFunction();' IDEMPOTENT TRUE LANGUAGE JavaScript

select callsOtherFunction() // works

// go to the function editor page /studio/index.html#/database/<DBNAME>/browse
// rename calledByOtherFunction to calledByOtherFunctionRenamed

select callsOtherFunction() // still works....

the code does not update the reference so I am unsure as to why this doesn't cause a reference error to be thrown

{
    "result": [
        {
            "@type": "d",
            "@rid": "#6:0",
            "@version": 3,
            "@class": "OFunction",
            "idempotent": true,
            "code": "return 1;",
            "name": "calledByOtherFunctionRenamed",
            "language": "JavaScript"
        },
        {
            "@type": "d",
            "@rid": "#6:1",
            "@version": 2,
            "@class": "OFunction",
            "idempotent": true,
            "code": "return calledByOtherFunction();",
            "name": "callsOtherFunction",
            "language": "JavaScript"
        }
    ],
}

Note that I couldn't figure out how to rename the function with SQL only and not using the function editor page

@luigidellaquila
Copy link
Member

Hi @creisle

Thank you very much for reporting, I'll check it asap.
The only thing I can suggest for now is to stop and restart the server.
You can also check SELECT FROM OFunction and see if the functions are correct

Thanks

Luigi

@creisle
Copy link
Author

creisle commented Jul 4, 2019

thanks for the quick reply! i will try restarting the server.

I did double check the select from OFunction and the results there are correct (see above). the thrown error seems to be isolated to the one db

But i can reproduce the persistent after delete functions in a new db. Is there anywhere else functions get cached/stored other than OFunction?

@creisle
Copy link
Author

creisle commented Jul 5, 2019

@luigidellaquila server restart seems to have fixed the issue! was it the caching causing this then?

@luigidellaquila
Copy link
Member

Hi @creisle

Yes, I think so. Probably the function library is not correctly updated when renaming the function.
I'll check it ASAP

Thanks

Luigi

@luigidellaquila luigidellaquila self-assigned this Jul 8, 2019
luigidellaquila added a commit that referenced this issue Jul 8, 2019
@luigidellaquila
Copy link
Member

Hi @creisle

I just pushed a fix, now it should work fine

Thanks

Luigi

@luigidellaquila luigidellaquila added this to the 3.0.22 milestone Jul 8, 2019
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

2 participants