wrapper.check.deadlock 配置

本文介绍了一种通过配置Wrapper属性来检测Java应用中死锁的方法。主要涉及四个属性:wrapper.check.deadlock、wrapper.check.deadlock.interval、wrapper.check.deadlock.action及wrapper.check.deadlock.output。这些属性允许用户控制死锁检查的频率、检测到死锁时采取的动作以及记录的信息级别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Index

Deadlock?:

Deadlocks can occur when two or more threads are locking resources in an order which results in all threads waiting indefinitely.

The simplest example is where Thread A locks Object A and then attempts to lock Object B, while another Thread B has Object B locked and is waiting to lock Object A. In this case, Thread A will never release Object A because it is waiting for Object B. This will never happen because Thread B will keep Object B locked indefinitely as it waits for Object A to become available.

wrapper.check.deadlock

Compatibility : 3.5.0
Editions : Professional EditionStandard EditionCommunity Edition (Not Supported)
Platforms : WindowsMac OSXLinuxIBM AIXFreeBSDHP-UXSolarisIBM z/OSIBM z/Linux

This wrapper.check.deadlock property, in combination with the other properties,

are used to configure how the Wrapper monitors a JVM for deadlocked threads. This can be very useful to detect and then work around potentially fatal problems which would otherwise be difficult if not impossible to work around.

Thread deadlock checks require that at least Java version 1.5 is used. Older JVMs will ignore the checks. It is possible to detect deadlocks involving "monitor" based thread locks (using synchronized)starting with Java 1.5. Deadlocks infolving "owned" or "reentrant" thread locks (using ReentrantLock) can also be detected starting with Java 1.6.

Checking for Deadlocks is fairly quick, but it does involve briefly locking and taking a snapshot of all threads so this property is FALSE by default.

Example: (Deadlock Check: Off)
wrapper.check.deadlock=FALSE

Simple Example:

Please read over the property details below, but the following simple example will configure the Wrapper to log the location of a deadlock and then immediately restart the JVM.

Example:
wrapper.check.deadlock=TRUE
wrapper.check.deadlock.interval=60
wrapper.check.deadlock.action=RESTART
wrapper.check.deadlock.output=FULL

wrapper.check.deadlock.interval

Compatibility : 3.5.0
Editions : Professional EditionStandard EditionCommunity Edition (Not Supported)
Platforms : WindowsMac OSXLinuxIBM AIXFreeBSDHP-UXSolarisIBM z/OSIBM z/Linux

The wrapper.check.deadlock.interval property makes it possible to control the interval at which the Wrapper looks for deadlocks in an application. It can be set to any interval starting with once per second, but The default value is "60" seconds (once per minute). In general, for applications which are known to be stable, it may be fine to greatly decrease the frequency of these deadlock checks.

Example: (once every 60 seconds)
wrapper.check.deadlock.interval=60

wrapper.check.deadlock.action

Compatibility : 3.5.0
Editions : Professional EditionStandard EditionCommunity Edition (Not Supported)
Platforms : WindowsMac OSXLinuxIBM AIXFreeBSDHP-UXSolarisIBM z/OSIBM z/Linux

The wrapper.check.deadlock.action property makes it possible to control what the Wrapper does when a deadlock is detectedThe default action is to RESTART.

Example:
wrapper.check.deadlock.action=RESTART

Possible actions are:

  • DEBUG :

    will cause a debug message to be logged. This is only really useful in helping to understand when the action is fired.

  • DUMP :

    will invoke a thread dump.

  • GC (Since ver. 3.5.7) :

    will invoke a full garbage collection sweep in the JVM. Be aware that doing this frequently can affect performance of the JVM as a full sweep will often cause all threads to freeze for the duration of the GC.

  • RESTART :

    will stop the current JVM and then restart a new invocation.

  • SHUTDOWN :

    will stop the JVM as well as the Wrapper.

  • USER_<n> (Professional Edition) :

    will cause a user defined event to be fired. This can be either the sending of an email, or the execution of an external system command. The command could be anything from performing clean up operations to raising an SNMP trap.

  • PAUSE :

    will pause the Java application if pausing is enabled and the JVM is running. See the wrapper.pausable property for details.

  • RESUME :

    will resume the Java application if it is in a paused state. This could be used if the JVM is not stopped when paused. See the wrapper.pausable property for details.

  • SUCCESS (Since ver. 3.5.5) :

    will tell the Wrapper to reset its internal failed invocation count and count the current JVM invocation as "successful". This is probably not useful in this context, but here for consistency with other properties.

  • NONE :

    will tell the Wrapper to log the fact that a deadlock was detected, but it will not actually do anything.

Note that actions, like "NONE", which do not restart the JVM will repeatedly be fired each time the deadlock check is made.

Chaining Multiple Actions:

It is also possible to list multiple actions so they each happen in the order specified.

Example:
wrapper.check.deadlock.action=DUMP,RESTART

wrapper.check.deadlock.output

Compatibility : 3.5.0
Editions : Professional EditionStandard EditionCommunity Edition (Not Supported)
Platforms : WindowsMac OSXLinuxIBM AIXFreeBSDHP-UXSolarisIBM z/OSIBM z/Linux

