[
https://issues.apache.org/jira/browse/NIFI-8461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17343648#comment-17343648
]
KevinSky edited comment on NIFI-8461 at 5/13/21, 1:16 AM:
----------------------------------------------------------
hi Mark Payne, and [#Matt Burgess],I found ExecuteScript::onTrigger():
{code:java}
configurator.init(scriptEngine, scriptToRun,
scriptingComponentHelper.getModules());
{code}
JythonScriptEngineConfigurator::init()
{code:java}
@Override
public Object init(ScriptEngine engine, String scriptBody, String[]
modulePaths) throws ScriptException {
// Always compile when first run
if (engine != null && compiledScriptRef.get() == null) {
// Add prefix for import sys and all jython modules
String prefix = "import sys\n"
+ Arrays.stream(modulePaths).map((modulePath) ->
"sys.path.append(" + PyString.encode_UnicodeEscape(modulePath, true) + ")")
.collect(Collectors.joining("\n"));
final CompiledScript compiled = ((Compilable)
engine).compile(prefix + scriptBody);
compiledScriptRef.set(compiled);
}
return compiledScriptRef.get();
}
{code}
compiledScriptRef.get() is always not null after executeScript processor
restart. So I infer whether it is because the compilation is not restarted
after the stop, which causes the session stored in the bindings in the
executesScript to be the previous one, so the flowfile is not correctly set to
ack status.
I found this compiledScriptRef is store in
scriptingComponentHelper.scriptEngineConfiguratorMap,but executeScript
processor stop,it only clear the scriptingComponentHelper.engineQ,but
scriptingComponentHelper.scriptEngineConfiguratorMap also has the reference.so
I just modify the scriptingComponentHelper::stop()
{code:java}
public void stop() {
if (engineQ != null) {
engineQ.clear();
}
if (!scriptEngineConfiguratorMap.isEmpty()){
scriptEngineConfiguratorMap.clear();
}
}
{code}
It works,but i found invokeScriptedProcessor also use
scriptingComponentHelper::stop(),I don't know this modification is suitable for
this processor.
was (Author: kevinsky1093):
hi Mark Payne, and [#Matt Burgess],I found ExecuteScript::onTrigger():
{code:java}
// configurator.init(scriptEngine, scriptToRun,
scriptingComponentHelper.getModules());
{code}
JythonScriptEngineConfigurator::init()
{code:java}
//@Override
public Object init(ScriptEngine engine, String scriptBody, String[]
modulePaths) throws ScriptException {
// Always compile when first run
if (engine != null && compiledScriptRef.get() == null) {
// Add prefix for import sys and all jython modules
String prefix = "import sys\n"
+ Arrays.stream(modulePaths).map((modulePath) ->
"sys.path.append(" + PyString.encode_UnicodeEscape(modulePath, true) + ")")
.collect(Collectors.joining("\n"));
final CompiledScript compiled = ((Compilable)
engine).compile(prefix + scriptBody);
compiledScriptRef.set(compiled);
}
return compiledScriptRef.get();
}
{code}
compiledScriptRef.get() is always not null after executeScript processor
restart. So I infer whether it is because the compilation is not restarted
after the stop, which causes the session stored in the bindings in the
executesScript to be the previous one, so the flowfile is not correctly set to
ack status.
I found this compiledScriptRef is store in
scriptingComponentHelper.scriptEngineConfiguratorMap,but executeScript
processor stop,it only clear the scriptingComponentHelper.engineQ,but
scriptingComponentHelper.scriptEngineConfiguratorMap also has the reference.so
I just modify the scriptingComponentHelper::stop()
{code:java}
// public void stop() {
if (engineQ != null) {
engineQ.clear();
}
if (!scriptEngineConfiguratorMap.isEmpty()){
scriptEngineConfiguratorMap.clear();
}
}
{code}
It works,but i found invokeScriptedProcessor also use
scriptingComponentHelper::stop(),I don't know this modification is suitable for
this processor.
> 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
>
>
> 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)