Problem solving

The answer is no.

In my current experience, there are two reasons for slow Sql. The first is really slow. The second is the big transaction problem

The problem’s analyse

I received two online alerts in Dingding.com near the end of work today, both of which belong to @me.

The first one was that the call to push Api timed out. I looked at it and didn’t pay much attention to it. I thought it was an accidental network congestion. The second is a slow SQL statement, and this is the same as the update statement, but the statement should hit the index, its execution must be fast, become a slow SQL statement must be occupied. But I didn’t find anything special when I looked at the code (I reconfigured the push of this module to be asynchronous). It is assumed that the resource is occupied somewhere else, causing this area to be timed out.

But after my experienced TL code analyzed the problem, the truth came out.

The problem Sql is in a message consumer code, pseudo logic as follows

// The transaction starts to modify the order information (occupy resources, other threads block) modify the corresponding order vehicle for the start push (timeout) other system index synchronization // the transaction endsCopy the code

There are 13 cars in an order, and when the 13 cars start shipping together, 13 shipping messages will be sent concurrently. When the first message is consumed, the push method times out and the 10-second timeout is returned, so other consumers will block the SQL call modified in the first sentence. It took more than 10 seconds for the other consumers to recover from the blockage. This batch of SQL becomes slow SQL.

It is interesting that the two seemingly unrelated alarms above are linked together.

In the future, I will pay more attention to online alarms. They are all learning opportunities.

The problem summary

Do not run blocking calls in transactions other than database operations, such as push, SMS, and synchronous indexing, which are asynchronously decoupled.

There’s one other company that’s really important.

The following is my public number, we can pay attention to.