Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
ab95841
WIP
albertzaharovits Dec 11, 2024
890452c
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 12, 2024
0d4688b
OK
albertzaharovits Dec 12, 2024
d3a0e62
Some test
albertzaharovits Dec 12, 2024
98654c9
test method rename
albertzaharovits Dec 12, 2024
2ee0d86
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 16, 2024
6a7161c
polish negative IT
albertzaharovits Dec 16, 2024
dbc2d85
IT nits
albertzaharovits Dec 17, 2024
df44c5a
IT finally done
albertzaharovits Dec 19, 2024
c058226
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 19, 2024
e10d2fc
[CI] Auto commit changes from spotless
Dec 19, 2024
9370a6d
Fix tests compile
albertzaharovits Dec 19, 2024
d9ac566
DataStreamAutoshardingIT
albertzaharovits Dec 19, 2024
4b724a1
Fix NodeIndexingMetricsIT
albertzaharovits Dec 19, 2024
aef63c1
IndicesMetrics
albertzaharovits Dec 19, 2024
be37282
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 19, 2024
2e1a075
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 24, 2024
d8a449f
IndicesMetricsIT
albertzaharovits Dec 26, 2024
069b3b6
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 26, 2024
2fd846a
[CI] Auto commit changes from spotless
Dec 26, 2024
91d36d3
RestShardStats
albertzaharovits Dec 26, 2024
c208d14
RestShardsActionTests
albertzaharovits Dec 26, 2024
931d778
Fix test/cat.shards/10_basic.yml
albertzaharovits Dec 26, 2024
a432109
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 26, 2024
bb18ea8
[CI] Auto commit changes from spotless
Dec 26, 2024
0dc3671
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 27, 2024
c1ea675
Spotless
albertzaharovits Dec 27, 2024
8b479a5
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 29, 2024
aa4a283
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Dec 31, 2024
d8e23d2
RestIndicesAction RestNodesAction
albertzaharovits Jan 1, 2025
8ec3ad1
[CI] Auto commit changes from spotless
Jan 1, 2025
e4a658b
IndexShardTests
albertzaharovits Jan 1, 2025
4e1ba34
rename WithVersionConflict -> DueToVersionConflict
albertzaharovits Jan 1, 2025
5a35cec
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Jan 1, 2025
73ade62
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Jan 7, 2025
108645b
Nit
albertzaharovits Jan 7, 2025
b38a937
Separate metric (rather than attribute) for version_conflict indexing…
albertzaharovits Jan 7, 2025
c90e42b
[CI] Auto commit changes from spotless
Jan 7, 2025
2fbc503
Update docs/changelog/119067.yaml
albertzaharovits Jan 7, 2025
342101e
testIndexingErrorsDueToVersionConflict with successful indexing too
albertzaharovits Jan 7, 2025
407529c
Doc _cat actions
albertzaharovits Jan 7, 2025
3185769
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Jan 7, 2025
969cfc7
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Jan 8, 2025
d2c8793
Merge branch 'main' into index-metrics-version-conflicts
albertzaharovits Jan 8, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
IT finally done
  • Loading branch information
