Skip to content

Commit

Permalink
Dynamic update of gc_delete setting for RobinEngine failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
bleskes committed Jul 30, 2013
1 parent f0caf6f commit ad818af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Expand Up @@ -1063,7 +1063,9 @@ public <T> T snapshot(SnapshotHandler<T> snapshotHandler) throws EngineException
snapshotIndexCommit = deletionPolicy.snapshot();
traslogSnapshot = translog.snapshot();
} catch (Exception e) {
if (snapshotIndexCommit != null) snapshotIndexCommit.release();
if (snapshotIndexCommit != null) {
snapshotIndexCommit.release();
}
throw new SnapshotFailedEngineException(shardId, e);
} finally {
rwl.readLock().unlock();
Expand Down Expand Up @@ -1368,7 +1370,7 @@ private IndexWriter createWriter() throws IOException {
class ApplySettings implements IndexSettingsService.Listener {
@Override
public void onRefreshSettings(Settings settings) {
long gcDeletesInMillis = indexSettings.getAsTime(INDEX_GC_DELETES, TimeValue.timeValueMillis(RobinEngine.this.gcDeletesInMillis)).millis();
long gcDeletesInMillis = settings.getAsTime(INDEX_GC_DELETES, TimeValue.timeValueMillis(RobinEngine.this.gcDeletesInMillis)).millis();
if (gcDeletesInMillis != RobinEngine.this.gcDeletesInMillis) {
logger.info("updating index.gc_deletes from [{}] to [{}]", TimeValue.timeValueMillis(RobinEngine.this.gcDeletesInMillis), TimeValue.timeValueMillis(gcDeletesInMillis));
RobinEngine.this.gcDeletesInMillis = gcDeletesInMillis;
Expand Down
Expand Up @@ -24,10 +24,11 @@
import org.elasticsearch.cluster.metadata.IndexMetaData;
import org.elasticsearch.common.Priority;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.test.integration.AbstractSharedClusterTest;
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertThrows;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.nullValue;

Expand Down Expand Up @@ -82,4 +83,21 @@ public void testOpenCloseUpdateSettings() throws Exception {
assertThat(indexMetaData.settings().get("index.refresh_interval"), equalTo("1s"));
assertThat(indexMetaData.settings().get("index.cache.filter.type"), equalTo("none"));
}

@Test
public void testRobinEngineGCDeletesSetting() throws InterruptedException {
createIndex("test");
client().prepareIndex("test", "type", "1").setSource("f", 1).get(); // set version to 1
client().prepareDelete("test", "type", "1").get(); // sets version to 2
client().prepareIndex("test", "type", "1").setSource("f", 2).setVersion(2).get(); // delete is still in cache this should work & set version to 3
client().admin().indices().prepareUpdateSettings("test")
.setSettings(ImmutableSettings.settingsBuilder()
.put("index.gc_deletes", 0)
).get();

client().prepareDelete("test", "type", "1").get(); // sets version to 4
Thread.sleep(300); // wait for cache time to change TODO: this needs to be solved better. To be discussed.
assertThrows(client().prepareIndex("test", "type", "1").setSource("f", 3).setVersion(4), VersionConflictEngineException.class); // delete is should not be in cache

}
}

0 comments on commit ad818af

Please sign in to comment.