Example of how btrace locates production faults
This article mainly introduces examples of btrace's method of locating production faults. The article introduces it in detail through the example code. I believe it has certain reference value for everyone. Friends who need it can take a look below.
Preface
Many times we need to know more details about the running of the program, but it is impossible to print all the running details in the program during development. Go to the log. Usually what you can do at this time is to modify the code, redeploy, and then observe again. However, this method is not very good for online applications. On the other hand, if you encounter code that is difficult to change, such as other referenced External packages and so on are very troublesome. BTrace is a tool that can dynamically view program running details without changing the code or restarting the application. The following article introduces the method of btrace to locate production faults. , friends in need can refer to it.
Phenomena
Some requests are very slow through the data access layer and cause the processing thread to be blocked, and the exception cannot be detected from the monitoring.
Write btrace script
@BTrace public class DBProxyTrace { @OnMethod(clazz = "xxx.xxx.QueryHandler", method = "query", location = @Location(Kind.RETURN)) public static void trace2(String sql, @Duration long duration) { if (duration/1000000 > 10 * 1000) { com.sun.btrace.BTraceUtils.println(duration/1000000 + "ms"); com.sun.btrace.BTraceUtils.println("this task executes more than 10s. the sql is : " + sql); com.sun.btrace.BTraceUtils.println("jstack is : "); com.sun.btrace.BTraceUtils.jstack(); } } }
Judge the SQL and stack information that is executed for more than 10 seconds.
Compile the script DBProxyTrace.Java and confirm that there is no problem with the script.
./bin/btracec -cp build/ java/DBProxyTrace.java
Execute script DBProxyTrace.class
./bin/btrace -cp build/ 17342 DBProxyTrace.class
Information
10468ms this task executes more than 10s. the sql is : rollback jstack is : xxx.QueryHandler.query(QueryHandler.java:106) xxx.net.AbstractConnection.onReadData(AbstractConnection.java:245) xxx.net.NIOReactor$RW.run(NIOReactor.java:77) java.lang.Thread.run(Thread.java:745)
Location
Blocked in transaction rollback.
Use jstack for further positioning.
Print JVM stack
"$_NIOREACTOR-7-RW" prio=10 tid=0x00007f069856f000 nid=0xde1 waiting for monitor entry [0x00007f0677011000] java.lang.Thread.State: BLOCKED (on object monitor) at Oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:1167) - waiting to lock <0x000000068086fbc0> (a oracle.jdbc.driver.T4CConnection)
Conclusion
Blocked The oracle driver rollback action is actually because the oracle driver adds a lock on the bottom layer to ensure the serial request response, and this channel is blocked by slow statements, so the rollback is blocked.
Summary
The above is the content of the example of btrace's method of locating production faults. For more related content, please pay attention to the PHP Chinese website (www.php .cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use map and positioning functions in uniapp 1. Background introduction With the popularity of mobile applications and the rapid development of positioning technology, map and positioning functions have become an indispensable part of modern mobile applications. uniapp is a cross-platform application development framework developed based on Vue.js, which can facilitate developers to share code on multiple platforms. This article will introduce how to use maps and positioning functions in uniapp and provide specific code examples. 2. Use the uniapp-amap component to implement the map function

1. First, we open the [Search] App on the mobile phone and select the device in the list on the device interface. 2. Then, you can check the location and click on the route to navigate there.

How to use WordPress plug-ins to achieve instant location functionality With the popularity of mobile devices, more and more websites are beginning to provide geolocation-based services. In WordPress websites, we can use plug-ins to implement instant positioning functions and provide visitors with services related to their geographical location. 1. Choose the right plug-in. There are many plug-ins that provide geolocation services in the WordPress plug-in library to choose from. Depending on the needs and requirements, choosing the right plug-in is the key to achieving instant positioning functionality. Here are a few

Methods to solve the problem of memory leak location in Go language development: Memory leak is one of the common problems in program development. In Go language development, due to the existence of its automatic garbage collection mechanism, memory leak problems may be less than other languages. However, when we face large and complex applications, memory leaks may still occur. This article will introduce some common methods to locate and solve memory leak problems in Go language development. First, we need to understand what a memory leak is. Simply put, a memory leak refers to the

1. Click to enter the Amap map software on your mobile phone. 2. Click My in the lower right corner. 3. Click to enter the family map. 4. Click Create My Family Map. 5. After the creation is successful, an invitation code will appear and can be shared with another mobile phone.

We all know very clearly that Taku APP is a very reliable chat and social platform. Now it allows everyone to make friends online. Some of the forms of making friends here mainly allow people to make friends by location. Oh, it's so simple and direct. After all, it can automatically locate your current location information for you, and better match you with some friends in the same city who are close to each other, so that everyone can chat more easily and feel special. Happy, many times, in order to get to know more friends in other places, everyone has the idea of modifying their address, but they don’t know how to modify their location information, which is very difficult. troubled, so the editor of this site also collected some specific

In today's society, mobile phones have become an indispensable part of our lives. As a well-known smartphone brand, Huawei mobile phones are deeply loved by users. However, with the popularity of mobile phones and the increase in frequency of use, mobile phones are often lost. Once our phone is lost, we tend to feel anxious and confused. So, if you unfortunately lose your Huawei phone, how can you quickly find its location? Step 1: Use the mobile phone positioning function. Huawei mobile phones have built-in powerful positioning functions. Users can use the "Security" option in the mobile phone settings.

Recently, many users on the Internet said that when using Apple phones to search or comment on topics related to "discovering oil," the device will automatically turn on positioning. It is suspected that Apple phones are collecting and sending location information to monitor users. Will typing "Oil found" on iPhone trigger location? Can Apple's privacy be guaranteed in this way? Obviously, this is a misunderstanding! Apple customer service said that the positioning function is turned on by default, and any operation may trigger status updates, rather than being limited to sending specific text. But this statement is not entirely comprehensive. Generally, the iPhone rarely triggers the positioning function, unless you are searching for something, or the APP mechanism setting is related. When the user enters certain characters, the APP will automatically enable the positioning function in the background. Why can this topic
