From ebac29d8a28e922d19112b4a1a8db5b2f7fb94e2 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Tue, 5 May 2015 20:17:36 +0200 Subject: [PATCH] Use buffered tanslog type also when sync is set to 0 When settings sync to 0, we benefit from using the buffered type, no need to change to simple, since we get a chance to fsync multiple operations (for that single operation) and not have to sync for the other ones before returning each one --- .../org/elasticsearch/index/translog/Translog.java | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/elasticsearch/index/translog/Translog.java b/src/main/java/org/elasticsearch/index/translog/Translog.java index 3bfc19a7893..1be4d0441c6 100644 --- a/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -152,10 +152,10 @@ public class Translog extends AbstractIndexShardComponent implements IndexShardC syncInterval = indexSettings.getAsTime(INDEX_TRANSLOG_SYNC_INTERVAL, TimeValue.timeValueSeconds(5)); if (syncInterval.millis() > 0 && threadPool != null) { - syncOnEachOperation(false); + this.syncOnEachOperation = false; syncScheduler = threadPool.schedule(syncInterval, ThreadPool.Names.SAME, new Sync()); } else if (syncInterval.millis() == 0) { - syncOnEachOperation(true); + this.syncOnEachOperation = true; } if (indexSettingsService != null) { @@ -507,15 +507,6 @@ public class Translog extends AbstractIndexShardComponent implements IndexShardC } } - public void syncOnEachOperation(boolean syncOnEachOperation) { - this.syncOnEachOperation = syncOnEachOperation; - if (syncOnEachOperation) { - type = TranslogFile.Type.SIMPLE; - } else { - type = TranslogFile.Type.BUFFERED; - } - } - /** package private for testing */ String getFilename(long translogId) { return TRANSLOG_FILE_PREFIX + translogId;