Database isolation level error checking method, device, equipment and medium
By running a set of transaction tests in the database, generating a directed graph and combining it with the processing log to generate a test report, the problem of database isolation level error checking in the existing technology that cannot fully cover users' diverse applications is solved, and efficient and accurate error checking is achieved.
Patent Information
- Application Number
- CN202111537022.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-13
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2041-12-13
AI Technical Summary
In the prior art, the error checking method of the database isolation level can only test limited transaction modes and fails to fully cover the diverse applications actually used by users, resulting in low testing efficiency.
By running a transaction test set in the database, obtaining the execution results and processing logs, generating multiple directed graphs, and generating a test report in combination with the transaction processing logs, a comprehensive error check of the database isolation level is achieved.
Improves the efficiency of database isolation level error checking, saves human resources and time, and generates more accurate test reports to avoid misjudgments.
Smart Images

Figure CN114253843B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of database technology, and in particular to a method, apparatus, device, and medium for checking errors at database isolation levels. Background Art
[0002] Database management systems, as important basic software, are widely used in many fields. With the continuous development of technology, there are more options for database system design, and the system architecture is constantly being restructured. The rapid iteration of new systems has brought new challenges to the quality management of database systems. Therefore, it is very necessary to test database systems.
[0003] Relational databases offer different isolation levels, and error checking for these levels is a key component of database system testing. Existing methods for checking database isolation levels for errors typically employ a fixed test model, examining the model's execution results and comparing them with expected results to verify their correctness. However, these methods can only test limited transaction modes, leaving untested modes unknown. Furthermore, due to the diverse applications used by users, these methods struggle to achieve comprehensive coverage, resulting in low testing efficiency. Summary of the Invention
[0004] In order to solve the above technical problems, the present disclosure provides a database isolation level error checking method, apparatus, device and medium.
[0005] In a first aspect, the present disclosure provides a method for checking errors at a database isolation level, comprising:
[0006] Run the transaction test set corresponding to the preset isolation level of the database in the database, and obtain the execution results and transaction processing logs of all transactions in the transaction test set after the run is completed;
[0007] generating a plurality of directed graphs according to the execution results and the key values corresponding to the transactions in the transaction test set;
[0008] A test report corresponding to a preset isolation level of the database is generated according to the multiple directed graphs and the transaction processing log.
[0009] Optionally, generating multiple directed graphs according to the execution results and the key values corresponding to the transactions in the transaction test set includes:
[0010] Querying the key values corresponding to each transaction in the transaction test set, and dividing each transaction according to the key values to obtain multiple key value groups;
[0011] For each key-value group in the plurality of key-value groups, determining a target directed graph corresponding to the current key-value group according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions;
[0012] Based on all target directed graphs, multiple directed graphs corresponding to the transaction test set are obtained.
[0013] Optionally, determining the target directed graph corresponding to the current key-value group according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions includes:
[0014] Determine the execution order of all target transactions based on the operations corresponding to all target transactions contained in the current key-value group and the execution results of all target transactions;
[0015] Determining the directions between corresponding target transactions according to the execution order;
[0016] Based on the pointing and all target transactions, a target directed graph corresponding to the current key-value group is generated.
[0017] Optionally, generating a test report corresponding to a preset isolation level of the database according to the multiple directed graphs and the transaction processing logs includes:
[0018] Analyzing the multiple directed graphs to determine a closed-loop directed graph;
[0019] A test report corresponding to the preset isolation level of the database is generated according to the closed-loop directed graph and the transaction processing log.
[0020] Optionally, generating a test report corresponding to a preset isolation level of the database based on the closed-loop directed graph and the transaction processing log includes:
[0021] Determining a set of transactions to be checked in the closed-loop directed graph according to a path relationship in the closed-loop directed graph;
[0022] Analyzing the transaction set to be checked according to the transaction processing log to obtain an analysis result;
[0023] Based on the analysis results, a test report corresponding to the preset isolation level of the database is generated.
[0024] Optionally, before running the transaction test set corresponding to the preset isolation level of the database in the database and obtaining the execution results of all transactions in the transaction test set and the transaction processing log after the running is completed, the method further includes:
[0025] Generating multiple transaction lines according to a preset isolation level of the database;
[0026] For each transaction line, multiple single transactions are randomly generated;
[0027] A transaction test set corresponding to the preset isolation level of the database is generated according to the multiple single transactions, the number of concurrent operations and the test cycle.
[0028] Optionally, the database preset isolation level includes at least one of read committed, repeatable, and serializable.
[0029] In a second aspect, the present disclosure provides a database isolation level error checking device, comprising:
[0030] An acquisition module is used to run a transaction test set corresponding to a preset isolation level of the database in the database, and after the run is completed, obtain the execution results and transaction processing logs of all transactions in the transaction test set;
[0031] A first generating module, configured to generate a plurality of directed graphs according to the execution result and the key value corresponding to each transaction in the transaction test set;
[0032] The second generating module is used to generate a test report corresponding to the preset isolation level of the database according to the multiple directed graphs and the transaction processing log.
[0033] Optionally, the first generation module includes:
[0034] a partitioning unit, configured to query the key values corresponding to the transactions in the transaction test set, and partition the transactions according to the key values to obtain a plurality of key value groups;
[0035] a first determining unit configured to determine, for each key-value group of the plurality of key-value groups, a target directed graph corresponding to the current key-value group according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions;
[0036] The second determining unit is configured to obtain a plurality of directed graphs corresponding to the transaction test set based on all target directed graphs.
[0037] Optionally, the first determining unit is specifically configured to:
[0038] For each key-value group in the plurality of key-value groups, determining an execution order among all target transactions according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions;
[0039] Determining the directions between corresponding target transactions according to the execution order;
[0040] Based on the pointing and all target transactions, a target directed graph corresponding to the current key-value group is generated.
[0041] Optionally, the second generation module includes:
[0042] a directed graph determining unit, configured to analyze the plurality of directed graphs and determine a closed-loop directed graph;
[0043] A report generating unit is used to generate a test report corresponding to the preset isolation level of the database based on the closed-loop directed graph and the transaction processing log.
[0044] Optionally, a report generation unit is used to:
[0045] Determining a set of transactions to be checked in the closed-loop directed graph according to a path relationship in the closed-loop directed graph;
[0046] Analyzing the transaction set to be checked according to the transaction processing log to obtain an analysis result;
[0047] Based on the analysis results, a test report corresponding to the preset isolation level of the database is generated.
[0048] Optionally, the above device further includes: a test set generation module, specifically configured to:
[0049] Before running a transaction test set corresponding to a preset isolation level of the database in the database and obtaining execution results of all transactions in the transaction test set and transaction processing logs after the running is completed, generating multiple transaction lines according to the preset isolation level of the database;
[0050] For each transaction line, multiple single transactions are randomly generated;
[0051] A transaction test set corresponding to the preset isolation level of the database is generated according to the multiple single transactions, the number of concurrent operations and the test cycle.
[0052] Optionally, the database preset isolation level includes at least one of read committed, repeatable, and serializable.
[0053] In a third aspect, the present disclosure further provides a computer device, comprising:
[0054] one or more processors;
[0055] a storage device for storing one or more programs,
[0056] When the one or more programs are executed by the one or more processors, the one or more processors implement any one of the database isolation level error checking methods described in the embodiments of the present disclosure.
[0057] In a fourth aspect, the present disclosure further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the database isolation level error checking method described in any one of the embodiments of the present disclosure.
[0058] The technical solution provided by the embodiments of the present disclosure has the following advantages over the prior art: first, a transaction test set corresponding to a preset isolation level of the database is run in the database, and after the run is completed, the execution results of all transactions in the transaction test set and the transaction processing log are obtained; then, based on the execution results and the key values corresponding to each transaction in the transaction test set, multiple directed graphs are generated; finally, based on the multiple directed graphs and the transaction processing log, a test report corresponding to the preset isolation level of the database is generated. Through the above solution, error checking of the database isolation level can be performed, the efficiency of the inspection can be improved, and human resources and time can be saved. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0060] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0061] Figure 1 This is a flowchart of a database isolation level error checking method provided by an embodiment of the present disclosure;
[0062] Figure 2A It is a flowchart of another database isolation level error checking method provided by an embodiment of the present disclosure;
[0063] Figure 2B A schematic diagram of a target directed graph in the method provided by an embodiment of the present disclosure;
[0064] Figure 3 This is a schematic diagram of the structure of a database isolation level error checking device provided by an embodiment of the present disclosure;
[0065] Figure 4 It is a structural diagram of a computer device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0066] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.
[0067] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0068] Figure 1 This is a flowchart of a database isolation level error checking method provided by an embodiment of the present disclosure. This embodiment is applicable to situations where error checking is performed on the isolation level between multiple transactions in a database. The method of this embodiment can be executed by a database isolation level error checking device, which can be implemented in hardware / or software and can be configured in a computer device. Figure 1 As shown, the method specifically includes the following:
[0069] S110: Run a transaction test set corresponding to a preset isolation level of the database in the database, and obtain execution results and transaction processing logs of all transactions in the transaction test set after the run is completed.
[0070] Among them, the isolation level can be understood as the degree to which a transaction must be isolated from resource or data changes made by other transactions. A transaction can be understood as an execution unit that accesses and may update various data items in a database, which is usually a set of operation statements. There are four database isolation levels, from low to high: Read Uncommitted, Read Committed, Repeatable Read, and Serializable. Since Read Uncommitted may occur in the case of an error, the error checking of the database isolation level in this embodiment does not consider error checking for Read Uncommitted. In this embodiment, the database preset isolation level may include at least one of Read Committed, Repeatable, and Serializable, and this embodiment does not make specific restrictions. The transaction test set can be understood as a set composed of multiple transactions used for testing. The transaction processing log can be understood as a log that records the execution process of all transactions. The execution result can be understood as the result obtained after the transaction is completed. For example, if the transaction updates the value in a table, the execution result may be: update success or update failure; if the transaction writes the value in a table, the execution result may be: write success or write failure; if the transaction reads the value in a table, the execution result may be that the value in the table is obtained or the value in the table is not obtained.
[0071] It should be noted that the database in the error check of the database isolation level in this embodiment mainly refers to a relational database, that is, a database established on the basis of a relational database model.
[0072] Specifically, in order to perform error checking on the database isolation level, it is necessary to obtain the transaction test set corresponding to the preset isolation level of the database, run the transaction test set in the corresponding database, and after the run is completed, query the database run record to obtain the execution results of all transactions in the transaction test set and the transaction processing log that records the execution process of all transactions in the transaction test set.
[0073] S120 , generating multiple directed graphs according to the execution results and the key values corresponding to the transactions in the transaction test set.
[0074] The key value can be understood as the identification information of a table in the database, and the table corresponding to the key value in the database can be determined based on the key value. A directed graph can be understood as a graph with a direction that reflects the relationship between transactions.
[0075] Specifically, after obtaining the execution results of all transactions in the transaction test set, the execution order of related transactions among all transactions and each transaction in the related transactions can be determined based on the execution results of all transactions and the key values corresponding to each transaction, so that multiple directed graphs can be generated based on the execution order of related transactions and each transaction in the related transactions.
[0076] S130: Generate a test report corresponding to a preset isolation level of the database based on the multiple directed graphs and the transaction processing logs.
[0077] The test report may include transactions with database isolation level errors in the transaction test set and the causes of the errors.
[0078] Specifically, after obtaining multiple directed graphs, the execution order between the transactions contained in the directed graphs is analyzed in combination with the transaction processing log, so that the specific transactions with errors in the database isolation level and the causes of the errors can be determined. Then, based on the specific transactions with errors and the causes of the errors, combined with the test report template, a test report corresponding to the preset isolation level of the database can be generated, which is convenient for testers to analyze and review and improve the performance of the database management system.
[0079] In this embodiment, a transaction test set corresponding to a preset isolation level of the database is first run in the database, and after the run is completed, the execution results of all transactions in the transaction test set and the transaction processing log are obtained. Then, based on the execution results and the key values corresponding to each transaction in the transaction test set, multiple directed graphs are generated. Finally, based on the multiple directed graphs and the transaction processing log, a test report corresponding to the preset isolation level of the database is generated. Through the above scheme, the database isolation level can be checked for errors, the efficiency of the check can be improved, and human resources and time can be saved.
[0080] In this embodiment, optionally, generating a test report corresponding to a preset isolation level of the database according to the multiple directed graphs and the transaction processing log may specifically include:
[0081] Analyzing the multiple directed graphs to determine a closed-loop directed graph;
[0082] A test report corresponding to the preset isolation level of the database is generated according to the closed-loop directed graph and the transaction processing log.
[0083] Specifically, since the directed graph reflects the relationship between transactions and has a direction, the directed graph may be open-loop or closed-loop. During the error checking process of the database isolation level, the open-loop directed graph usually has no errors in the database isolation level, while the closed-loop directed graph may have errors in the database isolation level. Therefore, it is necessary to analyze multiple directed graphs to determine which directed graphs have closed loops. After determining the closed-loop directed graph, it is also necessary to analyze the closed-loop directed graph in combination with the execution process related to the transactions contained in the closed-loop directed graph in the transaction processing log to determine whether there is an error in the isolation level of any transaction in the closed-loop directed graph. If an error occurs, a test report corresponding to the preset isolation level of the database is generated based on the transaction in which the error occurs. If there are no errors in all transactions, a test report is generated indicating that the transaction has passed the error check of the database isolation level, indicating that the result of this check is that all transactions have passed the check.
[0084] In this embodiment, the test report corresponding to the preset isolation level of the database is generated by the above method, which is conducive to improving the accuracy of the inspection results and preventing misjudgment.
[0085] In this embodiment, optionally, generating a test report corresponding to the preset isolation level of the database based on the closed-loop directed graph and the transaction processing log may specifically include:
[0086] Determining a set of transactions to be checked in the closed-loop directed graph according to a path relationship in the closed-loop directed graph;
[0087] Analyzing the transaction set to be checked according to the transaction processing log to obtain an analysis result;
[0088] Based on the analysis results, a test report corresponding to the preset isolation level of the database is generated.
[0089] The path relationship can be understood as the relationship between paths in a directed graph. A path can be understood as a line segment with a direction. The set of transactions to be checked can be understood as the set of transactions that may have isolation level errors.
[0090] Specifically, after obtaining a closed directed graph, transactions in the closed directed graph that may have isolation level errors can be identified based on the path relationships within the closed directed graph. Based on these transactions, a set of transactions to be checked can be obtained. After obtaining the set of transactions to be checked, each transaction included in the set of transactions to be checked is analyzed based on the transaction processing log to obtain analysis results, namely, transactions in the set of transactions to be checked that have isolation level errors. Based on the transactions that have isolation level errors, a test report corresponding to the database's preset isolation level can be generated.
[0091] In this embodiment, by analyzing each transaction to be checked included in the transaction set to be checked, the test report finally obtained is more accurate and avoids errors.
[0092] Figure 2A This is a flow chart of another database isolation level error checking method provided by the embodiment of the present disclosure. This embodiment is optimized based on the above embodiment. Optionally, this embodiment provides a detailed explanation of the process of generating multiple directed graphs. Figure 2A As shown, the method specifically includes the following:
[0093] S210: Run a transaction test set corresponding to a preset isolation level of the database in the database, and obtain execution results and transaction processing logs of all transactions in the transaction test set after the run is completed.
[0094] S220 , querying the key values corresponding to each transaction in the transaction test set, and dividing each transaction according to the key values to obtain multiple key value groups.
[0095] Specifically, since transactions are related by the same key value, by querying the key value corresponding to each transaction in the transaction test set, transactions with the same key value can be identified. Transactions with the same key value are grouped into a key value group, and multiple key value groups can be obtained based on the number of different key values.
[0096] S230 , for each key-value group in the plurality of key-value groups, determining a target directed graph corresponding to the current key-value group according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions.
[0097] The target transaction can be understood as any transaction included in the key-value group. The operation can be a write operation, a read operation, or an update operation. The target directed graph can be understood as the directed graph corresponding to each key-value group.
[0098] For each key-value group in the multiple key-value groups, each key-value group is taken as the current key-value group in turn. According to the operations corresponding to all target transactions contained in the current key-value group and the execution results of all target transactions, the dependency relationship between the target transactions can be determined, and thus the target directed graph corresponding to the current key-value group can be determined according to the dependency relationship.
[0099] For example, the dependencies between transactions may include:
[0100] 1. Write-write dependency: if transaction Tx is to write or update the value n-v1 of key n, and transaction Ty is to update the value n-v2 of key n, then Ty depends on Tx;
[0101] 2. Read-write dependency: If transaction Tx is to write or update the value n-v1 of key n, and transaction Ty is to read the value of key n, then Ty depends on Tx;
[0102] 3. Write-read dependency: If transaction Tx is: reading the value of key n, and transaction Ty is: writing or updating the value n-v1 of key n, then Ty depends on Tx.
[0103] S240: Based on all target directed graphs, obtain multiple directed graphs corresponding to the transaction test set.
[0104] Since each key-value group corresponds to a target directed graph, multiple directed graphs corresponding to the transaction test set can be obtained based on all the target directed graphs.
[0105] S250: Generate a test report corresponding to a preset isolation level of the database based on the multiple directed graphs and the transaction processing logs.
[0106] In this embodiment, a transaction test set corresponding to a preset isolation level of the database is first run in the database, and after the run is completed, the execution results of all transactions in the transaction test set and the transaction processing log are obtained. Then, the key values corresponding to each transaction in the transaction test set are queried, and each transaction is divided according to the key values to obtain multiple key value groups. Then, for each key value group in the multiple key value groups, the target directed graph corresponding to the current key value group is determined according to the operations corresponding to all target transactions contained in the current key value group and the execution results of all target transactions. Based on all the target directed graphs, multiple directed graphs corresponding to the transaction test set are obtained. Finally, a test report corresponding to the preset isolation level of the database is generated according to the multiple directed graphs and the transaction processing log. Multiple key value groups are determined according to different key values, and then multiple directed graphs are obtained. This is simple, efficient and highly accurate, which is conducive to improving the accuracy of the test report and the efficiency of the inspection, saving human resources and time.
[0107] In this embodiment, optionally, determining the target directed graph corresponding to the current key-value group according to the operations corresponding to all target transactions included in the current key-value group and the execution results of all target transactions may specifically include:
[0108] Determine the execution order of all target transactions based on the operations corresponding to all target transactions contained in the current key-value group and the execution results of all target transactions;
[0109] Determining the directions between corresponding target transactions according to the execution order;
[0110] Based on the pointing and all target transactions, a target directed graph corresponding to the current key-value group is generated.
[0111] Specifically, based on the operations corresponding to all target transactions contained in the current key-value group and the execution results of all target transactions, the dependency relationship between the target transactions can be determined, thereby obtaining the execution order between all target transactions. For example, if transaction Tx is: inserting the value n-v1 at key n, and another transaction Ty is: reading the value n-v1 of key n, then Ty depends on Tx, that is, the execution order of Tx is earlier than Ty. According to the execution order, the pointing between the corresponding target transactions can be determined. For example, if the execution order of Tx is earlier than Ty, then Tx points to Ty. After determining the pointing between the corresponding target transactions, based on the pointing and all target transactions, the target directed graph corresponding to the current key-value group can be generated.
[0112] For example, Figure 2B The schematic diagram of the target directed graph in the method provided in the embodiment of the present disclosure exemplifies a method, such as Figure 2B As shown:
[0113] Figure 2B In this example, four transactions are used to illustrate the following: insert key i value i-v1, read key i return value i-v1, read key j value without return, and insert key j value j-v1. Insert key i value i-v1 is executed earlier than read key i return value i-v1, and read key j value without return is executed earlier than insert key j value j-v1. Therefore, insert key i value i-v1 points to read key i return value i-v1, and read key j value without return points to insert key j value j-v1.
[0114] It should be noted that: in this embodiment, there is no specific limit on the number of transactions.
[0115] In this embodiment, the target directed graph is generated by the above method, which is efficient, fast, easy to operate and highly readable.
[0116] In this embodiment, optionally, before running the transaction test set corresponding to the preset isolation level of the database in the database and obtaining the execution results of all transactions in the transaction test set and the transaction processing log after the running is completed, the following steps may be specifically performed:
[0117] Generating multiple transaction lines according to a preset isolation level of the database;
[0118] For each transaction line, multiple single transactions are randomly generated;
[0119] A transaction test set corresponding to the preset isolation level of the database is generated according to the multiple single transactions, the number of concurrent operations and the test cycle.
[0120] A transaction line can be understood as the route of a transaction. A single transaction can be understood as executing one transaction at a time. In this embodiment, a single transaction primarily involves performing a non-specific operation on a non-specific key value. The non-specific key value can be any key value within a preset key value range. The non-specific operation can be either a read operation or a write operation. The preset key value range can be predefined or determined on a case-by-case basis, and this embodiment does not impose any specific limitations.
[0121] Specifically, a transaction test set can be generated based on the program written by the tester. The specific process is as follows: first, multiple transaction lines are generated based on the preset isolation level of the database. Then, for each transaction line, multiple single transactions are randomly generated, which can enrich the transaction test set. Because more concurrent operations on the same database, more complex concurrency relationships between transactions, and longer test cycles (more test cases), the generated test samples are richer. Therefore, by adjusting the number of single transactions, concurrent operations, and test cycles, a more comprehensive transaction test set can be generated.
[0122] In this embodiment, the transaction test set generated by the above method can fully cover transactions that may occur in actual applications, thereby improving the complexity and coverage of transactions and making the error checking of the database isolation level more comprehensive and covering a wider range.
[0123] Figure 3 This is a schematic diagram of a database isolation level error checking device provided by an embodiment of the present disclosure. The device is configured in a computer device and can implement the database isolation level error checking method described in any embodiment of the present application. The device specifically includes the following:
[0124] An acquisition module 310 is configured to run a transaction test set corresponding to a preset isolation level of the database in the database, and obtain the execution results and transaction processing logs of all transactions in the transaction test set after the run is completed;
[0125] A first generating module 320, configured to generate a plurality of directed graphs according to the execution result and the key value corresponding to each transaction in the transaction test set;
[0126] The second generating module 330 is configured to generate a test report corresponding to a preset isolation level of the database according to the multiple directed graphs and the transaction processing log.
[0127] In this embodiment, optionally, the first generating module 320 includes:
[0128] a partitioning unit, configured to query the key values corresponding to the transactions in the transaction test set, and partition the transactions according to the key values to obtain a plurality of key value groups;
[0129] a first determining unit configured to determine, for each key-value group of the plurality of key-value groups, a target directed graph corresponding to the current key-value group according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions;
[0130] The second determining unit is configured to obtain a plurality of directed graphs corresponding to the transaction test set based on all target directed graphs.
[0131] In this embodiment, optionally, the first determining unit is specifically configured to:
[0132] For each key-value group in the plurality of key-value groups, determining an execution order among all target transactions according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions;
[0133] Determining the directions between corresponding target transactions according to the execution order;
[0134] Based on the pointing and all target transactions, a target directed graph corresponding to the current key-value group is generated.
[0135] In this embodiment, optionally, the second generating module 330 includes:
[0136] a directed graph determining unit, configured to analyze the plurality of directed graphs and determine a closed-loop directed graph;
[0137] A report generating unit is used to generate a test report corresponding to the preset isolation level of the database based on the closed-loop directed graph and the transaction processing log.
[0138] In this embodiment, optionally, the report generating unit is specifically configured to:
[0139] Determining a set of transactions to be checked in the closed-loop directed graph according to a path relationship in the closed-loop directed graph;
[0140] Analyzing the transaction set to be checked according to the transaction processing log to obtain an analysis result;
[0141] Based on the analysis results, a test report corresponding to the preset isolation level of the database is generated.
[0142] In this embodiment, optionally, the apparatus further includes a test set generating module, specifically configured to:
[0143] Before running a transaction test set corresponding to a preset isolation level of the database in the database and obtaining execution results of all transactions in the transaction test set and transaction processing logs after the running is completed, generating multiple transaction lines according to the preset isolation level of the database;
[0144] For each transaction line, multiple single transactions are randomly generated;
[0145] A transaction test set corresponding to the preset isolation level of the database is generated according to the multiple single transactions, the number of concurrent operations and the test cycle.
[0146] In this embodiment, optionally, the database preset isolation level includes at least one of read committed, repeatable, and serializable.
[0147] The database isolation level error checking device provided by the embodiment of the present disclosure first runs a transaction test set corresponding to the preset isolation level of the database in the database, and obtains the execution results of all transactions in the transaction test set and the transaction processing log after the run is completed. Then, multiple directed graphs are generated based on the execution results and the key values corresponding to each transaction in the transaction test set. Finally, a test report corresponding to the preset isolation level of the database is generated based on the multiple directed graphs and the transaction processing log. This can perform error checking on the database isolation level, improve the efficiency of the inspection, and save human resources and time.
[0148] The database isolation level error checking device provided by the embodiment of the present disclosure can execute the database isolation level error checking method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0149] Figure 4 This is a schematic diagram of the structure of a computer device provided by an embodiment of the present disclosure. Figure 4 As shown, the computer device includes a processor 410 and a storage device 420; the number of processors 410 in the computer device can be one or more. Figure 4 In the figure, a processor 410 is used as an example; the processor 410 and the storage device 420 in the computer device can be connected via a bus or other means. Figure 4 The bus connection is taken as an example.
[0150] Storage device 420, as a computer-readable storage medium, can be used to store software programs, computer executable programs, and modules, such as the program instructions / modules corresponding to the database isolation level error checking method in the embodiments of the present disclosure. Processor 410 executes the software programs, instructions, and modules stored in storage device 420 to execute various functional applications and data processing of the computer device, thereby implementing the database isolation level error checking method provided in the embodiments of the present disclosure.
[0151] The storage device 420 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal, etc. Furthermore, the storage device 420 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some instances, the storage device 420 may further include memory remotely located relative to the processor 410, and these remote memories may be connected to the computer device via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0152] The computer device provided in this embodiment can be used to execute the database isolation level error checking method provided in any of the above embodiments, and has corresponding functions and beneficial effects.
[0153] The embodiment of the present disclosure further provides a storage medium containing computer-executable instructions, which, when executed by a computer processor, are used to implement the database isolation level error checking method provided by the embodiment of the present disclosure.
[0154] Of course, the computer executable instructions of the storage medium provided by the embodiment of the present disclosure are not limited to the method operations described above, but can also execute related operations in the database isolation level error checking method provided by any embodiment of the present disclosure.
[0155] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present disclosure can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer's floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present disclosure.
[0156] It is worth noting that in the embodiment of the above-mentioned database isolation level error checking device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this disclosure.
[0157] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0158] The foregoing description is intended only to provide specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not intended to be limited to the embodiments described herein, but rather to be construed in the broadest manner consistent with the principles and novel features disclosed herein.
Claims
1. A database isolation level error checking method, characterized in that: The method comprises: Run the transaction test set corresponding to the preset isolation level of the database in the database, and obtain the execution results and transaction processing logs of all transactions in the transaction test set after the run is completed; Querying the key values corresponding to the transactions in the transaction test set, and dividing the transactions according to the key values to obtain a plurality of key value groups, where the key values are identification information of the tables in the database; For each key-value group in the plurality of key-value groups, determining an execution order among all target transactions according to operations corresponding to all target transactions included in the current key-value group and execution results of all target transactions; Determining the directions between corresponding target transactions according to the execution order; Based on the pointing and all the target transactions, generating a target directed graph corresponding to the current key-value group; Based on all target directed graphs, multiple directed graphs corresponding to the transaction test set are obtained; Determining a set of transactions to be checked in a closed-loop directed graph based on path relationships in the closed-loop directed graph, wherein the closed-loop directed graph is obtained by analyzing the multiple directed graphs; Analyzing the transaction set to be checked according to the transaction processing log to obtain an analysis result; A test report corresponding to the preset isolation level of the database is generated according to the analysis result, wherein the test report includes: transactions in the transaction test set in which errors occur in the isolation level of the database and causes of the errors.
2. The method according to claim 1, characterized in that Generating a test report corresponding to a preset isolation level of the database according to the multiple directed graphs and the transaction processing logs includes: Analyzing the multiple directed graphs to determine a closed-loop directed graph; A test report corresponding to the preset isolation level of the database is generated according to the closed-loop directed graph and the transaction processing log.
3. The method according to claim 1, characterized in that Before running the transaction test set corresponding to the preset isolation level of the database in the database and obtaining the execution results of all transactions in the transaction test set and the transaction processing log after the running is completed, the method further includes: Generating multiple transaction lines according to a preset isolation level of the database; For each transaction line, multiple single transactions are randomly generated; A transaction test set corresponding to the preset isolation level of the database is generated according to the multiple single transactions, the number of concurrent operations and the test cycle.
4. The method according to any one of claims 1 to 3, characterized in that The database preset isolation level includes at least one of read committed, repeatable, and serializable.
5. A database isolation level error checking device, characterized in that: The device comprises: An acquisition module is used to run a transaction test set corresponding to a preset isolation level of the database in the database, and after the run is completed, obtain the execution results and transaction processing logs of all transactions in the transaction test set; a partitioning unit, configured to query a key value corresponding to each transaction in the transaction test set, and partition each transaction according to the key value to obtain a plurality of key value groups, wherein the key value is identification information of a table in the database; a first determining unit configured to determine, for each key-value group in the plurality of key-value groups, an execution order among all target transactions contained in the current key-value group based on operations corresponding to all target transactions and execution results of all target transactions; determine a directionality between corresponding target transactions based on the execution order; and generate a target directed graph corresponding to the current key-value group based on the directionality and all target transactions; A second determining unit is configured to obtain a plurality of directed graphs corresponding to the transaction test set based on all target directed graphs; A second generation module is configured to determine, based on path relationships in a closed-loop directed graph, a set of transactions to be checked in the closed-loop directed graph, where the closed-loop directed graph is obtained by analyzing the multiple directed graphs; analyze the set of transactions to be checked based on the transaction processing log to obtain analysis results; and generate, based on the analysis results, a test report corresponding to a preset isolation level of the database, the test report including: transactions in the transaction test set that have errors in the database isolation level and the causes of the errors.
6. A computer device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Database-based data processing method, apparatus and device, and readable storage medium
CN112069196A
Large-scale transaction load generation and database isolation level correctness verification system and method
CN112632105A