preface

Hello, everyone. I am a little boy picking up field snails. Have a great weekend, everyone.

As programmers, we often have to deal with bugs. It’s easy for a kid out of college or a programmer who hasn’t been on the job long enough to panic when they encounter a production problem. In fact, as we all know, hurry is useless, because hurry can not solve the problem.

Today, the field snail elder brother will talk with you about how to deal with production problems. Of course, this is as much for me as for you. I’m growing up myself.

  • Public number: a boy picking up snails

1. Adjust your mindset.

Anxiety is a normal human reaction to production problems, so what we need to do is calm down. Be sure to adjust your mindset.

Because if you are anxious like an ant on a hot pan, the leader will feel that you are not reliable in the eyes of the next important development task, I believe he will not give you, and what performance and so on, it is estimated that not where to go.

Also, it’s easy to distract yourself from solving a problem if you’re in a hurry! So encountered production problems, the need to adjust their state of mind, calm.

2. Focus on solving problems!

After adjusting our mindset, we need to focus on how to solve the problem.

If your problem is an exception reported by the monitor, you need to go through the log and analyze the log to find out what is wrong. For example, simple, whether the null pointer is abnormal; Or does not control the interface idempotent, unique index Duplicate key, etc.

If the CPU is overloaded, you can print stack information to analyze it. Jstack generates thread snapshots to analyze program exceptions, which is an essential skill for Java programmers. I wrote an article about jStack earlier, so you can take a look at it

Take a quick picture of your Java program: jStack command parsing

If it is the cause of slow SQL, we will analyze how to optimize, whether to add index, or control the amount of data in SQL, and so on.

If it’s a business complaint about a problem with the implementation of a business function, take a look at the current critical log and go back to your business code. Just take it case by case. Just calm down and figure out how to solve your problem.

3. Report solutions and analyze possible impacts

If you find out what the problem is, make a list of solutions. For example, it is the cause of slow SQL, which field to add index, or add a time range to control the amount of data and so on, you list one by one, report the solution to the superior leadership.

In addition to reporting solutions, it is also important to analyze the possible impact! Production problems will affect users. We need to analyze which users will be affected, what function points will be affected, and the remedy plan. If you have a null pointer exception that affects the customer information display, then your remedy is not to fill the number on it.

4. Love to communicate! Find leadership

The boss, though, would rather hear about your solutions than your problems. However, sometimes, due to lack of experience and other reasons, some problems will not be able to find a solution for a while. At this point, you can ask for the help of experienced programmers and your boss.

When oneself do not know how to solve, must not be a person stuffy voice over there blind think! What we want is a quick fix!

5. Technical output, summarizing production problems

After solving the production problem, it is suggested that we can write a technical summary, why this problem occurs, how to avoid solving this problem and so on.

The delete in subquery does not delete the index. Write a technical blog post to share your thoughts and make sure you don’t make the same mistakes the next time around. Before there was a technical summary of production problems, you can take a look at ha:

Production problem analysis! Delete in subquery does not move index? !

6. When developing and designing at ordinary times, overall consideration should be taken into account!

From the production problems, we can reflect on our peacetime development and design, how to think more comprehensive. Let’s take a simple example. If you need to query a user’s information, what do you do if you can’t find it? Does the code need to make a non-null judgment? For example, if you add a notification function to login and register, do you want to consider asynchrony? I have written an article about how to reduce bugs before. If you are interested, you can read it.

Talk about daily development, how to reduce bugs?

What is the big picture? In the process of development and design, it is necessary to avoid dealing with obvious bugs. And you need to think about, suppose you design your implementation this way, what might be the problem, and if there is a problem, what might be your remedy.

  • For example, if you design a new feature, if this interface is broken, will it cause the old feature to be broken? Could you add a switch or something?
  • For example, if someone sends a broadcast message, do you need to consider, if the message is lost and you don’t receive it, what will you do? Is the business acceptable? I wonder if we can compare it with last time when the message comes next time.

The last

Well, today talk so doha, I hope to help you. So when we encounter production problems, we must not panic! I’m not afraid of you saying I’m wordy, but to sum up:

  • Adjust your mindset.
  • Focus on solving problems!
  • Report the solution to your supervisor and analyze the possible impact
  • Willing to communicate! Find leadership
  • Technical output, summarize production problems
  • Peacetime development design, overall consideration!