Skip to content

Avoid warnings for non-system indexes using fast_refresh #124294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ private IndexMetadata buildIndexMetadataForMapperService(
.put(indexTemplateAndCreateRequestSettings)
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, dummyShards)
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, shardReplicas)
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID());
.put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
.put(IndexSettings.INDEX_FAST_REFRESH_SETTING.getKey(), false); // Avoid warnings for non-system indexes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a relative easy way to test the problem reported in the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a warning.. I tried to reproduce but it probably needs more than just the setting. @ywangd too for ideas.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The warning is for serverless deployments since fast_refresh was a feature for serverless only. In a serverless deployment, you can trigger this warning by just creating a related system index, e.g.

PUT .security-profile-8

In theory, the alternative fix can be removing the fast_refresh setting from all system indices since the setting is a noop today. But I am not sure whether that could still have other implications. Overall fixing it here feels safer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected, it's not just a warning - the provider doesn't work correctly when this trips. Not a real issue as system indexes are not in logsdb mode, but still easy to test.


if (templateIndexMode == IndexMode.TIME_SERIES) {
finalResolvedSettings.put(IndexSettings.MODE.getKey(), IndexMode.TIME_SERIES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,10 @@ public void testSortAndHostFieldSubobjectsFalse() throws Exception {
}

public void testSortAndHostNameObject() throws Exception {
var settings = Settings.builder().put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB).build();
var settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB)
.put(IndexSettings.INDEX_FAST_REFRESH_SETTING.getKey(), true)
.build();
var mappings = """
{
"_doc": {
Expand All @@ -1134,4 +1137,48 @@ public void testSortAndHostNameObject() throws Exception {
assertFalse(IndexSettings.LOGSDB_ADD_HOST_NAME_FIELD.get(result));
assertEquals(1, newMapperServiceCounter.get());
}

public void testSortFastRefresh() throws Exception {
var settings = Settings.builder()
.put(IndexSettings.MODE.getKey(), IndexMode.LOGSDB)
.put(IndexSettings.INDEX_FAST_REFRESH_SETTING.getKey(), true)
.build();
var mappings = """
{
"_doc": {
"properties": {
"@timestamp": {
"type": "date"
}
}
}
}
""";

String systemIndex = ".security-profile";
Metadata metadata = Metadata.EMPTY_METADATA;
var provider = new LogsdbIndexModeSettingsProvider(
logsdbLicenseService,
Settings.builder().put("cluster.logsdb.enabled", true).build()
);
provider.init(
im -> MapperTestUtils.newMapperService(xContentRegistry(), createTempDir(), im.getSettings(), im.getIndex().getName()),
IndexVersion::current,
() -> Version.CURRENT,
true,
true
);
var additionalIndexSettings = provider.getAdditionalIndexSettings(
DataStream.getDefaultBackingIndexName(systemIndex, 0),
systemIndex,
IndexMode.LOGSDB,
metadata.getProject(),
Instant.now(),
settings,
List.of(new CompressedXContent(mappings))
);

Settings result = builder().put(additionalIndexSettings).build();
assertTrue(IndexSettings.LOGSDB_SORT_ON_HOST_NAME.get(result));
}
}