Skip to content

Commit

Permalink
Fork listener#onFailure in PrimaryReplicaSyncer (#70506)
Browse files Browse the repository at this point in the history
We assert that the snapshot isn't closed on a transport thread, but we
close it without forking off the transport thread in case of a failure.
With this commit we fork on failure too.

Relates #69949
Closes #70407
  • Loading branch information
DaveCTurner committed Mar 17, 2021
1 parent ac4ec2b commit 18bf4bc
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,24 @@ public void onResponse(ResyncReplicationResponse response) {
@Override
public void onFailure(Exception e) {
if (closed.compareAndSet(false, true)) {
listener.onFailure(e);
executor.execute(new AbstractRunnable() {
@Override
public void onFailure(Exception ex) {
e.addSuppressed(ex);

// We are on the generic threadpool so shouldn't be rejected, and listener#onFailure shouldn't throw anything,
// so getting here should be impossible.
assert false : e;

// Notify the listener on the current thread anyway, just in case.
listener.onFailure(e);
}

@Override
protected void doRun() {
listener.onFailure(e);
}
});
}
}

Expand Down

0 comments on commit 18bf4bc

Please sign in to comment.