You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2020/07/10 12:10:40 UTC

[GitHub] [jackrabbit-oak] mreutegg opened a new pull request #241: OAK-9139: Log message on frozen node lookup by identifier

mreutegg opened a new pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241


   Logger implementation hidden behind a feature toggle. The logger has flood protection and prints at most one message per second.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on pull request #241: OAK-9139: Log message on frozen node lookup by identifier

Posted by GitBox <gi...@apache.org>.
mreutegg commented on pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241#issuecomment-659898948


   > I guess the most important thing really is that this is the only place where a lookup to nt:frozenNode is possible.
   
   Yes, I checked and all lookups are routed through this location. There are a few exceptions that talk directly to the IdentifierManager, but those lookups are for specific nodes that cannot be nt:frozenNode (e.g. a nt:version node).


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg closed pull request #241: OAK-9139: Log message on frozen node lookup by identifier

Posted by GitBox <gi...@apache.org>.
mreutegg closed pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #241: OAK-9139: Log message on frozen node lookup by identifier

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241#discussion_r456264117



##########
File path: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/FrozenNodeLogger.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.jcr.version;
+
+import java.io.Closeable;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.spi.toggle.Feature;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.apache.jackrabbit.oak.stats.Clock;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_FROZENNODE;
+import static org.apache.jackrabbit.oak.spi.toggle.Feature.newFeature;
+
+/**
+ * Logger facility for frozen node lookups by identifier. Calls to
+ * {@link #lookupById(Tree)} first check the feature toggle
+ * {@code oak.logFrozenNodeLookup} and then whether the given {@code Tree} is of
+ * type {@code nt:frozenNode} in which case the path of the tree is logged at
+ * INFO. Log messages are rate limited to one per second. If multiple frozen
+ * nodes are looked up by identifier with the period of one second, then only
+ * the first lookup is logged; the other lookups are not logged.
+ * Enabling DEBUG level for this class reveals the stack of the calling thread.
+ */
+public class FrozenNodeLogger implements Closeable {
+
+    private static final Logger log = LoggerFactory.getLogger(FrozenNodeLogger.class);
+
+    private static final long LOG_INTERVAL = 1000L;
+
+    private static long NO_MESSAGE_UNTIL = 0;
+
+    private final Clock clock;
+
+    private final Feature feature;
+
+    public FrozenNodeLogger(@NotNull Clock clock,
+                            @NotNull Whiteboard whiteboard) {
+        this.clock = checkNotNull(clock);
+        this.feature = newFeature("OAK-9139_log_frozen_node_lookup", whiteboard);

Review comment:
       My idea was to have it disabled by default. It does add a little bit of overhead, even though I did not see a significant change running the UUIDLookupTest benchmark.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on a change in pull request #241: OAK-9139: Log message on frozen node lookup by identifier

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on a change in pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241#discussion_r454268096



##########
File path: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/FrozenNodeLogger.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.jcr.version;
+
+import java.io.Closeable;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.spi.toggle.Feature;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.apache.jackrabbit.oak.stats.Clock;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_FROZENNODE;
+import static org.apache.jackrabbit.oak.spi.toggle.Feature.newFeature;
+
+/**
+ * Logger facility for frozen node lookups by identifier. Calls to
+ * {@link #lookupById(Tree)} first check the feature toggle
+ * {@code oak.logFrozenNodeLookup} and then whether the given {@code Tree} is of
+ * type {@code nt:frozenNode} in which case the path of the tree is logged at
+ * INFO. Log messages are rate limited to one per second. If multiple frozen
+ * nodes are looked up by identifier with the period of one second, then only
+ * the first lookup is logged; the other lookups are not logged.
+ * Enabling DEBUG level for this class reveals the stack of the calling thread.
+ */
+public class FrozenNodeLogger implements Closeable {
+
+    private static final Logger log = LoggerFactory.getLogger(FrozenNodeLogger.class);
+
+    private static final long LOG_INTERVAL = 1000L;

Review comment:
       I was wondering if there might ever be a need for this to be adjusted? (eg convert this to a System Property? but might also be overkill)

##########
File path: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/FrozenNodeLogger.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.jcr.version;
+
+import java.io.Closeable;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.spi.toggle.Feature;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.apache.jackrabbit.oak.stats.Clock;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_FROZENNODE;
+import static org.apache.jackrabbit.oak.spi.toggle.Feature.newFeature;
+
+/**
+ * Logger facility for frozen node lookups by identifier. Calls to
+ * {@link #lookupById(Tree)} first check the feature toggle
+ * {@code oak.logFrozenNodeLookup} and then whether the given {@code Tree} is of
+ * type {@code nt:frozenNode} in which case the path of the tree is logged at
+ * INFO. Log messages are rate limited to one per second. If multiple frozen
+ * nodes are looked up by identifier with the period of one second, then only
+ * the first lookup is logged; the other lookups are not logged.
+ * Enabling DEBUG level for this class reveals the stack of the calling thread.
+ */
+public class FrozenNodeLogger implements Closeable {
+
+    private static final Logger log = LoggerFactory.getLogger(FrozenNodeLogger.class);
+
+    private static final long LOG_INTERVAL = 1000L;
+
+    private static long NO_MESSAGE_UNTIL = 0;
+
+    private final Clock clock;
+
+    private final Feature feature;
+
+    public FrozenNodeLogger(@NotNull Clock clock,
+                            @NotNull Whiteboard whiteboard) {
+        this.clock = checkNotNull(clock);
+        this.feature = newFeature("OAK-9139_log_frozen_node_lookup", whiteboard);
+    }
+
+    public final void lookupById(@NotNull Tree tree) {
+        if (!feature.isEnabled()) {
+            return;
+        }
+        PropertyState primaryType = tree.getProperty(JCR_PRIMARYTYPE);
+        if (primaryType != null
+                && !primaryType.isArray()
+                && primaryType.getValue(Type.STRING).equals(NT_FROZENNODE)) {
+            long now = clock.getTime();
+            synchronized (FrozenNodeLogger.class) {
+                if (now >= NO_MESSAGE_UNTIL) {
+                    NO_MESSAGE_UNTIL = now + LOG_INTERVAL;
+                    logFrozenNode(tree);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void close() {
+        feature.close();
+    }
+
+    protected void logFrozenNode(Tree tree) {
+        log.info("Frozen node {} looked up by id", tree.getPath());
+        if (log.isDebugEnabled()) {
+            log.debug("Call stack", new Exception());

Review comment:
       nitpicking: replace "Call stack" with sth more descriptive? (might potentially simplify future `grep` effort)




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #241: OAK-9139: Log message on frozen node lookup by identifier

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241#discussion_r456250693



##########
File path: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/FrozenNodeLogger.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.jcr.version;
+
+import java.io.Closeable;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.spi.toggle.Feature;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.apache.jackrabbit.oak.stats.Clock;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_FROZENNODE;
+import static org.apache.jackrabbit.oak.spi.toggle.Feature.newFeature;
+
+/**
+ * Logger facility for frozen node lookups by identifier. Calls to
+ * {@link #lookupById(Tree)} first check the feature toggle
+ * {@code oak.logFrozenNodeLookup} and then whether the given {@code Tree} is of
+ * type {@code nt:frozenNode} in which case the path of the tree is logged at
+ * INFO. Log messages are rate limited to one per second. If multiple frozen
+ * nodes are looked up by identifier with the period of one second, then only
+ * the first lookup is logged; the other lookups are not logged.
+ * Enabling DEBUG level for this class reveals the stack of the calling thread.
+ */
+public class FrozenNodeLogger implements Closeable {
+
+    private static final Logger log = LoggerFactory.getLogger(FrozenNodeLogger.class);
+
+    private static final long LOG_INTERVAL = 1000L;

Review comment:
       Good point. I'll introduce a system property.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on a change in pull request #241: OAK-9139: Log message on frozen node lookup by identifier

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on a change in pull request #241:
URL: https://github.com/apache/jackrabbit-oak/pull/241#discussion_r454368299



##########
File path: oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/version/FrozenNodeLogger.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.oak.jcr.version;
+
+import java.io.Closeable;
+
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.spi.toggle.Feature;
+import org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard;
+import org.apache.jackrabbit.oak.stats.Clock;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.jackrabbit.JcrConstants.JCR_PRIMARYTYPE;
+import static org.apache.jackrabbit.JcrConstants.NT_FROZENNODE;
+import static org.apache.jackrabbit.oak.spi.toggle.Feature.newFeature;
+
+/**
+ * Logger facility for frozen node lookups by identifier. Calls to
+ * {@link #lookupById(Tree)} first check the feature toggle
+ * {@code oak.logFrozenNodeLookup} and then whether the given {@code Tree} is of
+ * type {@code nt:frozenNode} in which case the path of the tree is logged at
+ * INFO. Log messages are rate limited to one per second. If multiple frozen
+ * nodes are looked up by identifier with the period of one second, then only
+ * the first lookup is logged; the other lookups are not logged.
+ * Enabling DEBUG level for this class reveals the stack of the calling thread.
+ */
+public class FrozenNodeLogger implements Closeable {
+
+    private static final Logger log = LoggerFactory.getLogger(FrozenNodeLogger.class);
+
+    private static final long LOG_INTERVAL = 1000L;
+
+    private static long NO_MESSAGE_UNTIL = 0;
+
+    private final Clock clock;
+
+    private final Feature feature;
+
+    public FrozenNodeLogger(@NotNull Clock clock,
+                            @NotNull Whiteboard whiteboard) {
+        this.clock = checkNotNull(clock);
+        this.feature = newFeature("OAK-9139_log_frozen_node_lookup", whiteboard);

Review comment:
       Question: is the goal that this feature is by default enabled? I guess that would be useful.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org