albertzaharovits committed Dec 19, 2024
commit df44c5a0fee4d3d6aa542326f2e6bfc65fde8abc
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,8 @@ public void testDoNotInfinitelyWaitForMapping() {
internalCluster().ensureAtLeastNumDataNodes(3);
createIndex(
"test",
indexSettings(1, 0).put("index.analysis.analyzer.test_analyzer.type", "custom")
indexSettings(1, 0)
.put("index.analysis.analyzer.test_analyzer.type", "custom")
.put("index.analysis.analyzer.test_analyzer.tokenizer", "standard")
.putList("index.analysis.analyzer.test_analyzer.filter", "test_token_filter")
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

package org.elasticsearch.monitor.metrics;

import org.apache.lucene.analysis.TokenStream;
import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
Expand All @@ -28,8 +29,14 @@
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexingPressure;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.index.engine.VersionConflictEngineException;
import org.elasticsearch.index.mapper.DocumentParsingException;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.indices.analysis.AnalysisModule;
import org.elasticsearch.indices.recovery.IndexRecoveryIT;
import org.elasticsearch.plugins.AnalysisPlugin;
import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.PluginsService;
import org.elasticsearch.rest.RestStatus;
Expand All @@ -48,6 +55,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;

import static java.util.Collections.singletonMap;
import static org.elasticsearch.index.IndexingPressure.MAX_COORDINATING_BYTES;
import static org.elasticsearch.index.IndexingPressure.MAX_PRIMARY_BYTES;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
Expand All @@ -74,7 +82,7 @@ public List<Setting<?>> getSettings() {

@Override
protected Collection<Class<? extends Plugin>> nodePlugins() {
return List.of(TestTelemetryPlugin.class, TestAPMInternalSettings.class);
return List.of(TestTelemetryPlugin.class, TestAPMInternalSettings.class, TestAnalysisPlugin.class);
}

@Override
Expand Down Expand Up @@ -183,19 +191,24 @@ public void testMetricsForIndexingVersionConflicts() {
.orElseThrow();
plugin.resetMeter();

if (randomBoolean()) {
assertAcked(prepareCreate("test").get());
} else {
assertAcked(prepareCreate("test", Settings.builder().put("index.refresh_interval", "-1")).get());
}
assertAcked(
prepareCreate(
"test",
Settings.builder()
.put("index.refresh_interval", "-1")
.put("index.analysis.analyzer.test_analyzer.type", "custom")
.put("index.analysis.analyzer.test_analyzer.tokenizer", "standard")
.putList("index.analysis.analyzer.test_analyzer.filter", "test_token_filter")
).setMapping(Map.of("properties", Map.of("test_field", Map.of("type", "text", "analyzer", "test_analyzer")))).get()
);

String docId = randomUUID();
// successful index (with version)
client(dataNode).index(
new IndexRequest("test").id(docId)
.version(10)
.versionType(randomFrom(VersionType.EXTERNAL, VersionType.EXTERNAL_GTE))
.source(Map.of("test_date", "2025/01/01"))
.source(Map.of())
).actionGet();
// if_primary_term conflict
{
Expand Down Expand Up @@ -231,28 +244,48 @@ public void testMetricsForIndexingVersionConflicts() {
assertThat(e.getMessage(), containsString("version conflict"));
assertThat(e.status(), is(RestStatus.CONFLICT));
}
// indexing failure that is NOT a version conflict (date parsing failure)
// indexing failure that is NOT a version conflict
PluginsService pluginService = internalCluster().getInstance(PluginsService.class, dataNode);
pluginService.filterPlugins(TestAnalysisPlugin.class).forEach(p -> p.throwParsingError.set(true));
{
var e = expectThrows(
DocumentParsingException.class,
() -> client(dataNode).index(
new IndexRequest("test").id(docId)
.source(Map.of())
// .source(Map.of("test_date", "foo"))
).actionGet());
MapperParsingException.class,
() -> client(dataNode).index(
new IndexRequest("test").id(docId + "other")
.source(Map.of("test_field", "this will error"))
).actionGet()
);
assertThat(e.status(), is(RestStatus.BAD_REQUEST));
}

plugin.collect();

List<Measurement> measurements = plugin.getLongAsyncCounterMeasurement("es.indexing.indexing.failed.total");
assertThat(measurements, iterableWithSize(2));
assertThat(measurements.get(0).value(), is(3L));
assertThat(measurements.get(0).value(), is(4L));
assertThat(measurements.get(0).attributes(), is(Map.of("es.indexing.indexing.failed.cause", "any")));
assertThat(measurements.get(1).value(), is(3L));
assertThat(measurements.get(1).attributes(), is(Map.of("es.indexing.indexing.failed.cause", "version_conflict")));
}


public static final class TestAnalysisPlugin extends Plugin implements AnalysisPlugin {
final AtomicBoolean throwParsingError = new AtomicBoolean(false);

@Override
public Map<String, AnalysisModule.AnalysisProvider<TokenFilterFactory>> getTokenFilters() {
return singletonMap("test_token_filter", (indexSettings, environment, name, settings) -> new AbstractTokenFilterFactory(name) {
@Override
public TokenStream create(TokenStream tokenStream) {
if (throwParsingError.get()) {
throw new MapperParsingException("simulate mapping parsing error");
}
return tokenStream;
}
});
}
}

public void testNodeIndexingMetricsArePublishing() {

final String dataNode = internalCluster().startNode();
Expand Down