Skip to content

Commit

Permalink
dcache-bulk: fix handling of uncaught exception during perform
Browse files Browse the repository at this point in the history
Backport for 9.0 and 9.1 of https://rb.dcache.org/r/14162/

Acked-by: Lea
  • Loading branch information
alrossi authored and mksahakyan committed Nov 17, 2023
1 parent f6cd9f5 commit d1dc7b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
Expand Up @@ -62,7 +62,6 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
import static org.dcache.services.bulk.activity.BulkActivity.MINIMALLY_REQUIRED_ATTRIBUTES;
import static org.dcache.services.bulk.util.BulkRequestTarget.State.CANCELLED;
import static org.dcache.services.bulk.util.BulkRequestTarget.State.COMPLETED;
import static org.dcache.services.bulk.util.BulkRequestTarget.State.FAILED;
import static org.dcache.services.bulk.util.BulkRequestTarget.State.READY;
import static org.dcache.services.bulk.util.BulkRequestTarget.State.SKIPPED;
import static org.dcache.services.bulk.util.BulkRequestTarget.computeFsPath;
Expand Down Expand Up @@ -342,7 +341,7 @@ public void uncaughtException(Thread t, Throwable e) {
*/
containerState = ContainerState.STOP;
target.setErrorObject(e);
update(FAILED);
update();
ThreadGroup group = t.getThreadGroup();
if (group != null) {
group.uncaughtException(t, e);
Expand All @@ -353,13 +352,7 @@ public void uncaughtException(Thread t, Throwable e) {

public void update(State state) {
if (target.setState(state)) {
try {
targetStore.update(target.getId(), target.getState(), target.getErrorType(),
target.getErrorMessage());
} catch (BulkStorageException e) {
LOGGER.error("{}, updateJobState: {}", ruid, e.toString());
}
signalStateChange();
update();
}
}

Expand Down Expand Up @@ -547,4 +540,14 @@ private synchronized void setRunThread(Thread runThread) {
this.runThread.setUncaughtExceptionHandler(this);
}
}

private void update() {
try {
targetStore.update(target.getId(), target.getState(), target.getErrorType(),
target.getErrorMessage());
signalStateChange();
} catch (BulkStorageException e) {
LOGGER.error("{}, updateJobState: {}", ruid, e.toString());
}
}
}
Expand Up @@ -256,6 +256,11 @@ private ListenableFuture perform(Long id, PID pid, FsPath path, FileAttributes a
future = Futures.immediateFailedFuture(e);
register(id, pid, path, future, attributes, e);
return future;
} catch (Throwable e) {
future = Futures.immediateFailedFuture(e);
register(id, pid, path, future, attributes, e);
uncaughtException(Thread.currentThread(), e);
return future;
}

register(id, pid, path, future, attributes, null);
Expand Down

0 comments on commit d1dc7b5

Please sign in to comment.