[
https://issues.apache.org/jira/browse/NIFI-8461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17349069#comment-17349069
]
KevinSky commented on NIFI-8461:
--------------------------------
NIFI-8080caused this, in sigle thread,if it is not first in,compiledScriptRef
save the first time compiled value,and when executeScript restart, it only
clear
ScriptingComponentHelper.engineQ,but scriptEngineConfiguratorMap also has the
reference of compiledScriptRef. so that is why we see stuck in connections.
in multi thread, compiledScriptRef only save first engine compiled
CompiledScript. eval() method don't use the true engine to eval,so it always
throw exception like
is already marked for transfer in
or
is not known in this session
!image-2021-05-21-16-02-22-044.png|width=993,height=266!
It's hard and unless to binding compiledScriptRef to each engine in
scriptingComponentHelper.engineQ, We must always bind bindings to engine
without just complie it,so those code modification might be use:
{code:java}
public class JythonScriptEngineConfigurator implements ScriptEngineConfigurator
{
private String prefix = null;
@Override
public String getScriptEngineName() {
return "python";
}
@Override
public URL[] getModuleURLsForClasspath(String[] modulePaths, ComponentLog
log) {
// We don't need to add the module paths to the classpath, they will be
added via sys.path.append
return new URL[0];
}
@Override
public Object init(ScriptEngine engine, String scriptBody, String[]
modulePaths) throws ScriptException {
// Always compile when first run
if (engine != null) {
// Add prefix for import sys and all jython modules
prefix = "import sys\n"
+ Arrays.stream(modulePaths).map((modulePath) ->
"sys.path.append(" + PyString.encode_UnicodeEscape(modulePath, true) + ")")
.collect(Collectors.joining("\n"));
}
return null;
}
@Override
public Object eval(ScriptEngine engine, String scriptBody, String[]
modulePaths) throws ScriptException {
Object returnValue = null;
if (engine != null) {
returnValue = ((Compilable) engine).compile(prefix +
scriptBody).eval();
}
return returnValue;
}
}
{code}
> Queue reports items but cannot list them
> ----------------------------------------
>
> Key: NIFI-8461
> URL: https://issues.apache.org/jira/browse/NIFI-8461
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework
> Affects Versions: 1.13.2
> Environment: Docker image apache/nifi :1.13.2, Windows 10 Pro, WSL 2
> (Ubuntu), x86_64
> Reporter: Kevin Aagaard
> Assignee: Matt Burgess
> Priority: Major
> Labels: queue
> Attachments: ExecuteScript_Queue_Issue.txt, NIFI-8461.zip,
> image-2021-04-22-08-48-58-117.png, image-2021-04-22-08-49-40-904.png,
> image-2021-04-27-14-23-07-849.png, image-2021-04-27-14-23-24-477.png,
> image-2021-05-21-16-02-22-044.png
>
>
> The following segment of workflow demonstrates the issue. The queue reports
> that there are items within it, but they cannot be listed, even after
> stopping the consumer (and producer). Since this is in a Docker Container, it
> is unlikely an OS error.
>
> !image-2021-04-22-08-48-58-117.png!
>
> !image-2021-04-22-08-49-40-904.png!
> I do not currently have a simplified example workflow to recreate the error,
> but can work on it.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)