You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by th...@apache.org on 2024/08/16 13:37:41 UTC
(jackrabbit-oak) branch OAK-11025-b created (now 7a884dff45)
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a change to branch OAK-11025-b
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
at 7a884dff45 OAK-11025 Silence more warnings for ordered properties
This branch includes the following new commits:
new 7a884dff45 OAK-11025 Silence more warnings for ordered properties
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(jackrabbit-oak) 01/01: OAK-11025 Silence more warnings for ordered properties
Posted by th...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
thomasm pushed a commit to branch OAK-11025-b
in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 7a884dff45d2bea13885a595f8b7043442009986
Author: Thomas Mueller <th...@apache.org>
AuthorDate: Fri Aug 16 15:37:24 2024 +0200
OAK-11025 Silence more warnings for ordered properties
---
oak-commons/pom.xml | 1 +
.../jackrabbit/oak/commons/log}/LogSilencer.java | 2 +-
.../jackrabbit/oak/commons/log/package-info.java | 26 +++++++++++
.../oak/commons/log}/LogSilencerTest.java | 2 +-
.../plugins/index/lucene/LuceneDocumentMaker.java | 52 ++++++++++++++++------
.../oak/plugins/document/NodeDocument.java | 38 ++++++++--------
.../oak/plugins/document/SplitDocumentCleanUp.java | 13 +++---
7 files changed, 92 insertions(+), 42 deletions(-)
diff --git a/oak-commons/pom.xml b/oak-commons/pom.xml
index e0b1cbc186..14d3e8e929 100644
--- a/oak-commons/pom.xml
+++ b/oak-commons/pom.xml
@@ -51,6 +51,7 @@
org.apache.jackrabbit.oak.commons.concurrent,
org.apache.jackrabbit.oak.commons.io,
org.apache.jackrabbit.oak.commons.json,
+ org.apache.jackrabbit.oak.commons.log,
org.apache.jackrabbit.oak.commons.sort,
org.apache.jackrabbit.oak.commons.properties
</Export-Package>
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencer.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/log/LogSilencer.java
similarity index 98%
rename from oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencer.java
rename to oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/log/LogSilencer.java
index d05d9e12ab..4ed3f3b543 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencer.java
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/log/LogSilencer.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.document.util;
+package org.apache.jackrabbit.oak.commons.log;
import java.time.Duration;
import java.util.Collections;
diff --git a/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/log/package-info.java b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/log/package-info.java
new file mode 100644
index 0000000000..4da92d131a
--- /dev/null
+++ b/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/log/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * <em>For Oak internal use only. Do not use outside Oak components.</em>
+ */
+@Internal(since = "1.0.0")
+@Version("1.0.0")
+package org.apache.jackrabbit.oak.commons.log;
+
+import org.osgi.annotation.versioning.Version;
+import org.apache.jackrabbit.oak.commons.annotations.Internal;
+
diff --git a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencerTest.java b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/log/LogSilencerTest.java
similarity index 98%
rename from oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencerTest.java
rename to oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/log/LogSilencerTest.java
index 4502031511..0caa3693c3 100644
--- a/oak-store-document/src/test/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencerTest.java
+++ b/oak-commons/src/test/java/org/apache/jackrabbit/oak/commons/log/LogSilencerTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.jackrabbit.oak.plugins.document.util;
+package org.apache.jackrabbit.oak.commons.log;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
diff --git a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneDocumentMaker.java b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneDocumentMaker.java
index 2be705154e..505efa27ce 100644
--- a/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneDocumentMaker.java
+++ b/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneDocumentMaker.java
@@ -21,6 +21,7 @@ package org.apache.jackrabbit.oak.plugins.index.lucene;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -29,6 +30,7 @@ import org.apache.jackrabbit.oak.api.Blob;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.commons.PathUtils;
+import org.apache.jackrabbit.oak.commons.log.LogSilencer;
import org.apache.jackrabbit.oak.plugins.index.lucene.util.FacetsConfigProvider;
import org.apache.jackrabbit.oak.plugins.index.search.Aggregate;
import org.apache.jackrabbit.oak.plugins.index.search.FieldNames;
@@ -60,14 +62,14 @@ public class LuceneDocumentMaker extends FulltextDocumentMaker<Document> {
private static final String DYNAMIC_BOOST_SPLIT_REGEX = "[:/]";
- // warn once every 10 seconds at most
- private static final long DUPLICATE_WARNING_INTERVAL_MS = 10 * 1000;
-
private final FacetsConfigProvider facetsConfigProvider;
private final IndexAugmentorFactory augmentorFactory;
- // when did we warn (static, as we construct new objects quite often)
- private static long lastDuplicateWarning;
+ private static final LogSilencer LOG_SILENCER = new LogSilencer(Duration.ofSeconds(10).toMillis(), 10);
+ private static final String LOG_KEY_DUPLICATE = "Duplicate value";
+ private static final String LOG_KEY_NOT_A_DATE_STRING = "Not a date string";
+ private static final String LOG_KEY_UNABLE_TO_PARSE = "Unable to parse the provided date field";
+ private static final String LOG_KEY_FOR_INPUT_STRING = "For input string";
public LuceneDocumentMaker(IndexDefinition definition,
IndexDefinition.IndexingRule indexingRule,
@@ -299,19 +301,43 @@ public class LuceneDocumentMaker extends FulltextDocumentMaker<Document> {
doc.add(f);
fieldAdded = true;
} else {
- long now = System.currentTimeMillis();
- if (now > lastDuplicateWarning + DUPLICATE_WARNING_INTERVAL_MS) {
+ if (!LOG_SILENCER.silence(LOG_KEY_DUPLICATE)) {
log.warn("Duplicate value for ordered field {}; ignoring. Possibly duplicate index definition.", f.name());
- lastDuplicateWarning = now;
}
}
}
} catch (Exception e) {
- log.warn(
- "[{}] Ignoring ordered property. Could not convert property {} of type {} to type {} for path {}",
- getIndexName(), pname,
- Type.fromTag(property.getType().tag(), false),
- Type.fromTag(tag, false), path, e);
+ String message = e.getMessage();
+ String key = null;
+ // This is a known warning, one of:
+ // - IllegalArgumentException: Not a date string
+ // - RuntimeException: Unable to parse the provided date field
+ // - NumberFormatException: For input string
+ // For these we do not log a stack trace, and we only log once every 10 seconds
+ // (the location of the code can be found if needed, as it's in Oak)
+ if (message.startsWith("Not a date string")) {
+ key = LOG_KEY_NOT_A_DATE_STRING;
+ } else if (message.startsWith("Unable to parse the provided date field")) {
+ key = LOG_KEY_UNABLE_TO_PARSE;
+ } else if (message.startsWith("For input string")) {
+ key = LOG_KEY_FOR_INPUT_STRING;
+ }
+ if (key != null) {
+ if (!LOG_SILENCER.silence(key)) {
+ // log without stack trace (as it is known)
+ log.warn(
+ "[{}] Ignoring ordered property. Could not convert property {} of type {} to type {} for path {}, message {}",
+ getIndexName(), pname,
+ Type.fromTag(property.getType().tag(), false),
+ Type.fromTag(tag, false), path, e.getMessage());
+ }
+ } else {
+ log.warn(
+ "[{}] Ignoring ordered property. Could not convert property {} of type {} to type {} for path {}",
+ getIndexName(), pname,
+ Type.fromTag(property.getType().tag(), false),
+ Type.fromTag(tag, false), path, e);
+ }
}
return fieldAdded;
}
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
index 92218b0ab3..7c1da65208 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/NodeDocument.java
@@ -16,6 +16,20 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+import static java.util.Objects.requireNonNull;
+import static java.util.stream.Collectors.toSet;
+import static org.apache.jackrabbit.guava.common.base.Preconditions.checkArgument;
+import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
+import static org.apache.jackrabbit.guava.common.collect.Iterables.filter;
+import static org.apache.jackrabbit.guava.common.collect.Iterables.mergeSorted;
+import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;
+import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
+import static org.apache.jackrabbit.oak.plugins.document.StableRevisionComparator.REVERSE;
+import static org.apache.jackrabbit.oak.plugins.document.util.Utils.abortingIterable;
+import static org.apache.jackrabbit.oak.plugins.document.util.Utils.resolveCommitRevision;
+import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Key;
+import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -39,42 +53,26 @@ import java.util.function.Predicate;
import org.apache.jackrabbit.guava.common.collect.AbstractIterator;
import org.apache.jackrabbit.guava.common.collect.ImmutableList;
+import org.apache.jackrabbit.guava.common.collect.Iterables;
import org.apache.jackrabbit.guava.common.collect.Lists;
+import org.apache.jackrabbit.guava.common.collect.Maps;
import org.apache.jackrabbit.guava.common.collect.Ordering;
import org.apache.jackrabbit.guava.common.collect.Queues;
+import org.apache.jackrabbit.guava.common.collect.Sets;
import org.apache.jackrabbit.oak.api.PropertyState;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.commons.json.JsopBuilder;
import org.apache.jackrabbit.oak.commons.json.JsopReader;
import org.apache.jackrabbit.oak.commons.json.JsopTokenizer;
import org.apache.jackrabbit.oak.commons.json.JsopWriter;
+import org.apache.jackrabbit.oak.commons.log.LogSilencer;
import org.apache.jackrabbit.oak.plugins.document.memory.MemoryDocumentStore;
-import org.apache.jackrabbit.oak.plugins.document.util.LogSilencer;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.jackrabbit.guava.common.collect.Iterables;
-import org.apache.jackrabbit.guava.common.collect.Maps;
-import org.apache.jackrabbit.guava.common.collect.Sets;
-
-import static java.util.Objects.requireNonNull;
-import static java.util.stream.Collectors.toSet;
-
-import static org.apache.jackrabbit.guava.common.base.Preconditions.checkArgument;
-import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
-import static org.apache.jackrabbit.guava.common.collect.Iterables.filter;
-import static org.apache.jackrabbit.guava.common.collect.Iterables.mergeSorted;
-import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;
-import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
-import static org.apache.jackrabbit.oak.plugins.document.StableRevisionComparator.REVERSE;
-import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Key;
-import static org.apache.jackrabbit.oak.plugins.document.UpdateOp.Operation;
-import static org.apache.jackrabbit.oak.plugins.document.util.Utils.abortingIterable;
-import static org.apache.jackrabbit.oak.plugins.document.util.Utils.resolveCommitRevision;
-
/**
* A document storing data about a node.
*/
diff --git a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java
index b72b83f8e0..ecfe5ae124 100644
--- a/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java
+++ b/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/SplitDocumentCleanUp.java
@@ -16,23 +16,22 @@
*/
package org.apache.jackrabbit.oak.plugins.document;
+import static org.apache.jackrabbit.guava.common.base.Preconditions.checkArgument;
+import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
+import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.INTERMEDIATE;
+import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.NONE;
+
import java.io.Closeable;
import java.io.IOException;
import java.util.List;
import org.apache.jackrabbit.guava.common.collect.Lists;
-
+import org.apache.jackrabbit.oak.commons.log.LogSilencer;
import org.apache.jackrabbit.oak.plugins.document.VersionGarbageCollector.VersionGCStats;
-import org.apache.jackrabbit.oak.plugins.document.util.LogSilencer;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.jackrabbit.guava.common.base.Preconditions.checkArgument;
-import static org.apache.jackrabbit.oak.plugins.document.Collection.NODES;
-import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.INTERMEDIATE;
-import static org.apache.jackrabbit.oak.plugins.document.NodeDocument.SplitDocType.NONE;
-
/**
* Implements a split document cleanup.
*/