我在生产中遇到了一个问题,因为我认为它阻止了线程。
当我从生产环境获得线程转储时,我很惊讶大约50%的线程处于状态:
- 阻止尝试锁定:ch / qos / logback / classic / sift / SiftingAppender @ 0x1111fe3e8 [unlocked]
与此同时,正如您所看到的,SiftingAppender已“解锁”。
我不知道为什么会这样。
如果我们深入了解logback源代码,我们会发现有一个同步方法,这是我认为的“瘦”的地方:
ch.qos.logback.core.AppenderBase.doAppend(E)
public synchronized void doAppend(E eventObject) {
// WARNING: The guard check MUST be the first statement in the
// doAppend() method.
// prevent re-entry.
if (guard) {
return;
}
try {
guard = true;
if (!this.started) {
if (statusRepeatCount++ < ALLOWED_REPEATS) {
addStatus(new WarnStatus(
"Attempted to append to non started appender [" + name + "].",
this));
}
return;
}
if (getFilterChainDecision(eventObject) == FilterReply.DENY) {
return;
}
// ok, we now invoke derived class' implementation of append
this.append(eventObject);
} catch (Exception e) {
if (exceptionCount++ < ALLOWED_REPEATS) {
addError("Appender [" + name + "] failed to append.", e);
}
} finally {
guard = false;
}
}
这是2个不同线程的完整堆栈:
"[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'" id=25 idx=0x68 tid=29025 prio=5 alive, blocked, native_blocked, daemon
-- Blocked trying to get lock: ch/qos/logback/classic/sift/SiftingAppender@0x1111fe3e8[unlocked]
at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1411)[optimized]
at jrockit/vm/Locks.lockFat(Locks.java:1512)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1054)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1005)[optimized]
at ch/qos/logback/core/AppenderBase.doAppend(AppenderBase.java:65)[optimized]
at ch/qos/logback/core/spi/AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)[inlined]
at ch/qos/logback/classic/Logger.appendLoopOnAppenders(Logger.java:280)[inlined]
at ch/qos/logback/classic/Logger.callAppenders(Logger.java:267)[inlined]
at ch/qos/logback/classic/Logger.buildLoggingEventAndAppend(Logger.java:449)[inlined]
at ch/qos/logback/classic/Logger.filterAndLog_1(Logger.java:421)[inlined]
at ch/qos/logback/classic/Logger.info(Logger.java:611)[inlined]
at cz/bsc/g6/components/base/web/services/api/exception/ServiceImplLoggingAndExceptionWebTranslationAspect.logAfter(ServiceImplLoggingAndExceptionWebTranslationAspect.java:167)[inlined]
at sun/reflect/GeneratedMethodAccessor672.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)[optimized]
at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[optimized]
at java/lang/reflect/Method.invoke(Method.java:597)[optimized]
at org/springframework/aop/aspectj/AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)[inlined]
at org/springframework/aop/aspectj/AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:603)[inlined]
at org/springframework/aop/aspectj/AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:45)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/framework/adapter/MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/interceptor/ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/framework/JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)[optimized]
at $Proxy538.getVoLinkValue(Ljava/lang/Class;Ljava/lang/String;)Lcz/bsc/g6/components/base/web/services/api/vo/catalog/VoLink;(Unknown Source)[optimized]
at cz/bsc/g6/components/hccommon/web/ui/component/PortalMenuComponent.getItemName(PortalMenuComponent.java:112)[inlined]
at cz/bsc/g6/components/hccommon/web/ui/component/PortalMenuComponent.getMenuItems(PortalMenuComponent.java:46)[optimized]
at sun/reflect/GeneratedMethodAccessor1005.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)[optimized]
at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[optimized]
at java/lang/reflect/Method.invoke(Method.java:597)[optimized]
at javax/el/BeanELResolver.getValue(BeanELResolver.java:305)[optimized]
at com/sun/faces/el/DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)[inlined]
at com/sun/faces/el/DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)[optimized]
at com/sun/el/parser/AstValue.getValue(AstValue.java:138)[inlined]
at com/sun/el/parser/AstValue.getValue(AstValue.java:183)[optimized]
at com/sun/el/ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)[optimized]
at com/sun/faces/facelets/el/TagValueExpression.getValue(TagValueExpression.java:109)[optimized]
at com/sun/faces/facelets/tag/jstl/core/IndexedValueExpression.getValue(IndexedValueExpression.java:92)
...
-- end of trace
"pool-4050-thread-2" id=19383 idx=0x8a8 tid=17037 prio=5 alive, blocked, native_blocked
-- Blocked trying to get lock: ch/qos/logback/classic/sift/SiftingAppender@0x1111fe3e8[unlocked]
at jrockit/vm/Threads.waitForUnblockSignal()V(Native Method)
at jrockit/vm/Locks.fatLockBlockOrSpin(Locks.java:1411)[optimized]
at jrockit/vm/Locks.lockFat(Locks.java:1512)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1054)[optimized]
at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1005)[optimized]
at ch/qos/logback/core/AppenderBase.doAppend(AppenderBase.java:65)[optimized]
at ch/qos/logback/core/spi/AppenderAttachableImpl.appendLoopOnAppenders(AppenderAttachableImpl.java:48)[inlined]
at ch/qos/logback/classic/Logger.appendLoopOnAppenders(Logger.java:280)[inlined]
at ch/qos/logback/classic/Logger.callAppenders(Logger.java:267)[inlined]
at ch/qos/logback/classic/Logger.buildLoggingEventAndAppend(Logger.java:449)[inlined]
at ch/qos/logback/classic/Logger.filterAndLog_1(Logger.java:421)[inlined]
at ch/qos/logback/classic/Logger.info(Logger.java:611)[optimized]
at cz/bsc/g6/components/base/transform/container/AbstractTransformerProvidersContainer.resolveProviderFromToInstance(AbstractTransformerProvidersContainer.java:377)[optimized]
at cz/bsc/g6/components/base/transform/AbstractToTransformer.transformToClass(AbstractToTransformer.java:241)
at cz/bsc/g6/components/card/ws/resources/impl/WsCreditCardDao.getCreditCards(WsCreditCardDao.java:103)
at cz/bsc/g6/components/card/manager/impl/CreditCardManagerImpl.getCreditCards(CreditCardManagerImpl.java:22)
at sun/reflect/GeneratedMethodAccessor2279.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[optimized]
at java/lang/reflect/Method.invoke(Method.java:597)[inlined]
at org/springframework/aop/support/AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)[optimized]
at org/springframework/aop/framework/JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)[optimized]
at $Proxy286.getCreditCards()Ljava/util/List;(Unknown Source)
at cz/bsc/g6/components/card/web/services/impl/CreditCardWebServiceImpl.getCreditCards(CreditCardWebServiceImpl.java:54)
at sun/reflect/GeneratedMethodAccessor2277.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[optimized]
at java/lang/reflect/Method.invoke(Method.java:597)[optimized]
at org/springframework/aop/support/AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)[inlined]
at org/springframework/aop/framework/ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)[inlined]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)[optimized]
at org/springframework/aop/aspectj/MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at cz/bsc/g6/components/base/web/services/impl/ServiceCallWrapperAspect.wrapCall(ServiceCallWrapperAspect.java:36)
at sun/reflect/GeneratedMethodAccessor1514.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown Source)
at sun/reflect/DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[optimized]
at java/lang/reflect/Method.invoke(Method.java:597)[inlined]
at org/springframework/aop/aspectj/AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)[optimized]
at org/springframework/aop/aspectj/AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org/springframework/aop/aspectj/AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:161)[optimized]
at org/springframework/transaction/interceptor/TransactionInterceptor.invoke(TransactionInterceptor.java:110)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/aspectj/AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/aspectj/AspectJAfterAdvice.invoke(AspectJAfterAdvice.java:42)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/framework/adapter/MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:50)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/interceptor/ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)[optimized]
at org/springframework/aop/framework/ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)[optimized]
at org/springframework/aop/framework/JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)[optimized]
at $Proxy527.getCreditCards()Ljava/util/List;(Unknown Source)
at cz/bsc/g6/components/card/web/ui/component/CreditCardListComponent.updateCreditCardsList(CreditCardListComponent.java:65)
at cz/bsc/g6/components/hccommon/web/ui/component/ProductListContainerComponent$2.run(ProductListContainerComponent.java:107)
at cz/bsc/g6/components/hccommon/web/ui/system/MultiThreadingUtility$G6Thread.call(MultiThreadingUtility.java:60)
at cz/bsc/g6/components/hccommon/web/ui/system/MultiThreadingUtility$G6Thread.call(MultiThreadingUtility.java:42)
at java/util/concurrent/FutureTask$Sync.innerRun(FutureTask.java:303)
at java/util/concurrent/FutureTask.run(FutureTask.java:138)
at java/util/concurrent/ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java/util/concurrent/ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java/lang/Thread.run(Thread.java:662)
at jrockit/vm/RNI.c2java(JJJJJ)V(Native Method)
-- end of trace
我们使用weblogic v.10.3.5.0 slf4j.version - 1.7.5 logback.version - 1.0.13
有没有人想到为什么会这样?以及如何避免这个问题?
Logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<property scope="system" name="logRoot" value="/opt/BSCPraha/GEMINI/IBS/logs" />
<appender name="COMMON" class="ch.qos.logback.classic.sift.SiftingAppender">
<discriminator class="ch.qos.logback.classic.sift.MDCBasedDiscriminator">
<key>SOURCE_APP</key>
<defaultValue>common</defaultValue>
</discriminator>
<sift>
<appender name="FILE-${SOURCE_APP}"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logRoot}/hc-${SOURCE_APP}.log
</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${logRoot}/hc-${SOURCE_APP}-%d{yyyy.MM.dd_HH}-%i.log
</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>1000MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>%d{ISO8601} [%t] %-5p %c{1} [%X{sessionId}] [%X{requestIp}] - %m%n</pattern>
<immediateFlush>false</immediateFlush>
</encoder>
</appender>
</sift>
</appender>
<!-- webstart module logger -->
<logger name="cz.bsc.g6.components.starter.webstart" additivity="false">
<level value="info" />
</logger>
<!-- logging the XML interaction (calling Webservices of ESB) -->
<logger name="cz.bsc.g6.components.base.ws.resources.impl">
<level value="debug" />
</logger>
<logger name="org.springframework.ws.soap.saaj.SaajSoapMessageFactory">
<level value="debug" />
</logger>
<logger name="cz.bsc.g6">
<level value="debug" />
</logger>
<!-- Logging EI data -->
<logger
name="cz.bsc.g6.components.base.ei.services.impl.EiwsEndpoint.request">
<level value="debug" />
</logger>
<logger
name="cz.bsc.g6.components.base.ei.services.impl.EiwsEndpoint.response">
<level value="info" />
</logger>
<!-- log SQL query -->
<logger name="org.hibernate.SQL">
<level value="info" />
</logger>
<!-- log SQL query parameters values -->
<logger name="org.hibernate.engine.QueryParameters">
<level value="info" />
</logger>
<logger name="org.hibernate.engine.query.HQLQueryPlan">
<level value="info" />
</logger>
<root>
<level value="info" />
<appender-ref ref="COMMON" />
</root>
答案 0 :(得分:0)
日志是否保存在NFS挂载上? 将所有调试设置为info,然后让我知道:)