Skip to content

OAK-11025 Silence more warnings for ordered properties#1645

Merged
thomasmueller merged 4 commits intotrunkfrom
OAK-11025
Aug 15, 2024
Merged

OAK-11025 Silence more warnings for ordered properties#1645
thomasmueller merged 4 commits intotrunkfrom
OAK-11025

Conversation

@thomasmueller
Copy link
Copy Markdown
Member

No description provided.

Comment on lines +312 to +314
if (message.startsWith("Not a date string") ||
message.startsWith("Unable to parse the provided date field") ||
message.startsWith("For input string")) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think we should treat each of the messages separately. As it is, this implementation may totally suppress some classes of warnings. A message like "Not a date string" might never be shown if it just happens to always occur when the logging is being suppressed. Maybe we can use this class, which already does something like what we want:

https://github.com/apache/jackrabbit-oak/blob/trunk/oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/util/LogSilencer.java

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think we should treat each of the messages separately.

At first, I also thought about doing something similar: having a separate delay for each property. But that would complicate the code, and in my view unnecessarily: We don't have any evidence that someone (except us) is looking at these warnings. If someone is looking at the warnings, then he would take action, no matter what message.

I had a look at the LogSilencer, but it seems it is not protected against multi-threaded access to the cache. I don't want to risk running out of memory.

So I think the patch should be kept as-is.

Copy link
Copy Markdown
Contributor

@nfsantos nfsantos Aug 15, 2024

Choose a reason for hiding this comment

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

I don't agree that we should suppress altogether some types of errors. Either the error message is important and should always be logged (although removing duplicates), or else it is not important and it should not be logged at all. But a probabilistic approach where the message is logged in some runs but not in other runs, depending only on chance does not seem to be correct.

From what I saw, the LogSilencer is thread-safe and supports bounding the memory usage, so there is no risk of OOME.

private static final int DEFAULT_CACHE_SIZE = 64;
private final int cacheSize;
private final long silenceMillis;
@SuppressWarnings("serial")
private final Map<String, Long> silences = Collections.synchronizedMap(
new LinkedHashMap<String, Long>() {
protected final boolean removeEldestEntry(Map.Entry<String, Long> eldest) {
return size() > cacheSize;
}
});

The only thing I don't like so much about the LogSilencer is that in this case it would be more useful to count the number of times a message is suppressed and then print a warning like:

(this message was repeated n times).

So that we would know how widespread is the particular issue (if a few dozen times in a run, then ignore, if it appears millions of times, may be worth to investigate).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't agree that we should suppress altogether some types of errors

Well, the patch doesn't. It just avoid filling the log file.

Either the error message is important and should always be logged (although removing duplicates), or else it is not important and it should not be logged at all.

I don't see this as a binary thing. We do log a warning if we find a problem, but we need to avoid logging too much. That is what the patch does.

From what I saw, the LogSilencer is thread-safe

Ah I didn't see Collections.synchronizedMap sorry.

OK I'll try to use it.

@thomasmueller thomasmueller requested a review from nfsantos August 15, 2024 05:39
Comment on lines +318 to +324
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;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could be simplified a bit, something like:

List<String> errorMessagePrefixes = List.of("Not a date string", "Unable to parse the provided date field", "For input string");
...
String key = errorMessagePrefixes.stream().find(t -> message.startsWith(t))...

@thomasmueller thomasmueller merged commit 3bb3418 into trunk Aug 15, 2024
reschke added a commit that referenced this pull request Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants