log WARN for onScriptExecutionError to prevent silent ban (actually, system going to idle if the script is a part of a rule chain). restored TRACE level on fetchAndProcessResponses

This commit is contained in:
Sergey Matvienko 2021-05-11 08:01:21 +03:00
parent c3aec4d077
commit 3c72d0d608
2 changed files with 12 additions and 11 deletions

View File

@ -121,13 +121,16 @@ public abstract class AbstractJsInvokeService implements JsInvokeService {
protected abstract long getMaxBlacklistDuration();
protected void onScriptExecutionError(UUID scriptId, Throwable t) {
if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) {
log.warn("Script has TimeoutException and will increment counter {} on disabledFunctions for id {}", //TODO remove after test
disabledFunctions.computeIfAbsent(scriptId, key -> new DisableListInfo()).get(),
scriptId);
//return; //timeout is not a good reason to disable function
}
disabledFunctions.computeIfAbsent(scriptId, key -> new DisableListInfo()).incrementAndGet();
DisableListInfo disableListInfo = disabledFunctions.computeIfAbsent(scriptId, key -> new DisableListInfo());
log.warn("Script has exception and will increment counter {} on disabledFunctions for id {}, exception {}, cause {}",
disableListInfo.get(), scriptId, t.getClass(), t.getCause());
// if (t instanceof TimeoutException || (t.getCause() != null && t.getCause() instanceof TimeoutException)) {
// log.warn("Script has TimeoutException and will increment counter {} on disabledFunctions for id {}", //TODO remove after test
// disableListInfo.get(),
// scriptId);
// //return; //timeout is not a good reason to disable function
// }
disableListInfo.incrementAndGet();
}
private String generateJsScript(JsScriptType scriptType, String functionName, String scriptBody, String... argNames) {

View File

@ -109,11 +109,9 @@ public class DefaultTbQueueRequestTemplate<Request extends TbQueueMsg, Response
void fetchAndProcessResponses() {
final long pendingRequestsCount = pendingRequests.mappingCount();
log.info("Starting template pool topic {}, for pendingRequests {}", responseTemplate.getTopic(), pendingRequestsCount);
log.trace("Starting template pool topic {}, for pendingRequests {}", responseTemplate.getTopic(), pendingRequestsCount);
List<Response> responses = doPoll(); //poll js responses
//if (responses.size() > 0) {
log.info("Completed template poll topic {}, for pendingRequests [{}], received [{}]", responseTemplate.getTopic(), pendingRequestsCount, responses.size()); //TODO reduce verbose after test
//}
log.trace("Completed template poll topic {}, for pendingRequests [{}], received [{}] responses", responseTemplate.getTopic(), pendingRequestsCount, responses.size());
responses.forEach(this::processResponse); //this can take a long time
responseTemplate.commit();
tryCleanStaleRequests();