mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-26 23:07:45 +00:00
[ML] Make open/close job timeouts consistent (elastic/x-pack-elasticsearch#1039)
Before this change the persistent task operations related to opening and closing jobs would time out a long time before the operations related to native processes. Original commit: elastic/x-pack-elasticsearch@23076b773b
This commit is contained in:
parent
1760677b0e
commit
d2c90e798f
@ -22,6 +22,7 @@ import org.elasticsearch.common.settings.Setting;
|
||||
import org.elasticsearch.common.settings.Setting.Property;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.settings.SettingsFilter;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.license.XPackLicenseState;
|
||||
@ -157,6 +158,8 @@ public class MachineLearning implements ActionPlugin {
|
||||
public static final Setting<Integer> CONCURRENT_JOB_ALLOCATIONS =
|
||||
Setting.intSetting("xpack.ml.node_concurrent_job_allocations", 2, 0, Property.Dynamic, Property.NodeScope);
|
||||
|
||||
public static final TimeValue STATE_PERSIST_RESTORE_TIMEOUT = TimeValue.timeValueMinutes(30);
|
||||
|
||||
private final Settings settings;
|
||||
private final Environment env;
|
||||
private final XPackLicenseState licenseState;
|
||||
|
@ -41,6 +41,7 @@ import org.elasticsearch.rest.RestStatus;
|
||||
import org.elasticsearch.tasks.Task;
|
||||
import org.elasticsearch.threadpool.ThreadPool;
|
||||
import org.elasticsearch.transport.TransportService;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.MlMetadata;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedConfig;
|
||||
import org.elasticsearch.xpack.ml.datafeed.DatafeedState;
|
||||
@ -112,7 +113,9 @@ public class CloseJobAction extends Action<CloseJobAction.Request, CloseJobActio
|
||||
|
||||
private String jobId;
|
||||
private boolean force = false;
|
||||
private TimeValue timeout = TimeValue.timeValueMinutes(20);
|
||||
// A big state can take a while to persist. For symmetry with the _open endpoint any
|
||||
// changes here should be reflected there too.
|
||||
private TimeValue timeout = MachineLearning.STATE_PERSIST_RESTORE_TIMEOUT;
|
||||
|
||||
String[] resolvedJobIds;
|
||||
|
||||
|
@ -112,7 +112,9 @@ public class OpenJobAction extends Action<OpenJobAction.Request, OpenJobAction.R
|
||||
|
||||
private String jobId;
|
||||
private boolean ignoreDowntime = true;
|
||||
private TimeValue timeout = TimeValue.timeValueSeconds(20);
|
||||
// A big state can take a while to restore. For symmetry with the _close endpoint any
|
||||
// changes here should be reflected there too.
|
||||
private TimeValue timeout = MachineLearning.STATE_PERSIST_RESTORE_TIMEOUT;
|
||||
|
||||
public Request(String jobId) {
|
||||
this.jobId = ExceptionsHelper.requireNonNull(jobId, Job.ID.getPreferredName());
|
||||
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.ml.job.process.autodetect;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.message.ParameterizedMessage;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.job.config.DetectionRule;
|
||||
import org.elasticsearch.xpack.ml.job.config.ModelPlotConfig;
|
||||
import org.elasticsearch.xpack.ml.job.process.autodetect.output.AutodetectResultsParser;
|
||||
@ -140,7 +141,7 @@ class NativeAutodetectProcess implements AutodetectProcess {
|
||||
// wait for the process to exit by waiting for end-of-file on the named pipe connected
|
||||
// to the state processor - it may take a long time for all the model state to be
|
||||
// indexed
|
||||
stateProcessorFuture.get(30, TimeUnit.MINUTES);
|
||||
stateProcessorFuture.get(MachineLearning.STATE_PERSIST_RESTORE_TIMEOUT.getMinutes(), TimeUnit.MINUTES);
|
||||
// the log processor should have stopped by now too - assume processing the logs will
|
||||
// take no more than 5 seconds longer than processing the state (usually it should
|
||||
// finish first)
|
||||
|
@ -11,6 +11,7 @@ import org.elasticsearch.action.ActionListener;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.logging.Loggers;
|
||||
import org.elasticsearch.index.IndexNotFoundException;
|
||||
import org.elasticsearch.xpack.ml.MachineLearning;
|
||||
import org.elasticsearch.xpack.ml.action.PutJobAction;
|
||||
import org.elasticsearch.xpack.ml.action.UpdateJobAction;
|
||||
import org.elasticsearch.xpack.ml.job.config.JobUpdate;
|
||||
@ -228,7 +229,7 @@ public class AutoDetectResultProcessor {
|
||||
try {
|
||||
// Although the results won't take 30 minutes to finish, the pipe won't be closed
|
||||
// until the state is persisted, and that can take a while
|
||||
if (completionLatch.await(30, TimeUnit.MINUTES) == false) {
|
||||
if (completionLatch.await(MachineLearning.STATE_PERSIST_RESTORE_TIMEOUT.getMinutes(), TimeUnit.MINUTES) == false) {
|
||||
throw new TimeoutException("Timed out waiting for results processor to complete for job " + jobId);
|
||||
}
|
||||
// Input stream has been completely processed at this point.
|
||||
|
Loading…
x
Reference in New Issue
Block a user