|
@@ -188,18 +188,14 @@ public class IndexShard extends AbstractIndexShardComponent {
|
|
|
|
|
|
private final ShardEventListener shardEventListener = new ShardEventListener();
|
|
|
private volatile boolean flushOnClose = true;
|
|
|
- private volatile int flushThresholdOperations;
|
|
|
private volatile ByteSizeValue flushThresholdSize;
|
|
|
- private volatile boolean disableFlush;
|
|
|
|
|
|
/**
|
|
|
* Index setting to control if a flush is executed before engine is closed
|
|
|
* This setting is realtime updateable.
|
|
|
*/
|
|
|
public static final String INDEX_FLUSH_ON_CLOSE = "index.flush_on_close";
|
|
|
- public static final String INDEX_TRANSLOG_FLUSH_THRESHOLD_OPS = "index.translog.flush_threshold_ops";
|
|
|
public static final String INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE = "index.translog.flush_threshold_size";
|
|
|
- public static final String INDEX_TRANSLOG_DISABLE_FLUSH = "index.translog.disable_flush";
|
|
|
/** If we see no indexing operations after this much time for a given shard, we consider that shard inactive (default: 5 minutes). */
|
|
|
public static final String INDEX_SHARD_INACTIVE_TIME_SETTING = "index.shard.inactive_time";
|
|
|
private static final String INDICES_INACTIVE_TIME_SETTING = "indices.memory.shard_inactive_time";
|
|
@@ -270,9 +266,7 @@ public class IndexShard extends AbstractIndexShardComponent {
|
|
|
}
|
|
|
|
|
|
this.engineConfig = newEngineConfig(translogConfig, cachingPolicy);
|
|
|
- this.flushThresholdOperations = settings.getAsInt(INDEX_TRANSLOG_FLUSH_THRESHOLD_OPS, settings.getAsInt("index.translog.flush_threshold", Integer.MAX_VALUE));
|
|
|
this.flushThresholdSize = settings.getAsBytesSize(INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE, new ByteSizeValue(512, ByteSizeUnit.MB));
|
|
|
- this.disableFlush = settings.getAsBoolean(INDEX_TRANSLOG_DISABLE_FLUSH, false);
|
|
|
this.indexShardOperationCounter = new IndexShardOperationCounter(logger, shardId);
|
|
|
this.provider = provider;
|
|
|
this.searcherWrapper = indexSearcherWrapper;
|
|
@@ -1136,15 +1130,13 @@ public class IndexShard extends AbstractIndexShardComponent {
|
|
|
* Otherwise <code>false</code>.
|
|
|
*/
|
|
|
boolean shouldFlush() {
|
|
|
- if (disableFlush == false) {
|
|
|
- Engine engine = getEngineOrNull();
|
|
|
- if (engine != null) {
|
|
|
- try {
|
|
|
- Translog translog = engine.getTranslog();
|
|
|
- return translog.totalOperations() > flushThresholdOperations || translog.sizeInBytes() > flushThresholdSize.bytes();
|
|
|
- } catch (AlreadyClosedException | EngineClosedException ex) {
|
|
|
- // that's fine we are already close - no need to flush
|
|
|
- }
|
|
|
+ Engine engine = getEngineOrNull();
|
|
|
+ if (engine != null) {
|
|
|
+ try {
|
|
|
+ Translog translog = engine.getTranslog();
|
|
|
+ return translog.sizeInBytes() > flushThresholdSize.bytes();
|
|
|
+ } catch (AlreadyClosedException | EngineClosedException ex) {
|
|
|
+ // that's fine we are already close - no need to flush
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
@@ -1156,21 +1148,11 @@ public class IndexShard extends AbstractIndexShardComponent {
|
|
|
if (state() == IndexShardState.CLOSED) { // no need to update anything if we are closed
|
|
|
return;
|
|
|
}
|
|
|
- int flushThresholdOperations = settings.getAsInt(INDEX_TRANSLOG_FLUSH_THRESHOLD_OPS, this.flushThresholdOperations);
|
|
|
- if (flushThresholdOperations != this.flushThresholdOperations) {
|
|
|
- logger.info("updating flush_threshold_ops from [{}] to [{}]", this.flushThresholdOperations, flushThresholdOperations);
|
|
|
- this.flushThresholdOperations = flushThresholdOperations;
|
|
|
- }
|
|
|
ByteSizeValue flushThresholdSize = settings.getAsBytesSize(INDEX_TRANSLOG_FLUSH_THRESHOLD_SIZE, this.flushThresholdSize);
|
|
|
if (!flushThresholdSize.equals(this.flushThresholdSize)) {
|
|
|
logger.info("updating flush_threshold_size from [{}] to [{}]", this.flushThresholdSize, flushThresholdSize);
|
|
|
this.flushThresholdSize = flushThresholdSize;
|
|
|
}
|
|
|
- boolean disableFlush = settings.getAsBoolean(INDEX_TRANSLOG_DISABLE_FLUSH, this.disableFlush);
|
|
|
- if (disableFlush != this.disableFlush) {
|
|
|
- logger.info("updating disable_flush from [{}] to [{}]", this.disableFlush, disableFlush);
|
|
|
- this.disableFlush = disableFlush;
|
|
|
- }
|
|
|
|
|
|
final EngineConfig config = engineConfig;
|
|
|
final boolean flushOnClose = settings.getAsBoolean(INDEX_FLUSH_ON_CLOSE, this.flushOnClose);
|