Skip to content

Commit 18bf4bc

Browse files
committed
Fork listener#onFailure in PrimaryReplicaSyncer (#70506)
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
1 parent ac4ec2b commit 18bf4bc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

server/src/main/java/org/elasticsearch/index/shard/PrimaryReplicaSyncer.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,24 @@ public void onResponse(ResyncReplicationResponse response) {
224224
@Override
225225
public void onFailure(Exception e) {
226226
if (closed.compareAndSet(false, true)) {
227-
listener.onFailure(e);
227+
executor.execute(new AbstractRunnable() {
228+
@Override
229+
public void onFailure(Exception ex) {
230+
e.addSuppressed(ex);
231+
232+
// We are on the generic threadpool so shouldn't be rejected, and listener#onFailure shouldn't throw anything,
233+
// so getting here should be impossible.
234+
assert false : e;
235+
236+
// Notify the listener on the current thread anyway, just in case.
237+
listener.onFailure(e);
238+
}
239+
240+
@Override
241+
protected void doRun() {
242+
listener.onFailure(e);
243+
}
244+
});
228245
}
229246
}
230247

0 commit comments

Comments
 (0)