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 md...@apache.org on 2014/07/10 17:49:12 UTC
svn commit: r1609488 - in /jackrabbit/oak/trunk:
oak-doc/src/site/markdown/dos_and_donts.md
oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
Author: mduerig
Date: Thu Jul 10 15:49:12 2014
New Revision: 1609488
URL: http://svn.apache.org/r1609488
Log:
OAK-1964: Performance degradation due to SessionDelegate.WarningLock
Only log the stack trace if debug level logging is enabled for SessionDelegate
Modified:
jackrabbit/oak/trunk/oak-doc/src/site/markdown/dos_and_donts.md
jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
Modified: jackrabbit/oak/trunk/oak-doc/src/site/markdown/dos_and_donts.md
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-doc/src/site/markdown/dos_and_donts.md?rev=1609488&r1=1609487&r2=1609488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-doc/src/site/markdown/dos_and_donts.md (original)
+++ jackrabbit/oak/trunk/oak-doc/src/site/markdown/dos_and_donts.md Thu Jul 10 15:49:12 2014
@@ -44,6 +44,13 @@ multiple threads. When doing so Oak will
from becoming corrupted but will not make any guarantees beyond that. In
particular violating clients might suffer from lock contentions or deadlocks.
+If Oak detects concurrent write access to a session it will log a warning.
+For concurrent read access the warning will only be logged if `DEBUG` level
+is enabled for `org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate`.
+In this case the stack trace of the other session involved will also be
+logged. For efficiency reasons the stack trace will not be logged if
+`DEBUG` level is not enabled.
+
### Large number of direct child node
Oak scales to large number of direct child nodes of a node as long as those
Modified: jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java?rev=1609488&r1=1609487&r2=1609488&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java (original)
+++ jackrabbit/oak/trunk/oak-jcr/src/main/java/org/apache/jackrabbit/oak/jcr/delegate/SessionDelegate.java Thu Jul 10 15:49:12 2014
@@ -679,7 +679,7 @@ public class SessionDelegate {
lock.lock();
if (holderThread != null) {
if (this.isUpdate) {
- log.warn("Attempted to perform " + opName + " while thread " + holderThread +
+ warn(log, "Attempted to perform " + opName + " while thread " + holderThread +
" was concurrently writing to this session. Blocked until the " +
"other thread finished using this session. Please review your code " +
"to avoid concurrent use of a session.", holderTrace);
@@ -692,10 +692,20 @@ public class SessionDelegate {
}
}
this.isUpdate = isUpdate;
- holderTrace = new Exception("Stack trace of concurrent access to session");
+ if (log.isDebugEnabled()) {
+ holderTrace = new Exception("Stack trace of concurrent access to session");
+ }
holderThread = Thread.currentThread().getName();
}
+ private static void warn(Logger logger, String message, Exception stackTrace) {
+ if (stackTrace != null) {
+ logger.warn(message, stackTrace);
+ } else {
+ logger. warn(message);
+ }
+ }
+
public void lock(SessionOperation<?> sessionOperation) {
lock(sessionOperation.isUpdate(), sessionOperation.toString());
}