The wrapper.check.deadlock.output property makes it possible to control what information the Wrapper causes to be logged when a deadlock is detected. The default output level is FULL.

Example:
wrapper.check.deadlock.output=FULL

Possible output levels are:

  • FULL :

    will cause the WrapperManager class within the JVM to output a report which includes full stack traces for the threads involved in the deadlock.

    Output Example of "FULL":
    INFO   | jvm 1    | WrapperManager Error: Found 2 deadlocked threads!
    INFO   | jvm 1    | WrapperManager Error: =============================
    INFO   | jvm 1    | WrapperManager Error: "Locker-2" tid=18
    INFO   | jvm 1    | WrapperManager Error:   java.lang.Thread.State: BLOCKED
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock.lockSecond(DeadLock.java:64)
    INFO   | jvm 1    | WrapperManager Error:       - waiting on <0x000000002fcac6db> (a java.lang.Object) owned by "Locker-1" tid=17
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock.lockFirst(DeadLock.java:83)
    INFO   | jvm 1    | WrapperManager Error:       - locked <0x0000000029c56c60> (a java.lang.Object)
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock.access$100(DeadLock.java:22)
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock$1.run(DeadLock.java:42)
    INFO   | jvm 1    | WrapperManager Error:
    INFO   | jvm 1    | WrapperManager Error: "Locker-1" tid=17
    INFO   | jvm 1    | WrapperManager Error:   java.lang.Thread.State: BLOCKED
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock.lockSecond(DeadLock.java:64)
    INFO   | jvm 1    | WrapperManager Error:       - waiting on <0x0000000029c56c60> (a java.lang.Object) owned by "Locker-2" tid=18
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock.lockFirst(DeadLock.java:83)
    INFO   | jvm 1    | WrapperManager Error:       - locked <0x000000002fcac6db> (a java.lang.Object)
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock.access$100(DeadLock.java:22)
    INFO   | jvm 1    | WrapperManager Error:     at org.tanukisoftware.wrapper.test.DeadLock$1.run(DeadLock.java:42)
    INFO   | jvm 1    | WrapperManager Error:
    INFO   | jvm 1    | WrapperManager Error: =============================
    STATUS | wrapper  | A Thread Deadlock was detected in the JVM.  Restarting JVM.
  • SIMPLE :

    will cause the WrapperManager class within the JVM to output a report which includes only a brief summary naming the threads and objects involved in the deadlock. In many cases, this is enough especially for known problems.

    Output Example of "SIMPLE":
    INFO   | jvm 1    | WrapperManager Error: Found 2 deadlocked threads!
    INFO   | jvm 1    | WrapperManager Error: =============================
    INFO   | jvm 1    | WrapperManager Error: "Locker-2" BLOCKED waiting on a java.lang.Object owned by "Locker-1"
    INFO   | jvm 1    | WrapperManager Error: "Locker-1" BLOCKED waiting on a java.lang.Object owned by "Locker-2"
    INFO   | jvm 1    | WrapperManager Error: =============================
    STATUS | wrapper  | A Thread Deadlock was detected in the JVM.  Restarting JVM.
  • NONE (Since ver. 3.5.16) :

    will cause the WrapperManager class within the JVM to suppress all output. This may be desired for production systems when a problem is known but you don't want or need to maintain too much information in the logs. The Wrapper process, as in the other options, will always log a single entry to provide a reason why the triggeredaction takes place.

    Output Example of "NONE":
    STATUS | wrapper  | A Thread Deadlock was detected in the JVM.  Restarting JVM.
mycat是一个开源的分布式数据库中间件,用于管理和路由数据库请求。wrapper.conf是mycat的配置文件之一,用于配置mycat的核心参数和功能。下面是wrapper.conf配置文件的一些常见选项和其作用的简要解释: 1. wrapper.java.mainclass:指定mycat启动时使用的Java主类。 2. wrapper.working.dir:指定mycat工作目录。 3. wrapper.java.classpath:指定mycat运行所需的类路径。 4. wrapper.java.library.path:指定mycat运行所需的库路径。 5. wrapper.java.additional.X:添加额外的Java虚拟机参数,如-Xmx、-Xms等。 6. wrapper.app.parameter.X:添加额外的应用程序参数,如-Dproperty=value等。 7. wrapper.console.format:指定控制台输出格式。 8. wrapper.console.loglevel:指定控制台输出日志级别。 9. wrapper.logfile:指定日志文件路径。 10. wrapper.logfile.loglevel:指定日志文件输出级别。 11. wrapper.syslog.loglevel:指定系统日志输出级别。 12. wrapper.logfile.maxsize:指定日志文件的最大大小。 13. wrapper.logfile.maxfiles:指定日志文件的最大数量。 14. wrapper.restart.reload_configuration:设置为TRUE时,重新加载配置文件时会重启mycat。 这只是wrapper.conf文件中的一些常见选项,具体配置取决于你的需求和环境。你可以根据需要修改这些选项来调整和优化mycat的性能和功能。请注意,对于每个选项的具体含义和配置方式,建议查阅mycat的官方文档或相关资源以获取更详细的信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值