Murtadha Hubail has submitted this change and it was merged. Change subject: [ASTERIXDB-1961][IDX] Prevent NPE in cursor during cancellation ......................................................................
[ASTERIXDB-1961][IDX] Prevent NPE in cursor during cancellation - user model changes: no - interface changes: no - storage format changes: no Details: - Prevent NPE in cursor when an interruption happens during cursors initialization. - Keep track of interruption stack trace to help in diagnosing future similar issues. Change-Id: I6937d14bc79d6583bb62c1d7b726ab0f26a59d79 Reviewed-on: https://asterix-gerrit.ics.uci.edu/1856 Reviewed-by: abdullah alamoudi <bamou...@gmail.com> Tested-by: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Integration-Tests: Jenkins <jenk...@fulliautomatix.ics.uci.edu> BAD: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Reviewed-by: Yingyi Bu <buyin...@gmail.com> --- M hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/Task.java M hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java 2 files changed, 23 insertions(+), 4 deletions(-) Approvals: abdullah alamoudi: Looks good to me, approved Yingyi Bu: Looks good to me, approved Jenkins: Verified; No violations found; Verified Objections: Jenkins: Violations found diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/Task.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/Task.java index d689bc0..ad4881a 100644 --- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/Task.java +++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-nc/src/main/java/org/apache/hyracks/control/nc/Task.java @@ -280,6 +280,7 @@ } ct.setName(displayName + ":" + taskAttemptId + ":" + 0); try { + Exception operatorException = null; try { operator.initialize(); if (collectors.length > 0) { @@ -318,8 +319,22 @@ sem.acquire(collectors.length - 1); } } + } catch (Exception e) { + // Store the operator exception + operatorException = e; + throw e; } finally { - operator.deinitialize(); + try { + operator.deinitialize(); + } catch (Exception e) { + if (operatorException != null) { + // Add deinitialize exception to the operator exception to keep track of both + operatorException.addSuppressed(e); + } else { + operatorException = e; + } + throw operatorException; + } } NodeControllerService ncs = joblet.getNodeController(); ncs.getWorkQueue().schedule(new NotifyTaskCompleteWork(ncs, this)); diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java index f99a859..724a909 100644 --- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java +++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/impls/LSMIndexSearchCursor.java @@ -137,10 +137,14 @@ if (outputPriorityQueue != null) { outputPriorityQueue.clear(); } - for (int i = 0; i < rangeCursors.length; i++) { - rangeCursors[i].close(); + if (rangeCursors != null) { + for (int i = 0; i < rangeCursors.length; i++) { + if (rangeCursors[i] != null) { + rangeCursors[i].close(); + } + } + rangeCursors = null; } - rangeCursors = null; } finally { if (lsmHarness != null) { lsmHarness.endSearch(opCtx); -- To view, visit https://asterix-gerrit.ics.uci.edu/1856 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I6937d14bc79d6583bb62c1d7b726ab0f26a59d79 Gerrit-PatchSet: 2 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Murtadha Hubail <hubail...@gmail.com> Gerrit-Reviewer: Dmitry Lychagin <dmitry.lycha...@couchbase.com> Gerrit-Reviewer: Jenkins <jenk...@fulliautomatix.ics.uci.edu> Gerrit-Reviewer: Murtadha Hubail <hubail...@gmail.com> Gerrit-Reviewer: Till Westmann <ti...@apache.org> Gerrit-Reviewer: Yingyi Bu <buyin...@gmail.com> Gerrit-Reviewer: abdullah alamoudi <bamou...@gmail.com>