Investigating the test failure reported in #45518 it appears that the datafeed task was not found during a tast state update. There are only two places where such an update is performed: when we set the state to `started` and when we set it to `stopping`. We handle `ResourceNotFoundException` in the latter but not in the former. Thus the test reveals a rare race condition where the datafeed gets requested to stop before we managed to update its state to `started`. I could not reproduce this scenario but it would be my best guess. This commit catches `ResourceNotFoundException` while updating the state to `started` and lets the task terminate smoothly. Closes #45518 Backport of #46495
This commit is contained in:
parent
e38e631dac
commit
579af626f5
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.datafeed;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.elasticsearch.ElasticsearchStatusException;
|
||||
import org.elasticsearch.ResourceNotFoundException;
|
||||
import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.cluster.ClusterChangedEvent;
|
||||
|
@ -95,7 +96,12 @@ public class DatafeedManager {
|
|||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
finishHandler.accept(e);
|
||||
if (e instanceof ResourceNotFoundException) {
|
||||
// The task was stopped in the meantime, no need to do anything
|
||||
logger.info("[{}] Aborting as datafeed has been stopped", datafeedId);
|
||||
} else {
|
||||
finishHandler.accept(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, finishHandler::accept
|
||||
|
|
Loading…
Reference in New Issue