Skip to content

Commit

Permalink
Change index setting from read_only_allow_delete to write (#311)
Browse files Browse the repository at this point in the history
read_only_allow_delete does not block write to an index.
The disk-based shard allocator may add and remove this block automatically.
Therefore, use index.blocks.write instead.

Signed-off-by: Heemin Kim <[email protected]>
  • Loading branch information
heemin32 authored May 17, 2023
1 parent ca86afd commit 0d65260
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ public class GeoIpDataFacade {
private static final Tuple<String, Integer> INDEX_SETTING_REFRESH_INTERVAL = new Tuple<>("index.refresh_interval", -1);
private static final Tuple<String, String> INDEX_SETTING_AUTO_EXPAND_REPLICAS = new Tuple<>("index.auto_expand_replicas", "0-all");
private static final Tuple<String, Boolean> INDEX_SETTING_HIDDEN = new Tuple<>("index.hidden", true);
private static final Tuple<String, Boolean> INDEX_SETTING_READ_ONLY_ALLOW_DELETE = new Tuple<>(
"index.blocks.read_only_allow_delete",
true
);
private static final Tuple<String, Boolean> INDEX_SETTING_BLOCKS_WRITE = new Tuple<>("index.blocks.write", true);
private final ClusterService clusterService;
private final ClusterSettings clusterSettings;
private final Client client;
Expand Down Expand Up @@ -116,8 +113,7 @@ private void freezeIndex(final String indexName) {
client.admin().indices().prepareRefresh(indexName).execute().actionGet(timeout);
client.admin().indices().prepareForceMerge(indexName).setMaxNumSegments(1).execute().actionGet(timeout);
Map<String, Object> settings = new HashMap<>();
settings.put(INDEX_SETTING_READ_ONLY_ALLOW_DELETE.v1(), INDEX_SETTING_READ_ONLY_ALLOW_DELETE.v2());
settings.put(INDEX_SETTING_NUM_OF_REPLICAS.v1(), null);
settings.put(INDEX_SETTING_BLOCKS_WRITE.v1(), INDEX_SETTING_BLOCKS_WRITE.v2());
settings.put(INDEX_SETTING_AUTO_EXPAND_REPLICAS.v1(), INDEX_SETTING_AUTO_EXPAND_REPLICAS.v2());
client.admin()
.indices()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public void testPutGeoIpData_whenValidInput_thenSucceed() {
UpdateSettingsRequest request = (UpdateSettingsRequest) actionRequest;
assertEquals(1, request.indices().length);
assertEquals(index, request.indices()[0]);
assertEquals(true, request.settings().getAsBoolean("index.blocks.read_only_allow_delete", false));
assertEquals(true, request.settings().getAsBoolean("index.blocks.write", false));
assertNull(request.settings().get("index.num_of_replica"));
assertEquals("0-all", request.settings().get("index.auto_expand_replicas"));
return null;
Expand Down

0 comments on commit 0d65260

Please sign in to comment.