Full record of DB2 deadlock resolution process
DB2 is mainly used in large-scale application systems. It has good scalability and can support everything from mainframe to single-user environments. DB2 provides high-level data utilization, integrity, security, and recoverability. This article mainly introduces the full record of the DB2 deadlock resolution process. The cause of the deadlock in this article is the select statement. The processing process is quite difficult. Friends in need can refer to
in the production environment. The database used is DB2. However, a strange deadlock phenomenon has appeared frequently recently: a certain select sql statement always deadlocks.
According to past experience, deadlock problems usually occur in update sql statements such as update/delete. Moreover, this select sql statement is a very ordinary sql, without any processing of large amounts of data.
Analyzing this deadlock, there are many things that are difficult to deal with.
1. Due to the large amount of data in the production environment, we cannot import the data of the association table in the production environment into the test environment. That is, the amount of data cannot be simulated.
2. There is no log output. Because the log output level of the production environment is ERROR.
3. It cannot be tested in the production environment because the customer does not allow it.
4. The database in the production environment cannot enable snapshots and other functions. Because it will affect performance.
As you can imagine, without features such as snapshots, deadlock analysis can only rely on code analysis. But this process is very complicated, and there is no clue just by analyzing the code.
Stage 1: We suspect it is due to the amount of data
Due to the extremely large amount of data in the production environment, this process also involves the processing of many other tables. So we wonder whether the large amount of data caused the system to be overloaded, leading to deadlock?
So we obtained the load information of the CPU, hard disk, network, etc. when the deadlock occurred. No clues were found.
Phase 2: Make a test program and use multi-threading to simulate multiple users in the test environment to do this processing.
In order to reproduce this deadlock in the development environment, we made a multi-threaded test program to simulate multi-user operation. Unfortunately, it still has not been reproduced.
Phase 3: Analyze the difference between the test environment database and the product environment database
At this time we suspect that the problem is still caused by the amount of data. So we tried our best to have as much data in the development environment as in the production environment.
After running the test, it still did not reproduce.
Stage 4: Analyze the user's operation log
With no other solution, we have to analyze the user's operation log, hoping to find some clues. Hard work pays off, and we found that when two people perform this operation at the same time, a deadlock will basically occur. Therefore, we judge that the problem is caused by two people operating at the same time. However, why does the development environment simulate the operations of many people but no deadlock occurs?
Phase 5: Discovering database setting problems
We modified the test program to increase the number of simulated users, but unfortunately, the problem still did not reproduce. At this time we noticed: Are the database settings of the development environment different from the database settings of the production environment? We compared the settings of the two databases and found that many parameters were different. But we only focused on the settings related to the lock, that is, the settings containing the LOCK keyword.
Stage 6: Keep the settings of the test environment database and the production environment database consistent
We have changed all lock-related settings to be consistent with the production environment. But still the deadlock is not reproduced. Finally, a person discovered that the "cur_commit" setting was
different. So I queried the documentation and discovered the characteristics of cur_commit. When cur_commit = false, the following situations will cause a deadlock:
Thread 1 inserts data A, and then thread 2 inserts data B.
Before thread 2 has submitted the transaction, thread 1 queries data A, which will cause a deadlock.
In the development environment, cur_commit = true, so we have never been able to simulate this phenomenon.
So, we changed cur_commit to false.
Phase 7: Use the test program to simulate
We modified the test program to simulate the operations of the above two threads and successfully reproduced the deadlock. The error log information is also consistent with the production environment.
Stage 8: Use screen operations to simulate
Then we modified the program, used screen operations, and successfully reproduced the deadlock.
Solution:
The solution is very simple, that is, add the conditions in the query statement as indexes, so that deadlock will not occur.
Since the data volume of this table is not large, there is almost no impact on performance.
Detailed explanation of the python module ibm_db method for offline installation of db2
Connecting DB2 database with Python
Five ways to use PHP to operate DB2 Express C (1)_PHP tutorial
The above is the detailed content of Full record of DB2 deadlock resolution process. For more information, please follow other related articles on the PHP Chinese website!

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

Solution to the problem that Win11 system cannot install Chinese language pack With the launch of Windows 11 system, many users began to upgrade their operating system to experience new functions and interfaces. However, some users found that they were unable to install the Chinese language pack after upgrading, which troubled their experience. In this article, we will discuss the reasons why Win11 system cannot install the Chinese language pack and provide some solutions to help users solve this problem. Cause Analysis First, let us analyze the inability of Win11 system to

As smartphone technology continues to develop, mobile phones play an increasingly important role in our daily lives. As a flagship phone focusing on gaming performance, the Black Shark phone is highly favored by players. However, sometimes we also face the situation that the Black Shark phone cannot be turned on. At this time, we need to take some measures to solve this problem. Next, let us share five tips to teach you how to solve the problem of Black Shark phone not turning on: Step 1: Check the battery power. First, make sure your Black Shark phone has enough power. It may be because the phone battery is exhausted

Everyone knows that if the computer cannot load the driver, the device may not work properly or interact with the computer correctly. So how do we solve the problem when a prompt box pops up on the computer that the driver cannot be loaded on this device? The editor below will teach you two ways to easily solve the problem. Unable to load the driver on this device Solution 1. Search for "Kernel Isolation" in the Start menu. 2. Turn off Memory Integrity, and it will prompt "Memory Integrity has been turned off. Your device may be vulnerable." Click behind to ignore it, and it will not affect the use. 3. The problem can be solved after restarting the machine.

With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

Pinduoduo software provides a lot of good products, you can buy them anytime and anywhere, and the quality of each product is strictly controlled, every product is genuine, and there are many preferential shopping discounts, allowing everyone to shop online Simply can not stop. Enter your mobile phone number to log in online, add multiple delivery addresses and contact information online, and check the latest logistics trends at any time. Product sections of different categories are open, search and swipe up and down to purchase and place orders, and experience convenience without leaving home. With the online shopping service, you can also view all purchase records, including the goods you have purchased, and receive dozens of shopping red envelopes and coupons for free. Now the editor has provided Pinduoduo users with a detailed online way to view purchased product records. method. 1. Open your phone and click on the Pinduoduo icon.

The Linux Chinese garbled problem is a common problem when using Chinese character sets and encodings. Garbled characters may be caused by incorrect file encoding settings, system locale not being installed or set, and terminal display configuration errors, etc. This article will introduce several common workarounds and provide specific code examples. 1. Check the file encoding setting. Use the file command to view the file encoding. Use the file command in the terminal to view the encoding of the file: file-ifilename. If there is "charset" in the output

Title: How to solve the problem that PyCharm cannot be opened. PyCharm is a powerful Python integrated development environment, but sometimes we may encounter the problem that PyCharm cannot be opened. In this article, we'll share some common workarounds and provide specific code examples. Hope this helps those who encounter this problem. Method 1: Clear the cache Sometimes PyCharm’s cache files may cause the program to fail to open normally. We can try clearing the cache to solve this problem. Tool

How to solve the problem that the default gateway disappears automatically. In modern society, the Internet has become an indispensable part of people's lives. Whether for work or entertainment, we all need stable network connections to complete various tasks. The default gateway is one of the key elements connecting the local network to the external Internet. However, sometimes we may encounter the problem that the default gateway disappears automatically, resulting in the inability to access the Internet. So, how should we solve this problem when the default gateway disappears? First, we should clarify the concept of default gateway. The default gateway is a network route
