[Performance Test] Summary of senior veterans, summary of common concurrency problems (2)


Preface

1. The problem of extreme value concurrency

Concurrency problems caused by extreme values, so what are extreme values?

Limit value: The limit of the numerical range required by the standard. "Limit value" is also called "limit value", "critical value", and "limit value".

Let’s take an example: there will be a lottery at a party.

The specific arrangement is: Friends who are still present from 23:00 ~ 23:59 on the day will each receive a gift;
Each person will have 3 additional lucky draw opportunities;< a i=2> Those who post to Moments can get another lottery chance; those who have already won the first prize cannot win the second and third prizes; The probability of winning is based on the predetermined probability. Calculate the estimated probability; If the number of winning prizes reaches the upper limit, the lottery must be stopped.


Concurrent test scenarios designed based on these:
① From 23:00 ~ 23:59 that day, give a gift to everyone present;
②Everyone present has 3 lucky draw opportunities;
③If you post in a high-profile circle of friends, you can have another lucky draw chance;
④Those who have already won the first prize cannot win again. Won the second and third prizes;
⑤The probability of winning is set according to the estimated probability;
⑥The number of prizes won reaches the upper limit of the number of prizes, and the award will be stopped .

In this scenario, the test objects are first analyzed: event time, number of draws, winning probability, upper limit of the number of prizes, and winning rules.

Then the designed concurrent test case coverage points are:

①Test activity: You can also participate in the lottery even if you are not within the event time;
②Number of draws: If you have not shared the circle of friends to show off, the number of draws will exceed 3 times;
③Number of draws: If you show off in a high-profile circle of friends, the number of draws is more than 1;
④Probability of winning: Set the number of decimal places that are valid for the probability of winning;
⑤ Simplify the upper limit of quantity: control the upper limit of the number of awards;
⑥ Winning rules: If you have won the first prize, can you still win the second and third prizes?

2. The problem of concurrent pressure

Concurrency problems caused by stressful loads can be classified as performance problems. Today I will talk about some isolation levels of database transactions.

There are 4 isolation levels, from low to high:

1)Read uncommitted

Unauthorized reading and uncommitted read means that transaction B reads uncommitted data of transaction A.

If a transaction has started writing data, another transaction is not allowed to write data at the same time, but other transactions are allowed to read this row of data. This isolation level can be achieved through "exclusive write lock".

This isolation level avoids lost updates, but dirty reads may occur.

2)Read comitted

Authorized read, read committed, that is, transaction A reads the data first, transaction B then updates the data and mentions the transaction, and when transaction A reads the data again, the data has changed.

The transaction that reads the data allows other transactions to continue to access the row of data, but the uncommitted write transaction will prevent other transactions from accessing the row. This isolation level avoids dirty reads, but non-repeatable reads may occur.

3)Repeatable read

can be read repeatedly. Transactions that read data will prohibit write transactions, and write transactions will prohibit any other transactions.
This isolation level avoids non-repeatable reads and dirty reads, but phantom reads may sometimes occur. This can be achieved through "shared read locks" and "exclusive write locks".

4)Serializable

Serialization, providing strict transaction isolation. It requires transactions to be executed serially, and transactions can only be executed one after another, but not concurrently.

If transaction serialization cannot be achieved only through "row-level locking", other mechanisms must be used to ensure that newly inserted data will not be accessed by the transaction that just performed the query operation.

Sequence list is the highest transaction isolation level. It is also the most expensive and has the lowest performance. It is generally rarely used. At this level, transactions will be executed in order, which not only avoids dirty reads, non-repeatable reads, but also avoids phantom reads.

3. Dirty reading

One transaction reads the uncommitted data operation results of another transaction.

Update lost
Update lost includes the following two situations:

Rollback is lost. When two transactions update the same data source, if the first transaction is committed and the other transaction is revoked, the updates made by the first transaction will also be revoked, that is, the first Updates made by the transaction are lost.

Coverage loss occurs when 2 or more transactions query the same record and then each updates the row with the original query results. Coverage loss occurs because each transaction does not know the existence of other transactions, and the last transaction does something to the record. Modifications will overwrite committed updates to the record made by other transactions.

Non-repeatable Reads
Non-repeatable Reads, a transaction reads the same row of data twice, but gets different results, including the following situations.

Virtual read: After transaction R1 reads certain data, transaction R2 modifies it. When transaction R1 reads the data again, it gets a different value.

Phantom reading: The transaction performs two queries during the operation. The result of the second query contains data that did not appear in the first query or canceled the data that appeared in the first query (the SQL statement of the two queries is not required) same). This is caused by data being inserted by another transaction during the two queries.

The default isolation level of the usual database settings is Read committed (authorized read, read committed).

4. The problem of abnormal data interfering with concurrency

Abnormal data testing for such situations can also be called system robustness testing.

The focus of testing is to construct test data that can cause abnormalities based on business logic or system-related configurations. It is required that these data cannot be treated as normal data or affect other normal data.

For example, testers build test scenarios to continuously trigger scheduled batch processing tasks. If programmers ignore the logical processing of abnormal data in the code, it will cause the database connection pool to be full, memory overflow, and abnormal data to be directly reported and interrupted (task to be executed). There are more and more queues) and other issues.

The focus of this type of concurrency testing is not on synchronized concurrency, but on the number of concurrencies that are gradually stressed.

The following is the most comprehensive software testing engineer learning knowledge architecture system diagram in 2023 that I compiled.

1. Python programming from entry to proficiency

Please add image description

2. Practical implementation of interface automation projects

Please add image description

3. Web automation project actual combat

Please add image description

4. Practical implementation of App automation project

Please add image description

5. Resumes of first-tier manufacturers

Please add image description

6. Test and develop DevOps system

Please add image description

7. Commonly used automated testing tools

Please add image description

8. JMeter performance test

Please add image description

9. Summary (little surprise at the end)

Life is full of choices and challenges, and every choice you make affects your future. Therefore, please take every decision seriously, face challenges bravely, and make your life without regrets!

Everyone has the potential to become who they want to be, it just takes enough effort and time. Therefore, please believe in your abilities, pursue your dreams bravely, use actions to prove your worth, and let the world be different because of you!

Life is like a marathon, it doesn't matter how high the starting point is, only whether the end point is reached. Therefore, please keep running, use perseverance and courage to realize your dreams, and let life be wonderful because of you!

Guess you like

Origin blog.csdn.net/shuang_waiwai/article/details/134783441