thomasmueller commented on code in PR #2626:
URL: https://github.com/apache/jackrabbit-oak/pull/2626#discussion_r2773972299
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java:
##########
@@ -1285,6 +1285,37 @@ public void verifyNotPotentiallySlow() {
}
}
}
+
+ private String createTraversalWarningMessage(Traversal traversal) {
+ String caller =
IndexUtils.getCaller(settings.getIgnoredClassNamesInCallTrace());
+ String message = "Traversal query (query without index): " + statement
+ "; called by " + caller + "; consider creating an index";
+ if (traversal == Traversal.FAIL || traversal == Traversal.WARN &&
!potentiallySlowTraversalQueryLogged) {
+ Set<String> reindex = getNamesOfReindexingIndexes();
+ message += "\n\nExecution plan:\n" + getPlan();
+ if (!reindex.isEmpty()) {
+ String reindexNames = reindex.stream().map(name -> name +
",").collect(Collectors.joining());
+ message += "\n\nNote that the following indexes were
unavailable because of re-indexing:\n"
+ + reindexNames.substring(0, reindexNames.length() - 1);
+ }
Review Comment:
Even if the indexes are reindexing currently, I think the old version can
still be used for queries (no?)
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java:
##########
@@ -1285,6 +1285,37 @@ public void verifyNotPotentiallySlow() {
}
}
}
+
+ private String createTraversalWarningMessage(Traversal traversal) {
+ String caller =
IndexUtils.getCaller(settings.getIgnoredClassNamesInCallTrace());
+ String message = "Traversal query (query without index): " + statement
+ "; called by " + caller + "; consider creating an index";
+ if (traversal == Traversal.FAIL || traversal == Traversal.WARN &&
!potentiallySlowTraversalQueryLogged) {
+ Set<String> reindex = getNamesOfReindexingIndexes();
+ message += "\n\nExecution plan:\n" + getPlan();
+ if (!reindex.isEmpty()) {
+ String reindexNames = reindex.stream().map(name -> name +
",").collect(Collectors.joining());
+ message += "\n\nNote that the following indexes were
unavailable because of re-indexing:\n"
+ + reindexNames.substring(0, reindexNames.length() - 1);
+ }
Review Comment:
So I probably would not add this here... instead, I think we should probably
add a metric for "indexes that are currently reindexing", which should in
theory be zero. And if there are indexes that are indexing, specially if that's
for longer than eg. 1 hour, then we should investigate that.
##########
oak-core/src/main/java/org/apache/jackrabbit/oak/query/QueryImpl.java:
##########
@@ -1285,6 +1285,37 @@ public void verifyNotPotentiallySlow() {
}
}
}
+
+ private String createTraversalWarningMessage(Traversal traversal) {
+ String caller =
IndexUtils.getCaller(settings.getIgnoredClassNamesInCallTrace());
+ String message = "Traversal query (query without index): " + statement
+ "; called by " + caller + "; consider creating an index";
+ if (traversal == Traversal.FAIL || traversal == Traversal.WARN &&
!potentiallySlowTraversalQueryLogged) {
+ Set<String> reindex = getNamesOfReindexingIndexes();
+ message += "\n\nExecution plan:\n" + getPlan();
+ if (!reindex.isEmpty()) {
+ String reindexNames = reindex.stream().map(name -> name +
",").collect(Collectors.joining());
+ message += "\n\nNote that the following indexes were
unavailable because of re-indexing:\n"
+ + reindexNames.substring(0, reindexNames.length() - 1);
+ }
+ }
+ return message;
+ }
+
+ private Set<String> getNamesOfReindexingIndexes() {
+ Set<String> reindex = new HashSet<>();
+ Iterable<Tree> indexes = context.getRoot().getTree("/" +
INDEX_DEFINITIONS_NAME).getChildren();
+ for (Tree index : indexes) {
+ String name = index.getName();
+ PropertyState primaryType = index.getProperty(JCR_PRIMARYTYPE);
+ if (primaryType != null &&
INDEX_DEFINITIONS_NODE_TYPE.equals(primaryType.getValue(Type.STRING))) {
+ PropertyState reindexProp =
index.getProperty(REINDEX_PROPERTY_NAME);
+ if (reindexProp != null && reindexProp.getValue(Type.BOOLEAN))
{
+ reindex.add(name);
+ }
Review Comment:
I saw some cases where an index had reindex = true, but type = disabled...
So that would need to be ignored.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]