Skip to content

Commit

Permalink
Change default indexing primary limit in stateless
Browse files Browse the repository at this point in the history
In stateless we would like to have the primary limit be greater than the
coordinating limit to push forward with indexing data that has already
been received.
  • Loading branch information
Tim-Brooks committed Oct 2, 2024
1 parent 6759ae2 commit c7e5bd6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class IndexingPressure {

public static final Setting<ByteSizeValue> MAX_PRIMARY_BYTES = Setting.memorySizeSetting(
"indexing_pressure.memory.primary.limit",
MAX_INDEXING_BYTES,
s -> DiscoveryNode.isStateless(s) ? "15%" : MAX_INDEXING_BYTES.get(s).getStringRep(),
Setting.Property.NodeScope
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

package org.elasticsearch.index;

import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException;
import org.elasticsearch.core.Releasable;
import org.elasticsearch.index.stats.IndexingPressureStats;
import org.elasticsearch.test.ESTestCase;
import org.hamcrest.Matchers;

import static org.hamcrest.Matchers.equalTo;

public class IndexingPressureTests extends ESTestCase {

Expand All @@ -32,9 +34,27 @@ public class IndexingPressureTests extends ESTestCase {
public void testMemoryLimitSettingsFallbackToOldSingleLimitSetting() {
Settings settings = Settings.builder().put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "20KB").build();

assertThat(IndexingPressure.MAX_COORDINATING_BYTES.get(settings), Matchers.equalTo(ByteSizeValue.ofKb(20)));
assertThat(IndexingPressure.MAX_PRIMARY_BYTES.get(settings), Matchers.equalTo(ByteSizeValue.ofKb(20)));
assertThat(IndexingPressure.MAX_REPLICA_BYTES.get(settings), Matchers.equalTo(ByteSizeValue.ofKb(30)));
assertThat(IndexingPressure.MAX_COORDINATING_BYTES.get(settings), equalTo(ByteSizeValue.ofKb(20)));
assertThat(IndexingPressure.MAX_PRIMARY_BYTES.get(settings), equalTo(ByteSizeValue.ofKb(20)));
assertThat(IndexingPressure.MAX_REPLICA_BYTES.get(settings), equalTo(ByteSizeValue.ofKb(30)));
}

public void testPrimaryMemoryLimitSettingsDefaultForStateless() {
Settings settingsDefault = Settings.builder()
.put(DiscoveryNode.STATELESS_ENABLED_SETTING_NAME, true)
.build();

assertThat(IndexingPressure.MAX_COORDINATING_BYTES.getDefaultRaw(settingsDefault), equalTo("10%"));
assertThat(IndexingPressure.MAX_PRIMARY_BYTES.getDefaultRaw(settingsDefault), equalTo("15%"));

Settings settings = Settings.builder()
.put(IndexingPressure.MAX_INDEXING_BYTES.getKey(), "20KB")
.put(DiscoveryNode.STATELESS_ENABLED_SETTING_NAME, true)
.build();

assertThat(IndexingPressure.MAX_COORDINATING_BYTES.get(settings), equalTo(ByteSizeValue.ofKb(20)));
// Still defaults to 15% as it is not derived from the MAX_INDEXING_BYTES
assertThat(IndexingPressure.MAX_PRIMARY_BYTES.getDefaultRaw(settings), equalTo("15%"));
}

public void testHighAndLowWatermarkSettings() {
Expand Down

0 comments on commit c7e5bd6

Please sign in to comment.