Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-6441

Parameters are not passed to JavaScript over js-client in case of mode=distributed

    XMLWordPrintable

Details

    Description

      When trying to execute a javascript on a cluster with "mode=distributed", the client gives the following error:

      java.util.concurrent.ExecutionException: org.infinispan.remoting.RemoteException: ISPN000217: Received exception from node1, see cause for remote stack trace
      org.infinispan.remoting.RemoteException: ISPN000217: Received exception from node1, see cause for remote stack trace
      org.infinispan.commons.marshall.NotSerializableException: jdk.nashorn.api.scripting.ScriptObjectMirror
      an exception which occurred:
      	in field ecmaError
      	in field cause
      	in field cause
      	in object org.infinispan.commons.CacheException@2800248d
      	in object org.infinispan.remoting.responses.ExceptionResponse@552fdef2
         Stacktrace:
           undefined
      

      The script which is needed to be executed on server is:

      // mode=distributed,language=javascript,parameters=[k, v],datatype='text/plain; charset=utf-8'
      cache.put(k, v);
      cache.get(k);
      
      

      The test code running the script is:

        it('can execute a script remotely to store and retrieve data in distributed mode', function(done) {
          Promise.all([client, readFile('spec/utils/typed-put-get-dist.js')])
              .then(function(vals) {
                var c = vals[0];
                return c.addScript('typed-put-get-dist.js', vals[1].toString())
                    .then(function() { return c; } );
              })
              .then(t.assert(t.exec('typed-put-get-dist.js', {k: 'typed-key', v: 'typed-value'}),
                  t.toContain(['typed-value', 'typed-value', 'typed-value'])))
              .catch(t.failed(done)).finally(done);
        });
      

      The exception which is thrown on the server is:

      19:50:42,927 WARN  [org.infinispan.remoting.inboundhandler.NonTotalOrderPerCacheInboundInvocationHandler] (remote-thread--p2-t5) ISPN000071: Caught exception when handling command DistributedExecuteCommand [cache=Cache 'default'@node1, keys=[], callable=org.infinispan.scripting.impl.DistributedScript@2b11e2b8]: org.infinispan.commons.CacheException: ISPN026003: Script execution error
      	at org.infinispan.scripting.impl.ScriptingManagerImpl.execute(ScriptingManagerImpl.java:206)
      	at org.infinispan.scripting.impl.DistributedScript.call(DistributedScript.java:30)
      	at org.infinispan.commands.read.DistributedExecuteCommand.perform(DistributedExecuteCommand.java:107)
      	at org.infinispan.remoting.inboundhandler.BasePerCacheInboundInvocationHandler.invokePerform(BasePerCacheInboundInvocationHandler.java:92)
      	at org.infinispan.remoting.inboundhandler.BaseBlockingRunnable.run(BaseBlockingRunnable.java:34)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: javax.script.ScriptException: ReferenceError: "k" is not defined in <eval> at line number 2
      	at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
      	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:423)
      	at jdk.nashorn.api.scripting.NashornScriptEngine.access$300(NashornScriptEngine.java:73)
      	at jdk.nashorn.api.scripting.NashornScriptEngine$3.eval(NashornScriptEngine.java:511)
      	at javax.script.CompiledScript.eval(CompiledScript.java:92)
      	at org.infinispan.scripting.impl.ScriptingManagerImpl.execute(ScriptingManagerImpl.java:198)
      	... 7 more
      Caused by: <eval>:2 ReferenceError: "k" is not defined
      	at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
      	at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319)
      	at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291)
      	at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1432)
      	at jdk.nashorn.internal.scripts.Script$\^eval\_.:program(<eval>:2)
      	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:640)
      	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:228)
      	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
      	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:418)
      	... 11 more
      

      By the way, the test is run on the cluster consisting of 3 nodes. The default cache is used, which is:

                      <distributed-cache name="default" mode="SYNC" segments="20" owners="2" remote-timeout="30000" start="EAGER">
                          <locking acquire-timeout="30000" concurrency-level="1000" striping="false"/>
                          <transaction mode="NONE"/>
                      </distributed-cache>
      

      As the "mode" attribute is set to "distributed" in the script, it should run on all nodes. But the exception is thrown only on 2 of them (I guess due to owners is set to 2) . Not sure if this is a bug, so decided to mention it here.

      Attachments

        Issue Links

          Activity

            People

              rh-ee-galder Galder ZamarreƱo
              amanukya@redhat.com Anna Manukyan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: