Skip to content

Commit

Permalink
Merge pull request #32426 from vespa-engine/hmusum/fix-warning
Browse files Browse the repository at this point in the history
Fix warning message for paged attributes and remote storage
  • Loading branch information
Harald Musum authored Sep 20, 2024
2 parents 1a7c2a7 + 2e20b08 commit 7788a32
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.yahoo.schema.document.ImmutableSDField;
import com.yahoo.vespa.model.application.validation.Validation.Context;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -45,9 +46,9 @@ public void validate(Context context) {
}

private static void validatePagedAttributes(DeployLogger logger, String clusterName, Schema schema) {
Set<Attribute> fields = schema.allFields()
List<Attribute> fields = schema.allFields()
.flatMap(field -> pagedAttributes(field).stream())
.collect(Collectors.toSet());
.collect(Collectors.toList());
if (fields.isEmpty()) return;

logger.logApplicationPackage(WARNING, ("Cluster '%s' has nodes with remote storage and fields with paged attributes." +
Expand All @@ -56,11 +57,13 @@ private static void validatePagedAttributes(DeployLogger logger, String clusterN
.formatted(clusterName, join(fields)));
}

private static String join(Set<Attribute> fields) {
return fields.stream()
private static String join(List<Attribute> fields) {
var ret = fields.stream()
.limit(10)
.map(Attribute::getName)
.map(s -> "'" + s + "'")
.collect(Collectors.joining("','"));
.collect(Collectors.joining(", "));
return ret + ((fields.size() > 10) ? ", ..." : "");
}

private static Set<Attribute> pagedAttributes(ImmutableSDField field) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation;

import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.config.model.NullConfigModelRegistry;
import com.yahoo.config.model.api.ApplicationClusterEndpoint;
Expand Down Expand Up @@ -43,6 +42,10 @@ void logs_warning_when_using_paged_attributes_and_remote_storage() throws IOExce
indexing: summary | attribute
attribute: paged
}
field name type string {
indexing: summary | attribute
attribute: paged
}
field rating type int {
indexing: summary | attribute
}
Expand All @@ -53,7 +56,7 @@ void logs_warning_when_using_paged_attributes_and_remote_storage() throws IOExce
assertTrue(logger.message.toString().contains(
"Cluster 'mycluster' has nodes with remote storage and fields with paged attributes." +
" This might lead to performance issues when doing I/O." +
" Consider using storage-type='local' or removing 'paged' setting for these fields: 'year'"));
" Consider using storage-type='local' or removing 'paged' setting for these fields: 'year', 'name'"));
}

private static class MyLogger implements DeployLogger {
Expand Down

0 comments on commit 7788a32

Please sign in to comment.