Skip to content

Commit 75a8d66

Browse files
[ML] Fix bug in inference stats persister for when feature reset is called (#77252)
The test failure originates from an unhandled exception being thrown in the ml_utility threadpool. This exception was thrown by the results persister service, I found a place where the exception thrown was not ultimately handled. closes #77182 Co-authored-by: Elastic Machine <[email protected]>
1 parent 91616ba commit 75a8d66

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/TrainedModelStatsService.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.apache.logging.log4j.LogManager;
1010
import org.apache.logging.log4j.Logger;
1111
import org.apache.logging.log4j.message.ParameterizedMessage;
12+
import org.elasticsearch.ElasticsearchException;
1213
import org.elasticsearch.action.ActionListener;
1314
import org.elasticsearch.action.bulk.BulkRequest;
1415
import org.elasticsearch.action.support.IndicesOptions;
@@ -208,10 +209,15 @@ void updateStats() {
208209
if (shouldStop()) {
209210
return;
210211
}
211-
resultsPersisterService.bulkIndexWithRetry(bulkRequest,
212-
stats.stream().map(InferenceStats::getModelId).collect(Collectors.joining(",")),
213-
() -> shouldStop() == false,
214-
(msg) -> {});
212+
String jobPattern = stats.stream().map(InferenceStats::getModelId).collect(Collectors.joining(","));
213+
try {
214+
resultsPersisterService.bulkIndexWithRetry(bulkRequest,
215+
jobPattern,
216+
() -> shouldStop() == false,
217+
(msg) -> {});
218+
} catch (ElasticsearchException ex) {
219+
logger.warn(() -> new ParameterizedMessage("failed to store stats for [{}]", jobPattern), ex);
220+
}
215221
}
216222

217223
static boolean verifyIndicesExistAndPrimaryShardsAreActive(ClusterState clusterState, IndexNameExpressionResolver expressionResolver) {

0 commit comments

Comments
 (0)