Transaction detection methods, apparatus, computer equipment, computer-readable storage media, and computer program products

By combining timestamp information and detection axioms, transaction detection is achieved in both online and offline modes, solving the problem of low detection efficiency in existing technologies, improving the efficiency and applicability of transaction detection, and supporting flexible adaptation to multiple isolation levels.

CN123114631APending Publication Date: 2026-11-17SHENZHEN TENCENT COMP SYST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510641008.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-16
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing technologies are inefficient in transaction detection, especially with large-scale transaction history records, and lack effective online detection solutions. They also cannot meet the flexible adaptation requirements of multiple isolation levels, resulting in an imbalance between resource consumption and detection coverage.

Method used

Transaction detection is performed using timestamp information. Through dynamic adaptation between online and offline modes and combined with detection axioms, it achieves transaction detection with linear complexity, avoiding the complex construction of traditional dependency graphs and supporting detection at multiple isolation levels.

Benefits of technology

It improves the efficiency and universality of transaction detection, reduces complexity while ensuring detection accuracy, supports flexible adaptation to multiple isolation levels, has good scalability, and is suitable for data structures such as key-value pairs and lists.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114631A_ABST
    Figure CN123114631A_ABST
Patent Text Reader

Abstract

This application provides a transaction detection method, apparatus, computer device, computer program product, and computer-readable storage medium. The method includes: acquiring a preset detection mode and isolation level, wherein the detection mode is an online mode or an offline mode; determining a transaction to be detected based on the detection mode, and acquiring the transaction identifier and time information of the transaction to be detected; determining at least one detection axiom corresponding to the transaction to be detected based on the detection mode and the isolation level; and detecting the transaction to be detected based on the transaction identifier, the time information, and each of the detection axioms to obtain a detection result for the transaction to be detected. This application can improve the efficiency of transaction detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to database technology, and more particularly to a transaction detection method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] Databases need to support concurrent operations to improve performance, but the parallel execution of multiple transactions can lead to data conflicts, such as write overwriting and reading intermediate states. To control the mutual influence between these concurrent transactions and ensure data consistency and system stability, isolation level checks are required. Related technologies typically involve constructing a transaction dependency graph, and isolation level checks are performed by determining whether the graph contains cycles. However, as the scale of historical transaction records increases, the number of vertices and edges in the constructed dependency graph increases, the cost of determining whether the dependency graph is cyclic increases, the number of constraints to be processed increases, and the time spent solving the constraint set increases, resulting in low detection efficiency. Summary of the Invention

[0003] This application provides a transaction detection method, apparatus, computer device, computer-readable storage medium, and computer program product, which can improve transaction detection efficiency.

[0004] The technical solution of this application embodiment is implemented as follows:

[0005] This application provides a transaction detection method, the method comprising:

[0006] Obtain a preset detection mode and isolation level, wherein the detection mode is either online or offline.

[0007] The transaction to be detected is determined based on the detection mode, and the transaction identifier and time information of the transaction to be detected are obtained.

[0008] Based on the detection mode and the isolation level, at least one detection axiom is determined for the transaction to be detected;

[0009] Based on the identifier of the transaction to be detected, the time information, and each of the detection axioms, the transaction to be detected is detected to obtain the detection result of the transaction to be detected.

[0010] This application provides a transaction detection device, including:

[0011] The first acquisition module acquires a preset detection mode and isolation level, wherein the detection mode is either online mode or offline mode;

[0012] The first determining module is used to determine the transaction to be detected based on the detection mode, and to obtain the transaction identifier and time information of the transaction to be detected;

[0013] The second determining module is used to determine at least one detection axiom corresponding to the transaction to be detected based on the detection mode and the isolation level;

[0014] The transaction detection module is used to detect the transaction to be detected based on the transaction identifier, the time information, and each of the detection axioms, and to obtain the detection result of the transaction to be detected.

[0015] This application provides a computer device, the computer device comprising:

[0016] Memory is used to store executable instructions for a computer;

[0017] The processor, when executing computer-executable instructions stored in the memory, implements the transaction detection method provided in the embodiments of this application.

[0018] This application provides a computer-readable storage medium storing a computer program or computer-executable instructions, which, when executed by a processor, implements the transaction detection method provided in this application.

[0019] This application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, they implement the transaction detection method provided in this application.

[0020] The embodiments of this application have the following beneficial effects:

[0021] When performing transaction detection, the transaction to be detected is first determined based on the detection mode, and the transaction identifier and time information of the transaction to be detected are obtained. The detection mode can be online or offline, that is, the transaction detection method provided in this application embodiment can be applied to both online and offline modes, improving the universality of transaction detection. Then, based on the detection mode and isolation level, at least one detection axiom corresponding to the transaction to be detected is determined, realizing the dynamic adaptation of the detection axiom with the detection mode and isolation level, and the detection intensity can be switched as needed, thereby balancing resource overhead and detection coverage. Finally, based on the transaction identifier, time information and each detection axiom, the transaction to be detected is detected to obtain the detection result of the transaction to be detected. This can avoid the complex construction of traditional transaction dependency graphs, and achieve linear complexity transaction detection directly through timestamp comparison. While ensuring detection accuracy, it can significantly improve transaction detection efficiency. Moreover, by flexibly adapting to multiple isolation levels through detection axioms, when adding a new isolation level, only new detection axioms need to be defined, without modifying the overall detection framework, thus having good scalability. Attached Figure Description

[0022] Figure 1 This is a schematic diagram of the transaction detection system architecture provided in the embodiments of this application;

[0023] Figure 2 This is a schematic diagram of the structure of the server 400 provided in the embodiment of this application;

[0024] Figure 3A This is a flowchart illustrating the transaction detection method provided in an embodiment of this application;

[0025] Figure 3B This is a schematic diagram illustrating the implementation process of transaction detection based on detection axioms provided in an embodiment of this application;

[0026] Figure 4 This is a schematic diagram of the implementation process for performing a second conflict-free axiom verification on the transaction to be detected, provided in an embodiment of this application.

[0027] Figure 5 This is a schematic diagram illustrating the implementation process of re-verifying the second external consistency axiom for the detected fifth transaction, as provided in an embodiment of this application.

[0028] Figure 6 This is a schematic diagram illustrating the implementation process of timestamp-based transaction isolation level checking provided in an embodiment of this application;

[0029] Figure 7 This is a comparison chart of the SI inspection efficiency of the offline isolation level checker provided in this application embodiment with PolySI, Viper, ElleKV and Emme-SI;

[0030] Figure 8 This is a comparison chart of the offline isolation level checker provided in this application embodiment and Elle's transaction history check on a list data structure;

[0031] Figure 9 This is a comparison chart of the throughput of the online isolation level checker provided in this application embodiment and Cobra when checking SER;

[0032] Figure 10 This is a comparison chart of the memory usage of the offline isolation level checker provided in this application embodiment with other SI check tools;

[0033] Figure 11 This diagram illustrates the impact of online checks on database throughput when history is collected or not.

[0034] Figure 12 This is a diagram illustrating SI isolation level anomalies that cannot be detected by black-box tools. Detailed Implementation

[0035] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0036] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0037] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0038] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0039] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0040] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0041] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0042] 1) A database is a system for storing, managing, and retrieving structured data, typically implemented through a Database Management System (DBMS). It supports efficient querying, data persistence, concurrent access by multiple users, and data consistency.

[0043] 2) A transaction is a logical unit of database operations (such as CRUD operations) that satisfy the ACID properties: Atomicity: all operations succeed or all operations roll back; Consistency: data changes from one valid state to another; Isolation: concurrent transactions do not interfere with each other; Durability: the results are permanently saved after commit.

[0044] 3) Isolation level refers to the different settings for the degree of isolation between data visibility and modification during the execution of different transactions. The SQL standard defines four common database isolation levels, from low to high: Read Uncommitted, Read Committed, Snapshot Isolation (SI), and Serializable (SER).

[0045] 4) A timestamp is a data type that records the time when a specific event occurred.

[0046] 5) The start timestamp is a unique timestamp assigned by the system when a transaction begins execution (usually monotonically increasing, such as a logical clock or physical time). It marks the "birth time" of the transaction to determine the version of data it reads. In multi-version concurrency control, a transaction can only read data versions committed before the start timestamp (i.e., snapshot isolation).

[0047] 6) Commit timestamp refers to the timestamp assigned by the system when a transaction is successfully committed (it must be greater than the commit timestamps of all committed transactions). It marks the "effective time" of the transaction, and the modified data version is visible to other transactions. In MVCC, the commit timestamp determines the visibility boundary of data versions.

[0048] 7) Serializable, the highest isolation level, forces transactions to be executed sequentially, like a single thread, avoiding all concurrency issues.

[0049] 8) Snapshot isolation: Transactions see a static snapshot of the database at a certain point in time, and write operations are committed based on the snapshot, avoiding read blocking.

[0050] 9) Black-box testing, also known as functional testing, primarily checks whether each function of the software can be used normally. During testing, the program is treated as a black box that cannot be opened. Testing is performed through the program interface without considering the program's internal structure and characteristics to check whether the program functions correctly according to the design requirements and the specifications.

[0051] 10) White-box testing, also known as structural testing, is mainly used to detect errors in the software coding process. A programmer's programming experience, mastery of the software, and work status can all affect programming quality and lead to code errors.

[0052] 11) The detection axiom is a set of formal rules used to verify whether the execution history (Schedule) of a transaction meets the requirements of a specific isolation level (such as SI, SER). Its core objective is to determine, through mathematical logic, whether the interaction between transactions violates the isolation guarantee.

[0053] To better understand the transaction detection method provided in the embodiments of this application, the transaction detection methods provided in related technologies and their shortcomings are first explained.

[0054] In related technologies, black-box inspection is a common solution for handling transaction isolation level detection. Currently, there are one commonly used black-box inspection tool for the SER isolation level and two for the SI isolation level. The black-box inspection tool for the SER isolation level first constructs a corresponding transaction dependency graph for the transaction history to be inspected, and then determines whether the transaction history violates the SER isolation level by finding cycles. Technically, it models the transaction dependency graph as a serializable dependency graph (Polygraph), then encodes it into propositional logic formulas, and uses a dedicated MonoSAT solver to find cycles. It also prunes the serializable dependency graph and designs heuristic optimization algorithms for specific transaction types (such as read-modify-write) to further improve performance.

[0055] The first black-box inspection tool for SI isolation level modifies the serializable dependency graph, transforming it into a BC-polygraph. This allows SI inspection problems to be solved directly by determining acyclicity, similar to SER inspection problems. Viper also introduces heuristic pruning, which can significantly improve inspection efficiency when parameters are set appropriately.

[0056] The second type of black-box inspection tool targets SI isolation level. It uses a serializable dependency graph to transform the SI isolation level detection problem into a constraint solving problem. Through simplified constraint encoding and pruning techniques, it significantly reduces the number of constraints that need to be solved, achieving efficient solution of the SI inspection problem.

[0057] Besides black-box inspection, there are two other technologies that support SER and SI isolation levels. However, both of these require building a dependency graph for inspection.

[0058] The main drawbacks of the above five inspection tools include:

[0059] I. Inefficient Detection Algorithms. Theoretically, the time complexity of the three black-box detection tools mentioned above is exponential. As the scale of the transaction history increases, the detection time increases dramatically. With the increase in the scale of the transaction history, the number of vertices and edges in the constructed transaction dependency graph increases, the cost of determining whether the dependency graph is cyclic increases, the number of constraints to be processed increases, and the time spent solving the constraint set increases. All of these lead to serious performance problems. Although the two inspection tools supporting SER and SI isolation levels mentioned above are much faster than black-box tools, they still use traditional cycle detection for inspection. The process of constructing the dependency graph and detecting cycles takes a considerable amount of time when the number of transactions reaches tens of thousands, indicating room for performance optimization.

[0060] II. Lack of Solutions for Online Inspection. The first type of black-box inspection tool is currently the only tool that supports online inspection, and it only supports the SER isolation level. It requires periodically adding a fence transaction between transactions to completely separate the two batches of transactions before online inspection can be performed, which is often unacceptable in production environments. Furthermore, this type of inspection tool requires that the transaction history not have too many write transactions when performing online inspections. This is because the graph nodes corresponding to write transactions cannot be reclaimed; as transactions increase, the graph grows larger and larger, leading to memory overflow and program termination.

[0061] Third, the executed transactions are subject to certain restrictions. The aforementioned checking tools require transactions to meet the constraint of unique write values, meaning that at most one transaction performs a write operation on the same key-value pair, and no two different transactions write the same value on the same key. These tools rely on key-value pairs to construct dependency graphs, and unique write values ​​ensure that a certain type of edge in the dependency graph is known and definite; otherwise, the number of constraints would increase significantly.

[0062] The three technical issues mentioned above limit the application scenarios of existing tools. When the transaction history is large, black-box tools are inadequate, and white-box tools will spend a lot of time building complex dependency graphs. Currently, almost all tools perform offline checks, and there is no mature implementation solution for incremental online checks. Moreover, most existing check algorithms require the restriction of unique write values.

[0063] To address the aforementioned technical issues, this application's embodiments utilize timestamp-related information to design general-purpose and efficient offline and online inspection algorithms and tools, ensuring theoretical reliability and completeness. Furthermore, the transaction detection method provided in this application's embodiments is not limited to key-value pair storage but can be extended to data structures such as lists and sets.

[0064] This application provides a transaction detection method, apparatus, device, computer-readable storage medium, and computer program product, which can perform online and offline checks on the isolation level of transactions through timestamps, thereby reducing the complexity and improving the efficiency of transaction detection. The following describes exemplary applications of the computer device provided in this application. The computer device provided in this application can be implemented as various types of terminals such as laptops, tablets, desktop computers, set-top boxes, smartphones, smart speakers, smartwatches, smart TVs, and vehicle terminals, or it can be implemented as a server. The following describes exemplary applications when the device is implemented as a server.

[0065] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of the transaction detection system 100 provided in the embodiment of this application. In order to support a transaction detection application, the terminal 200 connects to the server 400 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.

[0066] When server 400 determines that the transaction detection start condition is met, it obtains a preset detection mode and isolation level. The transaction detection start condition can be receiving a transaction detection command sent by terminal 200, reaching a preset transaction detection cycle, or detecting a preset transaction detection trigger event. The detection mode can be online or offline, meaning the transaction detection method provided in this embodiment can perform online or offline detection. Then, based on the detection mode, the transaction to be detected is determined, and the transaction identifier and time information of the transaction to be detected are obtained from database 500. Based on the detection mode and the isolation level, at least one detection axiom corresponding to the transaction to be detected is determined. Finally, based on the transaction identifier, the time information, and each detection axiom, the transaction to be detected is detected to obtain the detection result. Server 400 can send the detection result of the transaction to be detected to terminal 200, and terminal 200 receives and displays the detection result.

[0067] In some embodiments, server 400 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminals and servers can be connected directly or indirectly via wired or wireless communication, which is not limited in this embodiment.

[0068] See Figure 2 , Figure 2 This is a schematic diagram of the structure of the server 400 provided in this embodiment of the application. Figure 2 The server 400 shown includes at least one processor 410, memory 450, at least one network interface 420, and a user interface 430. The various components in server 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to implement communication between these components. In addition to a data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 2 The general labeled all buses as Bus System 440.

[0069] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0070] User interface 430 includes one or more output devices 431 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0071] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices physically located away from the processor 410.

[0072] The memory 450 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 450 described in this application embodiment is intended to include any suitable type of memory.

[0073] In some embodiments, memory 450 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.

[0074] Operating system 451 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;

[0075] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc.

[0076] Presentation module 453 is configured to enable the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 (e.g., a display screen, a speaker, etc.) associated with user interface 430;

[0077] The input processing module 454 is used to detect and translate one or more user inputs or interactions from one or more input devices 432.

[0078] In some embodiments, the apparatus provided in this application can be implemented in software. Figure 2 A transaction detection device 455 stored in memory 450 is shown. This device can be software in the form of programs or plug-ins, and includes the following software modules: a first acquisition module 4551, a first determination module 4552, a second determination module 4553, and a transaction detection module 4554. These modules are logically linked and can therefore be arbitrarily combined or further divided according to their implemented functions. The functions of each module will be described below.

[0079] In other embodiments, the apparatus provided in this application can be implemented in hardware. As an example, the apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the transaction detection method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0080] The transaction detection method provided in this application will be described in conjunction with exemplary applications and implementations of the server provided in the embodiments of this application.

[0081] The transaction detection method provided in the embodiments of this application will be described below. As mentioned above, the electronic device implementing the transaction detection method of the embodiments of this application can be a terminal, a server, or a combination of both. Therefore, the executing entity of each step will not be described again below.

[0082] The transaction detection method provided in this application can be applied to resource transaction scenarios. It detects transactions generated in the resource database to determine whether the transactions meet the preset isolation level, thereby ensuring the atomicity and consistency of transaction operations and avoiding dirty reads or non-repeatable reads that could lead to incorrect resource quantities. The transaction detection method provided in this application can also be applied to e-commerce inventory management systems to check transactions in the inventory database to determine whether the transactions meet the preset isolation level, thereby avoiding inventory deduction conflicts and preventing situations where sales exceed inventory.

[0083] See Figure 3A , Figure 3A This is a flowchart illustrating the transaction detection method provided in the embodiments of this application, which will be combined with... Figure 3A The steps shown are explained below. Figure 3A The main component of the process is the server.

[0084] In step 101, the preset detection mode and isolation level are obtained.

[0085] The detection mode can be either online or offline. Online mode detects transactions currently in progress, while offline mode detects transactions that have already been executed. Isolation levels include at least a first isolation level and a second isolation level, with the second isolation level being higher than the first. For example, the first isolation level could be a snapshot isolation level, and the second isolation level could be a serializable isolation level. The core idea of ​​snapshot isolation is that each transaction reads data from a snapshot of the database; that is, all data seen by the transaction is data committed before the start of the transaction. If some data is changed by other transactions after the current transaction starts, snapshot isolation ensures that the current transaction cannot see this new value. Therefore, snapshot isolation perfectly solves the concurrency problem of "non-repeatable reads." Serializable isolation is a very strict isolation level that requires that the execution result of a transaction must be completely consistent with the result of executing it serially in a certain order. To achieve this isolation level, the database forces transactions to be completely isolated from other transactions during execution, ensuring no concurrency conflicts. If a potential conflict is detected, the database will abort the transaction and request a retry. Serializable isolation is typically used in scenarios with extremely high data consistency requirements. Although it has a higher performance overhead, it can provide the strongest data consistency guarantee in high-concurrency environments.

[0086] In step 102, the transaction to be detected is determined based on the detection mode, and the transaction identifier and time information of the transaction to be detected are obtained.

[0087] In some embodiments, when the detection mode is online, the currently executing first transaction can be identified as the transaction to be detected; when the detection mode is offline, the transaction to be detected can be determined based on multiple executed second transactions obtained from the database log. The second transaction is a historical transaction formed by parsing and storing executed transactions in memory. Further, when the isolation level is the first isolation level, the start timestamps and commit timestamps of multiple second transactions are obtained. The start timestamp is a unique logical timestamp assigned by the database system at the start of the transaction, identifying the "birth time" of the transaction. The start timestamp can be a monotonically increasing integer, a physical clock, or a Hybrid Logical Clock (HLC). The start timestamp can be used to determine data visibility and conflict detection, and it is also a global sorting criterion. The commit timestamp is a logical timestamp assigned by the database system when the transaction is successfully committed, identifying the "effective time" of the transaction. The commit timestamp can be used to mark data version visibility; modifications made by a transaction are only visible to other transactions after the commit timestamp, thus ensuring atomicity. The submission timestamp can be a monotonically increasing integer, a physical clock, or a mixed logic clock. In this embodiment, the start timestamp and the submission timestamp have the same form.

[0088] After obtaining the start timestamps and commit timestamps of multiple second transactions, regardless of the type of timestamp, the multiple start timestamps and commit timestamps are sorted in chronological order to obtain the first timestamp sequence. Then, the first timestamp sequence is traversed, and the second transaction corresponding to each first timestamp in the first timestamp sequence is identified as the transaction to be detected.

[0089] For example, the start timestamp and commit timestamp are represented by incrementing integers, and two second transactions are obtained, namely T. 21 and T 22 T 21 The start timestamp is 150, the commit timestamp is 180, and T 22 The start timestamp is 160, T 22 If the commit timestamp is 170, then the first timestamp sequence is 150, 160, 170, 180. Traversing the first timestamp sequence, the first timestamp is 150, and the transaction corresponding to this timestamp is T. 21 Then the first transaction to be detected is T. 21 The second first timestamp is 160, and the transaction corresponding to this first timestamp is T. 22 Then the second transaction to be detected is T. 22 The third first timestamp is 170, and the transaction corresponding to this first timestamp is T. 22 Then the third transaction to be detected is T. 22The fourth first timestamp is 180, and the transaction corresponding to this first timestamp is T. 21 The fourth transaction to be detected is T. 21 .

[0090] When the isolation level is level 2, the commit timestamps of multiple second transactions are obtained and sorted chronologically to obtain a second timestamp sequence. The second transaction corresponding to each second timestamp in the second timestamp sequence is identified as the transaction to be detected. In other words, when the isolation level is level 2, the start timestamp is ignored, and only the commit timestamps are sorted to obtain the second timestamp sequence. The second timestamp sequence is then traversed to determine each transaction to be detected.

[0091] In some embodiments, the second isolation level (SER) is a more stringent isolation level, requiring strict total order visibility between transactions. Therefore, for SER checks, it is only necessary to assume that transactions do not conflict with each other and determine the global serial execution order based on the commit timestamp. In this case, the start timestamp of the transaction has no effect and can be ignored.

[0092] Following the example above, regarding T 21 and T 22 Sort the commit timestamps to obtain the second timestamp sequence 170, 180. Traverse the second timestamp sequence to obtain the first transaction to be detected, T. 22 The second transaction to be detected is T. 21 .

[0093] In step 102, for offline mode, after obtaining the start and commit timestamps of transactions, all timestamps can be sorted in ascending order. By simulating transactions starting or committing in chronological order, each transaction is checked sequentially to ensure it meets the preset detection axioms, guaranteeing the reliability and completeness of the detection results. For online mode, transactions in execution are treated as those to be detected, enabling incremental detection and improving the real-time performance of transaction detection.

[0094] In step 103, based on the detection mode and isolation level, at least one detection axiom corresponding to the transaction to be detected is determined.

[0095] Before explaining the implementation process of step 103, the definitions of transactions, history, and abstract execution will be explained first.

[0096] A transaction is a tuple (O, po), where O is a set of operations (e.g., read and write operations), and po is the program order on O, that is, the execution order of the operations in O, which is a strict total order. Strict total order guarantees the consistency of a transaction as a logical unit and is the theoretical foundation for achieving Atomicity and Isolation in ACID.

[0097] history It is a pair, where It is a collection of transactions, SO is The order of conversations, i.e. The order of transactions within their respective sessions is a partial order. SO is a partial order, meaning that transactions in different sessions do not need to be in total order (unless there is an explicit dependency), which provides room for concurrency optimization (such as executing conflict-free transactions in parallel). It is a collection of all transactions executed concurrently. SO only constrains the commit order of transactions within the same session. Transactions between different sessions can run concurrently if they have no dependencies. This flexibility is the basis for efficient concurrency control.

[0098] Abstract execution It is a quadruple, in which It refers to history. VIS represents the visibility relationship in history, which is a partial order. If (T1, T2) ∈ VIS, then transaction T2 can see the modifications made by transaction T1 (i.e., T1's writes are visible to T2). Therefore, T2 cannot read any writes made by T1 (even if T1 has committed). The VIS determines which transaction writes a transaction's read operations can observe. For example, in SI, transaction T can only see transactions committed before it started (i.e., the VIS includes all transactions committed before T started). In SER, the VIS must guarantee consistent reads across all transactions (to avoid write skew).

[0099] For example, T1 writes X = 1 and commits. T2 reads X. If (T1, T2) ∈ VIS, then T2 reads X = 1; otherwise, it may read the old value X = 0.

[0100] AR represents historical arbitration relationships, which is a strict total order, and AR represents the global commit order of transactions. If (T1, T2) ∈ AR, then T1 commits before T2 in the global order. Strict total order means: not reflexive. (A transaction cannot be committed before itself). Fully comparable: For any two different transactions T1 and T2, either (T1,T2)∈AR or (T2,T1)∈AR (they cannot both be true at the same time).

[0101] For example, T1 writes X=1, and T2 writes X=2. If (T1,T2)∈AR, then the final X=2 (T2 overwrites T1).

[0102] In this embodiment of the application, when the detection mode is offline mode and the isolation level is the first isolation level, if the first timestamp corresponding to the transaction to be detected is the start timestamp, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the first internal consistency axiom (INT), and the first external consistency axiom (EXT), wherein:

[0103] SESSION axiom requirements In other words, earlier transactions in the same session should be visible to later transactions.

[0104] The INT axiom states that within a transaction, if there are multiple reads or writes on a key, then all operations except the first read or write should return the value of the previous read or write on that key.

[0105] The EXT axiom requires that when a transaction first reads a key that it has not written to, it should read the last of the AR order in the transactions it is visible to.

[0106] If the first timestamp corresponding to the transaction to be detected is the commit timestamp, the detection axiom corresponding to the transaction to be detected includes the first conflict-free axiom (NOCONFLICT). The NOCONFLICT axiom requires that if two transactions write to the same key, they cannot be concurrent, that is, one of them must be visible to the other. In other words, in offline mode and with the isolation level at the first isolation level, when determining the transaction to be detected, the first timestamp sequence is obtained by sorting the start timestamp and commit timestamp in ascending order, and then traversing the first timestamp sequence. Since each transaction corresponds to one start timestamp and one commit timestamp, the same transaction may be detected twice. However, the detection axioms corresponding to different types of timestamps are different. This avoids repeatedly performing the same axiom on the same transaction to be detected, thereby ensuring the efficiency of transaction detection.

[0107] When the detection mode is offline mode and the isolation level is the second isolation level, the detection axioms corresponding to the transaction to be detected include the session axiom, the first internal consistency axiom, and the first external consistency axiom.

[0108] Since the second isolation level is higher than the first isolation level, and the second isolation level requires that the execution result of a transaction must be completely consistent with the result of executing it serially in a certain order, there will be no write conflict caused by two transactions writing different values ​​to the same key. Therefore, it is not necessary to check the conflict-free axiom under the second isolation level.

[0109] In some embodiments, when the detection mode is online mode and the isolation level is the first isolation level, the detection axioms corresponding to the transaction to be detected include the session axiom, the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom.

[0110] When the detection mode is online mode and the isolation level is the second isolation level, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the second internal consistency axiom, and the second external consistency axiom, and the second isolation level is higher than the first isolation level.

[0111] It should be noted that the principles of the second internal consistency axiom, the second external consistency axiom, and the first conflict-free axiom in online mode are the same as those in offline mode. The difference lies in the source of the data to be tested.

[0112] In the above embodiments, different detection axioms are set for different isolation levels under different detection modes. If it is determined by detecting transaction-related data that the set detection axioms are satisfied, then it is equivalent to satisfying the corresponding isolation level. This allows for precise constraints on the interaction behavior between transactions through formal rules, thereby achieving a controllable trade-off between performance and consistency. This not only avoids excessive constraints on low isolation levels and improves detection efficiency, but also ensures the completeness of axiom detection for high isolation levels and improves the accuracy of detection results.

[0113] In step 104, the transaction to be detected is detected based on the identifier of the transaction to be detected, the time information, and each detection axiom, and the detection result of the transaction to be detected is obtained.

[0114] In some embodiments, the transaction identifier to be detected can be a transaction sequence number. The transaction sequence number is a unique sequence number assigned to a transaction after it is generated. The transaction sequence number clarifies the order of transactions and resolves conflicts between concurrent transactions. Time information includes a start timestamp and a commit timestamp. See also Figure 3B The above step 104 can be achieved through the following steps 1041 to 1043, in conjunction with the following... Figure 3B Please provide an explanation.

[0115] In step 1041, for each detection axiom, the data to be detected corresponding to the detection axiom is determined based on the transaction identifier and time information to be detected.

[0116] In some embodiments, different detection axioms require different detection data due to different detection rules. When the detection axiom is a session axiom, the historical commit timestamp and historical transaction identifier of the previous transaction of the transaction to be detected are obtained. The transaction identifier, the start timestamp of the transaction to be detected, the historical commit timestamp of the previous transaction, and the historical transaction identifier are determined as the detection data corresponding to the session axiom. The previous transaction of the transaction to be detected refers to the last transaction executed before the transaction to be detected within the same session. In practical applications, the sequence number (sno) and commit timestamp (commit_ts) of the last transaction processed in each session can be recorded using the variables last_sno and last_cts, respectively. Therefore, the values ​​of variables last_sno and last_cts can be obtained, thus obtaining the historical transaction identifier and historical commit timestamp of the previous transaction of the transaction to be detected. The transaction identifier, the start timestamp of the transaction to be detected, the historical commit timestamp of the previous transaction, and the historical transaction identifier are determined as the detection data corresponding to the session axiom.

[0117] When the axiom to be detected is the first internal consistency axiom, it indicates that the internal consistency axiom is being detected in offline mode. In this case, the operation information set of the transaction to be detected is obtained based on the transaction identifier. The first target operation information is determined from this set; the first target operation information is the operation information for a non-first read operation on the first target key. The first target operation information includes the first target key being read and the first read value of the first target key. The first value corresponding to the first target key is obtained from the first internal list. The first target operation information and the first value are then determined as the data to be detected corresponding to the first internal consistency axiom. In some embodiments, the first internal list can be a global hash table int_val, which records the latest internal read or write value for each key by each transaction.

[0118] In some embodiments, when determining the first target operation information from the operation information set, the operation information set can be traversed, and it can be determined in turn whether the traversed operation information is a read operation. If it is a read operation, the key corresponding to the read operation is obtained, and the number of reads of the key is obtained. When the number of reads is greater than 0, it means that it is not the first read operation of the key, that is, an internal read. Then the operation information is determined as the first target operation information. When the number of reads is 0, it means that it is the first read operation of the key, and the operation information set is traversed again.

[0119] When the axiom to be detected is the first external consistency axiom, it indicates that the external consistency axiom is being detected in offline mode. In this case, the operation information set of the transaction to be detected is obtained based on the transaction identifier. Second target operation information is determined from this set, which is the operation information for the first read operation on the second target key. The second target operation information includes at least the second target key and its second read value. The second value corresponding to the second target key is obtained from the first external list. The second target operation information and its second value are then determined as the data to be detected corresponding to the first external consistency axiom. The first external list can be a global hash table frontier, which records the keys and values ​​corresponding to the read and write operations of all committed transactions to date.

[0120] In some embodiments, when the axiom to be detected is the first conflict-free axiom, it indicates that the conflict-free axiom is being detected in offline mode. Step 1041, in its implementation, involves obtaining the operation information set of the transaction to be detected based on the transaction identifier; traversing the operation information set; when encountering third target operation information, adding the third target key and the transaction identifier to the first run list; the third target operation information is the operation information for a write operation on the third target key; the third target operation information includes the third target key and the first write value of the third target key; when the transaction to be detected is determined to be committed, the third target key and the transaction identifier are deleted from the first run list, resulting in an updated first run list; the updated first run list is then determined as the data to be detected corresponding to the first conflict-free axiom. The first run list is also a global hash table, recording the key and transaction identifier when an uncommitted transaction performs a write operation. When a transaction is committed, the key written by that transaction and the transaction itself are deleted from the first run list, resulting in an updated first run list.

[0121] The following describes the process of acquiring the data to be tested in online mode when the detection axioms are the session axiom, the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom. Specifically, the process of acquiring the data to be tested corresponding to the session axiom in online mode is the same as in offline mode. The process of acquiring the data to be tested corresponding to the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom is similar to the verification process of the first internal consistency axiom, the first external consistency axiom, and the first conflict-free axiom. The difference is that in online mode, the second internal list, the second external list, and the second running list are not global hash tables, but local hash tables indexed by transaction commit timestamps or transaction identifiers. That is, each transaction corresponds to one second internal list, one second external list, and one second running list, which will be explained in detail below.

[0122] When the axiom to be detected is the second internal consistency axiom, step 1041, in its implementation, obtains the operation information set of the transaction to be detected based on the transaction identifier, determines the fourth target operation information from the operation information set, the fourth target operation information is the operation information of the first read operation for the fourth target key, the fourth target operation information includes at least the fourth target key and the third read value corresponding to the fourth target key; determines the previous committed transaction of the transaction to be detected based on the time information, and obtains the fourth value corresponding to the fourth target key from the second internal list corresponding to the previous committed transaction; and determines the fourth target operation information and the fourth value as the data to be detected corresponding to the second internal consistency axiom.

[0123] In some embodiments, when determining the previous committed transaction of the transaction to be detected based on time information, the start timestamp of the transaction to be detected is obtained from the time information, and then the largest historical commit timestamp less than the start timestamp is found from the second timestamp sequence. The transaction corresponding to the largest historical commit timestamp is determined as the previous committed transaction of the transaction to be detected. Then, based on the transaction identifier or historical commit timestamp of the previous committed transaction, the second internal list corresponding to the previous committed transaction is obtained. The second internal list records the latest read or write values ​​of each key after the previous committed transaction has been committed.

[0124] When the axiom to be detected is the second external consistency axiom, in step 1041, the operation information set of the transaction to be detected is obtained based on the transaction identifier. The fifth target operation information is determined from this set. The fifth target operation information is the operation information for a non-first read operation on the fifth target key. The method for determining the fifth target operation information is similar to that for determining the second target operation information. Then, the previous committed transaction of the transaction to be detected is determined based on the time information, and the fifth value corresponding to the fifth target key is obtained from the second external list corresponding to the previous committed transaction. The fifth target operation information and the fifth value are then used to determine the data to be detected corresponding to the second external consistency axiom. Here, the method for obtaining the second external list is the same as that for obtaining the second internal list; it is retrieved based on the historical commit timestamp or transaction identifier of the previous committed transaction.

[0125] When the axiom to be tested is the second conflict-free axiom, see [reference needed]. Figure 4 Step 1041 can be achieved through steps 411 to 415 below, in conjunction with... Figure 4 Please provide an explanation.

[0126] In step 411, the previous committed transaction of the transaction to be detected is determined based on the time information.

[0127] In some embodiments, based on the start timestamp of the transaction to be detected, the largest commit timestamp less than the start timestamp is found from the third timestamp sequence, and then the transaction corresponding to the largest commit timestamp is determined as the previous committed transaction of the transaction to be detected. The third timestamp sequence includes the start timestamp and commit timestamp of the detected transactions, and the timestamps in the third timestamp sequence are arranged in ascending order.

[0128] For example, the start timestamps of the transactions to be detected are 200, 20, 30, 50, 80, 130, 150, 170, and 220. At this time, we can start from 170 and traverse backward to determine whether the timestamp encountered is the commit timestamp. If the timestamp encountered is the start timestamp, then we continue to traverse backward until we encounter the commit timestamp. Assuming that 170 is the commit timestamp, then the transaction corresponding to 170 is determined as the previous committed transaction of the transaction to be detected.

[0129] In step 412, the set of operation information of the transaction to be detected is obtained based on the identifier of the transaction to be detected.

[0130] Here, the operation information set includes read operation information, write operation information, etc., during the execution of the transaction to be detected.

[0131] In step 413, the operation information set is traversed. When the sixth target operation information is encountered, the sixth target key and the transaction identifier to be detected in the sixth target operation information are added to the second run list corresponding to the previous committed transaction.

[0132] The sixth target operation information is the operation information for the write operation, and the sixth target operation information includes at least the sixth target key and the second write value for the sixth target key.

[0133] In step 414, when it is determined that the transaction to be detected has been committed, the sixth target key and the identifier of the transaction to be detected are deleted from the second run list to obtain the updated second run list.

[0134] The second run list is a local hash table indexed by either the transaction commit timestamp or the transaction identifier. It records the keys and transaction identifiers of uncommitted transactions when they perform write operations. When a transaction is committed, the key written by that transaction, along with the transaction itself, is removed from the second run list, resulting in an updated second run list.

[0135] In step 415, the updated second run list is determined as the data to be detected corresponding to the second conflict-free axiom.

[0136] When testing the second conflict-free axiom, it is only necessary to verify whether the updated second run list is empty to determine whether there are transactions with parallel write conflicts. Therefore, it is only necessary to determine the updated second run list as the data to be tested corresponding to the second conflict-free axiom, which can effectively reduce the complexity of transaction detection.

[0137] In the above steps, for different detection axioms, the corresponding data to be detected is determined based on the conditions for the validity of each detection axiom, thereby providing the necessary and accurate data foundation for the subsequent transaction detection process, without the need to construct a complex transaction dependency graph. Under the premise of ensuring the accuracy of the detection results, the efficiency of transaction detection can be greatly improved.

[0138] In step 1042, the transaction to be detected is detected based on the data to be detected, and the detection sub-result of the transaction to be detected against the detection axiom is obtained.

[0139] In some embodiments, when the detection axiom is the session axiom, the transaction identifier to be detected, the start timestamp of the transaction to be detected, the historical commit timestamp of the previous transaction, and the historical transaction identifier are determined as the data to be detected corresponding to the session axiom. The session axiom requires that the transaction identifier to be detected is the historical transaction identifier of the previous transaction plus a first preset value, and the start timestamp of the transaction to be detected is greater than the historical commit timestamp of the previous transaction. Therefore, when implementing step 1042, if the difference between the transaction identifier to be detected and the historical transaction identifier is the first preset value, and the start timestamp of the transaction to be detected is greater than the historical commit timestamp, it indicates that the session axiom is satisfied, that is, the detection sub-result of the transaction to be detected for the session axiom is determined to be a successful detection; if the difference between the transaction identifier to be detected and the historical transaction identifier is not the first preset value, or the start timestamp of the transaction to be detected is less than or equal to the historical commit timestamp, it indicates that the transaction to be detected does not satisfy the session axiom, that is, the detection sub-result of the transaction to be detected for the session axiom is determined to be a failed detection.

[0140] The first preset value is generally set to 1, which means the difference between the identifier of the transaction to be detected and the identifier of the historical transaction is 1. Assuming the identifier of the historical transaction is 001, the identifier of the transaction to be detected is 002, the commit timestamp of the previous transaction is 170, and the start timestamp of the transaction to be detected is 175, then it means that the transaction to be detected satisfies the session axiom, that is, the detection sub-result of the transaction to be detected according to the session axiom is that the detection passes.

[0141] In some embodiments, when the axiom to be detected is the first internal consistency axiom, the data to be detected includes the first target operation information and the first value. When implementing step 1042, the first read value of the first target key is obtained from the first target operation information. When the first read value and the first value are the same, it indicates that the first internal consistency axiom is valid. Therefore, the detection sub-result of the transaction to be detected against the first internal consistency axiom is determined to be a successful detection. When the first read value and the first value are different, it indicates that the first internal consistency axiom is not valid. Therefore, the detection sub-result of the transaction to be detected against the first internal consistency axiom is determined to be a failed detection.

[0142] In some embodiments, when the axiom to be detected is the first external consistency axiom, the data to be detected includes the second target operation information and the second value. When implementing step 1042, the second read value of the second target key is obtained from the second target operation information; and it is determined whether the second read value and the second value are the same. When the second read value and the second value are the same, it indicates that the external consistency axiom is valid. At this time, the detection sub-result of the transaction to be detected against the first external consistency axiom is determined to be a successful detection. When the second read value and the second value are different, it indicates that the external consistency axiom is not valid. At this time, the detection sub-result of the transaction to be detected against the first external consistency axiom is determined to be a failed detection.

[0143] In some embodiments, when the axiom to be detected is the first conflict-free axiom, the data to be detected is the updated first run list. In the implementation of step 1042, it is determined whether the updated first run list is empty. If the updated first run list is empty, it means that there are no other transactions on the key corresponding to the write operation, that is, no concurrent write operations have occurred on the same key. Then the first conflict-free axiom holds, and the detection sub-result of the transaction to be detected against the first conflict-free axiom is determined to be a successful detection. If the updated first run list is not empty, it means that there are other transactions on the key corresponding to the write operation, that is, concurrent write operations have occurred on the same key. Then the first conflict-free axiom does not hold, and the detection sub-result of the transaction to be detected against the first conflict-free axiom is determined to be a failed detection.

[0144] The above describes the implementation process of verifying the session axiom, the first internal consistency axiom, the first external consistency axiom, and the first conflict-free axiom for the transaction to be tested in offline mode. Furthermore, when verifying the first internal consistency axiom, the first external consistency axiom, and the first conflict-free axiom, the operation information set of the transaction to be tested can be traversed. When a non-first read operation is encountered, the first internal consistency axiom is verified; when the first read operation is encountered, the first external consistency axiom is verified; and when a write operation is encountered, the first conflict-free axiom is verified.

[0145] In some embodiments, in offline mode, when traversing the first timestamp sequence or the second timestamp sequence and reaching the commit timestamp of the transaction to be detected, it is determined that the transaction to be detected has been committed. At this time, the first internal list and the first external list are updated, that is, the first write value of the third target key is obtained from the third target operation information, and the value of the third target key in the first internal list is updated to the first write value; the value of the third target key in the first external list is also updated to the first write value. In this way, the first internal list and the first external list store the latest value of the third target key, thereby ensuring the validity of the write operation and data consistency.

[0146] The following describes the implementation process of verifying the session axiom, the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom for the transaction under test in online mode. The verification process for the session axiom in online mode is the same as that in offline mode. The verification process for the second internal consistency axiom is similar to that of the first internal consistency axiom. The difference lies in that, when verifying the second internal consistency axiom, the data to be tested is obtained from the second internal list corresponding to the previous committed transaction of the transaction under test. This will be explained in detail below.

[0147] When the axiom to be tested is the second internal consistency axiom, in step 1042, the third read value of the fourth target key is obtained from the fourth target operation information, and it is determined whether the third read value and the fourth value are the same. When the third read value and the fourth value are the same, it means that the third read value is the latest value of the fourth target key, that is, the second internal consistency axiom is true, and the detection sub-result of the transaction to be tested against the second internal consistency axiom is determined to be a successful test. When the third read value and the fourth value are different, it means that the third read value is not the latest value of the fourth target key, that is, the second internal consistency axiom is not true, and the detection sub-result of the transaction to be tested against the second internal consistency axiom is determined to be a failed test.

[0148] When the axiom to be detected is the second external consistency axiom, in step 1042, the fourth read value of the fifth target key is obtained from the fifth target operation information, and it is determined whether the fourth read value and the fifth value are the same. When the fourth read value and the fifth value are the same, it means that the fourth read value is the same as the latest value of the fifth target key, that is, the second external consistency axiom is true. Therefore, the detection sub-result of the transaction to be detected for the second external consistency axiom is determined to be a successful detection. When the fourth read value and the fifth value are different, it means that the fourth read value is different from the latest value of the fifth target key, that is, the second external consistency axiom is not true. Therefore, the detection sub-result of the transaction to be detected for the second external consistency axiom is determined to be a failed detection.

[0149] When the axiom to be tested is the second conflict-free axiom, in step 1042, it is determined whether the updated second run list is empty. If the updated second run list is empty, it means that there is no parallel write conflict of multiple transactions for the sixth target key, the second conflict-free axiom is true, that is, the detection sub-result of the transaction to be tested according to the second conflict-free axiom is determined to be a successful test. If the updated second run list is not empty, it means that there is a parallel write conflict of multiple transactions for the sixth target key, the second conflict-free axiom is not true, therefore the detection sub-result of the transaction to be tested according to the second conflict-free axiom is determined to be a failed test.

[0150] In step 1043, the detection result of the transaction to be detected is determined based on each detection sub-result.

[0151] In some embodiments, when every check sub-result corresponding to the transaction to be detected passes the check, the transaction to be detected is determined to have passed the check; when any check result corresponding to the transaction to be detected fails the check, the transaction to be detected is determined to have failed the check. When the check result of the transaction to be detected fails the check, the axiom of the failed check sub-result is recorded.

[0152] In the transaction detection method provided in this application embodiment, the transaction to be detected is first determined based on the detection mode, and the transaction identifier and time information of the transaction to be detected are obtained. The detection mode is either online or offline, meaning that the transaction detection method provided in this application embodiment can be applied to both online and offline modes, improving the universality of transaction detection. Then, based on the detection mode and isolation level, at least one detection axiom corresponding to the transaction to be detected is determined, realizing dynamic adaptation of the detection axiom with the detection mode and isolation level. The detection intensity can be switched as needed, thereby balancing resource overhead and detection coverage. Finally, based on the transaction identifier, time information, and each detection axiom, the transaction to be detected is detected to obtain the detection result. This avoids the complex construction of traditional transaction dependency graphs and directly achieves linear complexity transaction detection through timestamp comparison. While ensuring detection accuracy, it can significantly improve transaction detection efficiency. Furthermore, by flexibly adapting to multiple isolation levels through detection axioms, when adding a new isolation level, only new detection axioms need to be defined, without modifying the overall detection framework, thus having good scalability.

[0153] In some embodiments, due to the asynchronous nature of transaction execution in online mode, the commit timestamp of the transaction to be detected may be before the start timestamp of the detected transaction, or the start timestamp of the transaction to be detected may be before the commit timestamp of the detected transaction. In short, there may be a time overlap between the transaction to be detected and the detected transaction. Therefore, after verifying the session axiom, the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom for the transaction to be detected, it is necessary to verify the second conflict-free axiom for transactions that have time overlap with the transaction to be detected through the following steps:

[0154] Step 1: Determine the third transaction based on the time information of the transaction to be detected.

[0155] In this embodiment, there is an overlapping time interval between the time information of the third transaction and the time information of the transaction to be detected. In some embodiments, a timestamp subsequence is obtained from the third timestamp sequence, wherein the third timestamp sequence includes the start timestamp and commit timestamp of the detected transactions arranged in ascending order, the first timestamp of the timestamp subsequence is the start timestamp of the transaction to be detected, the Nth timestamp of the timestamp subsequence is the commit timestamp of the transaction to be detected, and N is the total number of timestamps included in the timestamp subsequence. Then, the transactions corresponding to the 2nd to the (N-1)th timestamps in the timestamp subsequence are determined as the third transaction.

[0156] Step 2: Detect the third transaction based on its time information, identifier, and the second conflict-free axiom, and obtain the detection sub-result of the third transaction against the second conflict-free axiom.

[0157] In some embodiments, this step is implemented by first determining the previous committed transaction of the third transaction based on the time information of the third transaction, and obtaining the operation information set of the third transaction based on the third transaction identifier. The operation information set of the third transaction is traversed. When the seventh target operation information is encountered, the seventh target key and the third transaction identifier in the seventh target operation information are added to the third run list, where the third run list is the run list corresponding to the previous committed transaction of the third transaction, and the seventh target operation information is the operation information for the write operation on the seventh target key. When the third transaction is determined to be committed, the seventh target key and the third transaction identifier are deleted from the third run list to obtain the updated third run list. Then, it is determined whether the updated third run list is empty. If the updated third run list is empty, the detection sub-result of the third transaction for the second conflict-free axiom is passed. If the updated third run list is not empty, it means that the detection sub-result of the third transaction for the second conflict-free axiom is failed.

[0158] Step 3: Update the detection result of the third transaction based on the detection sub-result of the third transaction against the second conflict-free axiom.

[0159] In some embodiments, this step involves obtaining the historical detection sub-results of the third transaction against the second conflict-free axiom. If the detection sub-result of the third transaction against the second conflict-free axiom obtained in step two is the same as the historical detection sub-results, the detection result of the third transaction remains unchanged. If the detection sub-result of the third transaction against the second conflict-free axiom obtained in step two is different from the historical detection sub-results, the detection result of the third transaction is determined based on the detection sub-result of the third transaction against the second conflict-free axiom obtained in step two, the historical detection sub-result of the third transaction against the session axiom, the historical detection sub-result of the third transaction against the second internal consistency axiom, and the historical detection sub-result of the third transaction against the second external consistency axiom. When all three of the following sub-results obtained in step two—the third transaction's detection result for the second conflict-free axiom, the third transaction's historical detection result for the session axiom, the third transaction's historical detection result for the second internal consistency axiom, and the third transaction's historical detection result for the second external consistency axiom—pass the detection, the third transaction's detection result is determined to be successful. When at least one of these three sub-results obtained in step two—the third transaction's detection result for the second conflict-free axiom, the third transaction's historical detection result for the session axiom, the third transaction's historical detection result for the second internal consistency axiom, and the third transaction's historical detection result for the second external consistency axiom—fails the detection, the third transaction's detection result is determined to be unsuccessful.

[0160] In the above embodiments, when a newly acquired transaction to be detected is submitted, due to the asynchronous nature of transaction execution, the read and write operations of the newly submitted transaction may affect the detection sub-results of the already detected third transaction that have overlapping time intervals with the newly submitted transaction for the second conflict-free axiom. Therefore, after the transaction to be detected is submitted, the second conflict-free axiom is re-detected on the third transaction, and the inspection result of the third transaction is updated according to the detection sub-results obtained from the re-detection, thereby ensuring the accuracy of the detection results.

[0161] In some embodiments, also due to the asynchronous nature of transaction execution in online mode, the transaction to be checked with a smaller commit timestamp may have written a new value to the key, and the result of checking the second external consistency axiom for the already checked transaction with a larger start timestamp may need to be updated. In this case, execution can continue after step 104. Figure 5 The following steps are shown:

[0162] In step 105, when a transaction to be detected is committed, the start timestamp and commit timestamp in the time information are inserted into the third timestamp sequence to obtain the updated third timestamp sequence.

[0163] The third timestamp sequence includes the start and commit timestamps of the detected transactions, and the timestamps in the third timestamp sequence are arranged in ascending order. When inserting the start and commit timestamps from the time information into the third timestamp sequence, the start timestamp is first compared with each timestamp in the third timestamp sequence. If the start timestamp is greater than the i-th timestamp and less than the (i+1)-th timestamp, the start timestamp is inserted between the i-th and (i+1)-th timestamps. Then, the commit timestamp is compared with each timestamp after the start timestamp. If the commit timestamp is greater than the j-th timestamp and less than the (j+1)-th timestamp, the commit timestamp is inserted after the j-th timestamp, thus obtaining the updated third timestamp sequence, in which the timestamps are also arranged in ascending order.

[0164] For example, the third timestamp sequence is: 20, 30, 50, 80, 130, 150, 170. The start timestamp of the transaction to be detected is 100, and the commit timestamp is 145. Then, the start timestamp is inserted between 80 and 130, resulting in 20, 30, 50, 80, 100, 130, 150, 170. Then, starting from 130, it is compared with the commit timestamp 145. Finally, it is determined that the commit timestamp is inserted between 130 and 150, so the final updated third timestamp sequence is 20, 30, 50, 80, 100, 130, 145, 150, 170.

[0165] In step 106, the sequence of timestamps is iterated backwards from the commit timestamp of the transaction to be detected in the updated third timestamp sequence.

[0166] Continuing with the example above, the updated third timestamp sequence is 20, 30, 50, 80, 100, 130, 145, 150, 170, so we start iterating from 150.

[0167] In step 107, it is determined whether the timestamp currently being traversed is the start timestamp.

[0168] Here, if the timestamp currently being traversed is the start timestamp, proceed to step 108; if the timestamp currently being traversed is not the start timestamp, then it is the submission timestamp, and proceed to step 110.

[0169] In step 108, the fourth transaction corresponding to the start timestamp is tested based on the second external consistency axiom, and a new test sub-result of the fourth transaction based on the second external consistency axiom is obtained.

[0170] In some embodiments, when performing the second external consistency axiom check on the fourth transaction, the operation information set of the fourth transaction is obtained, and then the eighth target operation information is obtained from the operation information set of the fourth transaction. The eighth target operation information is the first read operation for the eighth target key. The sixth value of the eighth target key is obtained from the fourth external list of the previous committed transaction of the fourth transaction, and the fifth read value of the eighth target key is obtained from the eighth target operation information. If the fifth read value and the sixth value are the same, the new detection sub-result of the fourth transaction for the second external consistency axiom is a successful detection. If the fifth read value and the sixth value are different, the new detection sub-result of the fourth transaction for the second external consistency axiom is a failed detection.

[0171] For example, assuming 150 is the start timestamp of transaction T3, then the fourth transaction is also T3. According to the updated third timestamp sequence, the most recent commit timestamp before 150 is 145. Therefore, the previous committed transaction of the fourth transaction is the transaction to be tested. The eighth target operation information determined from the operation information set of the fourth transaction is the first read operation on the eighth target key "sales", and the value read is 1000. The sixth value corresponding to the eighth target key obtained from the fourth external list corresponding to the transaction to be tested is also 1000. Therefore, the detection sub-result of the fourth transaction for the second external consistency axiom is determined to be a successful test.

[0172] In step 109, the detection result of the fourth transaction is updated based on the new detection sub-result of the fourth transaction for the second external consistency axiom.

[0173] In some embodiments, historical detection sub-results of the fourth transaction against the second external consistency axiom are obtained. If the new detection sub-result of the fourth transaction against the second external consistency axiom obtained in step 108 is the same as the historical detection sub-result, the detection result of the fourth transaction remains unchanged. If the new detection sub-result of the fourth transaction against the second external consistency axiom obtained in step 108 is different from the historical detection sub-result, the detection result of the fourth transaction is determined based on the new detection sub-result of the fourth transaction against the second external consistency axiom, the historical detection sub-result of the fourth transaction against the session axiom, the historical detection sub-result of the fourth transaction against the second internal consistency axiom, and the historical detection sub-result of the fourth transaction against the second conflict-free axiom. The fourth transaction's detection result is determined to be successful when all of the following sub-results of the fourth transaction pass the tests: the new sub-result of the fourth transaction against the second external consistency axiom, the historical sub-result of the fourth transaction against the session axiom, the historical sub-result of the fourth transaction against the second internal consistency axiom, and the historical sub-result of the fourth transaction against the second conflict-free axiom. The fourth transaction's detection result is determined to be unsuccessful when at least one of the following sub-results of the fourth transaction fails the tests: the new sub-result of the fourth transaction against the second external consistency axiom, the historical sub-result of the fourth transaction against the session axiom, the historical sub-result of the fourth transaction against the second internal consistency axiom, and the historical sub-result of the fourth transaction against the second conflict-free axiom.

[0174] Suppose that before inserting the start timestamp 100 and commit timestamp 145 of the transaction to be tested into the third timestamp sequence, the previous committed transaction of the fourth transaction is the sixth transaction T4 corresponding to commit timestamp 130. The value of the eighth target key "sales" in the second external list corresponding to the sixth transaction is 800, which is different from the 1000 read by the fourth transaction. At this time, the detection sub-result of the fourth transaction for the second external consistency axiom is that the detection failed. However, after the transaction to be tested is committed, the previous committed transaction of the fourth transaction changes. Thus, by re-detecting the second external consistency axiom, a new detection sub-result for the second external consistency axiom is obtained. Suppose that the historical detection sub-results of the fourth transaction for the session axiom, the historical detection sub-results of the fourth transaction for the second internal consistency axiom, and the historical detection sub-results of the fourth transaction for the second conflict-free axiom are all successful, and the new detection result for the second external consistency axiom is successful. Then, the detection result of the fourth transaction is updated from failed to successful, thus ensuring that an accurate detection result is obtained.

[0175] In step 110, the third external list corresponding to the fifth transaction with the commit timestamp is obtained.

[0176] It should be noted that the fourth and fifth transactions can be the same transaction or different transactions. When traversing to the commit timestamp, the third external list corresponding to the fifth transaction can be retrieved based on the commit timestamp, or the third external list can be retrieved based on the transaction identifier of the fifth transaction.

[0177] In step 111, the value of the sixth target key in the third external list is updated to the second write value.

[0178] In some embodiments, if a newly submitted transaction to be detected performs a write operation on the sixth target key, then the value of the sixth target key in the third outer list of the fifth transaction is updated, that is, updated to the second write value, thereby ensuring that the third outer list stores the latest values ​​of each key and ensuring the accuracy of the transaction detection results.

[0179] In the above embodiments, in online mode, when the transaction to be detected is committed, the time information of the transaction to be detected is first inserted into the third timestamp sequence to obtain the updated third timestamp sequence. Since the transaction to be detected may have performed write operations on some keys, causing the values ​​of these keys to change, the results of the second external consistency axiom checked by the detected transactions before the transaction to be detected may be incorrect. Therefore, these transactions need to be re-checked. When traversing the updated third timestamp sequence, when the commit timestamp is reached, these transactions need to update the second external list to ensure that the state of the key values ​​is correct. When the start timestamp is reached, the second external consistency axiom of the detected transactions corresponding to the start timestamp is re-verified, and the detection result of the detected transaction is updated based on the new detection sub-result, thereby ensuring the real-time accuracy of the detection result.

[0180] In some embodiments, after obtaining the detection results of all transactions to be detected in offline mode, if the transaction with the detection result of failing the detection is output, the reason for the transaction failure can also be output, such as the axiom that the sub-result of the detection failed. This allows users to obtain the transaction detection results in a timely manner, so that when a transaction fails the detection, the problematic transaction can be located in time, and the index design or transaction splitting (such as splitting long transactions into short transactions) can be optimized for the identified high-frequency conflicting transactions. In some embodiments, after all transactions to be detected have been detected, the execution history data of the transactions to be detected can be deleted to reduce the memory space occupied.

[0181] Furthermore, due to the asynchronous nature of online mode, a detection result that fails temporarily may be changed by the write operation of a later committed transaction, and a detection result that passes temporarily may also be changed to fail due to a later committed transaction. Therefore, in this embodiment of the application, in online mode, after obtaining the detection result of the transaction to be detected, the detection result of the transaction to be detected is output after a preset time threshold is reached; and in order to avoid the transaction detection result occupying memory space indefinitely, the output detection result and the execution history data of the transaction corresponding to the detection result are deleted, thereby improving the memory space utilization rate.

[0182] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.

[0183] This application provides a timestamp-based database transaction isolation level checking scheme, including offline and online modes. Through an efficient timestamp-based white-box transaction checking tool, it checks whether committed transactions on database nodes meet certain specific properties to verify whether the database correctly implements its claimed transaction isolation level.

[0184] The Serializability (SER) and Snapshot Isolation (SI) checks based on transaction history records have both been proven to be NP-complete problems. Therefore, black-box checks inevitably face the problem of low efficiency when the scale of the transaction history reaches a certain level. The technical approach of this invention is to use timestamp-based information in addition to the information obtainable through black-box checks, thereby directly deriving the version order of the transaction history, turning the SER and SI checks into P-problems, and greatly improving the checking efficiency. In this application's embodiments, firstly, timestamps are introduced into the isolation level checks, abandoning conventional graph-based checks and using axiomatic checks to improve efficiency. Secondly, efficient offline and online SER and SI check algorithms are designed. Finally, offline and online check tools are developed. Experiments show that compared to other black-box or white-box check tools, the offline and online check tools provided in this application's embodiments have significant performance advantages in SER and SI checks.

[0185] Figure 6 This is a schematic diagram illustrating the implementation process of timestamp-based transaction isolation level checking provided in an embodiment of this application. Figure 6As shown, firstly, the transaction generator 601 generates transactions to be executed according to certain parameters and strategies. Then, the executor 602 connects to the deployed database 603 to execute these transactions, forming the execution history. After execution, the database stores transaction information, including the transaction start timestamp and commit timestamp. This information is often stored in the database log, write-ahead log, or change data capture mechanism. After retrieving this information, the inspector 604 (i.e., online and offline inspection tools) can check whether the execution history meets a specified isolation level.

[0186] In an offline inspection workflow, each of the above steps must wait for the previous step to complete completely before proceeding. However, in an online inspection workflow, history can be collected and sent to the inspector simultaneously during transaction execution, allowing the inspector to perform incremental checks.

[0187] The offline isolation level checker and the online isolation level checker mainly consist of the following two major functional modules:

[0188] The transaction reading module is used to read and parse executed transactions into memory, forming a history. For the offline isolation level checker, transactions are read from a JSON file. For the online isolation level checker, transactions are read from data carried in HTTP requests, and the data should also be in JSON format.

[0189] The historical inspection module checks whether the transaction history meets SER or SI standards. If a violation is found, it is recorded and output. For the offline isolation level checker, there are fast mode and garbage collection (GC) mode. Fast mode does not perform garbage collection, completing the historical inspection as quickly as possible; GC mode periodically reclaims the inspected portion of the history, reducing memory usage. Violation records are output uniformly after all inspections are completed. For the online isolation level checker, garbage collection is enabled to prevent unlimited memory expansion. Due to asynchronicity, a violation at one time may be corrected by subsequent transactions, and a correctness at one time may become a violation due to subsequent transactions. Therefore, in this embodiment, a time window is set, and violations that are not corrected will be output after the window period.

[0190] The main features of the offline and online isolation level checkers provided in this application are their outstanding performance, and the fact that the online isolation level checker is the first tool to support online SER and SI checks. To verify their performance, efficiency comparison experiments were designed from multiple aspects, comparing the offline and online isolation level checkers with five other tools. Specifically, these included an efficiency comparison experiment of the offline isolation level checker with four tools other than Cobra for SI checks, an efficiency comparison experiment of the offline isolation level checker with Elle for SI checks on list data structures, and an efficiency comparison experiment of the online isolation level checker with Cobra for online SER checks. Furthermore, experiments were conducted comparing the memory usage of the offline isolation level checker with other tools and the impact of online checks by the online isolation level checker on database throughput. Through this experimental design, the performance advantages of the offline and online isolation level checkers provided in this application can be comprehensively compared, and their resource consumption is at a reasonable level in actual use.

[0191] First, we will introduce the results of the comparative experiment on inspection efficiency. Figure 7 This chart compares the efficiency of the offline isolation level checker provided in this application with that of PolySI, Viper, ElleKV, and Emme-SI. ElleKV refers to Elle's transaction history check on key-value pair storage, distinguishing it from ElleList used in later experiments. It can be seen that the check time of the two black-box tools, PolySI and Viper, increases sharply with the number of transactions. The other two white-box tools show slower growth at smaller transaction sizes. Emme-SI's check time begins to increase rapidly at transaction sizes exceeding 2000.

[0192] To investigate the performance comparison of the two white-box tools and the offline isolation level checker provided in this application embodiment when the transaction size is large, the transaction size was increased in this application embodiment. At the same time, in order to let Elle give full play to its advantages, a comparison was also made between the offline isolation level checker provided in this application embodiment and Elle's transaction history check on the list data structure (i.e., ElleList). Figure 8This is a comparison chart of the transaction history checks performed by the offline isolation level checker provided in this application and Elle on a list data structure. When the transaction size is large and increases rapidly, the check time of Emme-SI also increases sharply. This is because Emme uses SSG as the dependency graph for checking SI, and building such a dependency graph is time-consuming; the time does not increase linearly with the size. In contrast, regardless of the data structure, Elle's check time appears to increase linearly with the number of transactions, but it still increases faster than the offline isolation level checker. The offline isolation level checker has a performance advantage of approximately 7 to 11 times compared to Elle.

[0193] Figure 9 This is a comparison chart of the throughput of the online isolation level checker provided in this application embodiment and Cobra when checking SER. Different parameters were set for Cobra during the comparison. The maximum throughput of Cobra reached 5000-6000 transactions per second, but decreased over time. In other cases, the throughput stabilized but did not exceed 3000. The online isolation level checker provided in this application embodiment achieved a maximum throughput of approximately 18000 transactions per second, which decreased to approximately 12000 transactions per second after garbage collection was triggered. When the set memory was full, the throughput decreased to approximately 3000 transactions per second due to frequent garbage collection.

[0194] The results of the memory usage experiment will be presented next. Figure 10 This is a comparison chart of the memory usage of the offline isolation level checker provided in this application embodiment with other SI checking tools. Figure 10 It can be seen that when the number of transactions changes, the memory usage of the offline isolation level checker provided in this embodiment increases linearly, and is much smaller than that of other tools. When the key distribution method changes, the memory usage of each tool does not change significantly. At this time, the memory usage of the offline isolation level checker provided in this embodiment is still the smallest, much smaller than that of other tools. In fact, changing other parameters, such as the number of sessions and the number of operations per transaction, will yield the same conclusion.

[0195] Finally, we present the experimental results of the online isolation level checker's online inspection of the impact on database throughput. Figure 11 This diagram illustrates the impact of online checks on database throughput when historical data is collected or not. Figure 11 It can be seen that as the number of operations per transaction increases, the database throughput consistently decreases by about 5% compared to not collecting history, a small loss that is acceptable. The same conclusion is reached when other parameters are changed.

[0196] As can be seen from the comparative experiments above, regardless of the data structure being examined for transaction history, the offline isolation level checker provided in this application embodiment is significantly more efficient than Viper / PolySI / Elle / Emme, greatly improving the efficiency of database transaction isolation level checks and possessing high practical value. Regarding online checks, the online isolation level checker provided in this application embodiment also shows a significant performance improvement compared to Cobra, and supports SI checks, which Cobra lacks.

[0197] Furthermore, the offline and online isolation level checkers provided in this application are not subject to write-value uniqueness constraints, can check the history of various data structures, are not limited to a specific isolation level, and can be easily extended to other data structures and isolation levels. In addition, the timestamp information required by the offline and online isolation level checkers provided in this application is readily available in many databases, and does not require actual physical timestamps; logical timestamps are also feasible. Therefore, they can be applied to many different types of databases.

[0198] The offline and online isolation level checkers provided in this application are suitable for checking databases that claim to provide SER or SI isolation level transactions to determine whether they have correctly implemented the claimed isolation level. Furthermore, the offline isolation level checker provided in this application can also detect anomalies that black-box tools cannot discover.

[0199] Figure 12 This diagram illustrates an SI isolation level anomaly that black-box tools cannot detect. Transactions T1, T2, and T3 are executed sequentially. T1 and T2 both write values ​​to key x. T3 reads the value of key x, and should read the latest value, i.e., the 2 written by T2. However, T3 actually reads the 1 written by T1. This clearly violates SER and SI. Black-box tools, lacking time information (version information), can reconstruct a theoretically correct execution order: T1, T3, and finally T2. However, with time information, it becomes clear that this is not the actual execution order, thus preventing black-box tools from detecting this problem. The offline and online isolation level checkers provided in this application can detect such anomalies.

[0200] The technical implementation process of the transaction inspection method provided in the embodiments of this application is described below.

[0201] Database transactions provide an "all or nothing" abstraction and isolate concurrent computations on shared data, greatly simplifying client programming. SER is the gold standard for transaction isolation, ensuring that all transactions are executed sequentially. To improve performance, many databases implement SI, a widely adopted weaker isolation level.

[0202] However, correctly implementing database isolation levels is extremely difficult, and many databases fail to provide the claimed SER or SI. Determining whether a given execution history meets the isolation check for a specified isolation level is fundamental to database testing. Existing black-box checking tools for SER and SI are NP-hard, typically exhibiting high computational complexity and difficulty scaling to large historical records containing tens of thousands of transactions. Currently, both black-box and white-box tools use graph algorithms for isolation level checks. However, for white-box checks, spending time constructing a potentially complex graph is unnecessary; checks can be performed based on the axiomatic definition of isolation levels, achieving linear time complexity, with significant room for efficiency improvement. Furthermore, in real-world production environments, transactions are often continuously and incrementally generated, making it difficult to acquire all transactions before checking. Therefore, an online checking mechanism is needed to check transactions as they are generated. Currently, only one checking tool supports online SER checks, but it requires periodically inserting fence transactions between batches to completely separate them, which is often unacceptable in practice. The offline isolation level checker and online isolation level checker provided in this application embodiment are designed to solve the problem of efficient transaction checking in offline and online scenarios, respectively.

[0203] The following uses SI as an example to illustrate the semantics of isolation levels. SI is defined using operational semantics, describing how it should be implemented. When a transaction T begins, it is assigned a start timestamp. Each write operation of transaction T has a buffer to store data, while read operations are performed from its buffer or from already committed transactions. These transactions are stored in the log, and the read access is determined by the start timestamp of transaction T. When transaction T commits, it is assigned a commit timestamp. If transaction T has write conflicts with other concurrent transactions, it must be aborted; otherwise, the contents of transaction T's buffer are updated to the log, and the commit is successful.

[0204] Operational semantics are suitable for database engineering implementations, while axiomatic semantics are more suitable for isolation level checks. To define the axiomatic semantics of SI, transactions, history, and abstract execution are first formally defined.

[0205] A transaction is a tuple (O, po), where O is a set of operations (e.g., read and write operations), and po is the program order on O, that is, the execution order of the operations in O, which is a strict total order.

[0206] history It is a pair, where It is a collection of transactions, SO is The order of conversations, i.e. The order in which transactions occur within their respective sessions is a partial order.

[0207] Abstract execution It is a quadruple, in which It is history. VIS represents visible relationships in history, which is a partial order. AR represents arbitral relationships in history, which is a strict total order.

[0208] With the formal definitions of the above concepts, SI can then be defined axiomatically. A history SI is satisfied if and only if there exists an abstract execution This makes the following axioms hold: SESSION, INT, EXT, PREFIX, and NOCONFLICT.

[0209] Session axioms: In other words, earlier transactions in the same session should be visible to later transactions.

[0210] The Internal Consistency Axiom (INT) states that within a transaction, if there are multiple reads or writes on a key, then all operations except the first read or write should return the value of the previous read or write on that key.

[0211] The External Consistency Axiom (EXT) states that when a transaction first reads a key it has not written to, it should read the last of the AR order in the transactions it is visible to.

[0212] Prefix (PREFIX) axiom: AR; That is, if a transaction S is visible to another transaction T, then in AR order, transactions that precede S should also be visible to T.

[0213] The No-Conflict Axiom states that if two transactions write to the same key, they cannot be concurrent; that is, one of them must be visible to the other.

[0214] The above introduces axiomatic semantics suitable for inspection. Combining it with timestamps will greatly simplify the inspection process.

[0215] Timestamp-based AR relationships: For any two distinct transactions T1 and T2, If and only if the commit timestamp of T1 is less than the start timestamp of T2, i.e., T1.commit_ts <T2.commit_ts。

[0216] Timestamp-based VIS relationships: For any two distinct transactions T1 and T2, The commit timestamp of T1 is less than or equal to the start timestamp of T2 if and only if T1.commit_ts ≤ T2.start_ts.

[0217] Since the start timestamp of a transaction is always less than or equal to its commit timestamp, the above VIS and AR relationships still satisfy the conditions that VIS is a partial order relation and AR is a strict total order relation. Furthermore, under this definition, the PREFIX axiom holds naturally and requires no verification.

[0218] Therefore, checking SI only requires checking the four axioms: SESSION, INT, EXT, and NOCONFLICT. For checking SER, a SER guaranteeing session order needs to satisfy the axioms: SESSION, INT, EXT, and TOTALVIS. TOTALVIS means that VIS is a strict total order, and VIS itself is a subset of a strict total order (AR), in other words, VIS = AR. Therefore, for SER checking, it is only necessary to assume that transactions are pairwise non-conflicting, determine the global serial execution order based on the commit timestamp (i.e., assume TOTALVIS has been satisfied), and then check SESSION, INT, and EXT. In this case, the transaction start timestamp is irrelevant and can be ignored.

[0219] The isolation level checking algorithms of the offline isolation level checker and the online isolation level checker provided in the embodiments of this application will be described below.

[0220] Since the timestamps are known, we can sort all the timestamps in ascending order and then check each transaction sequentially to see if it satisfies these axioms, simulating transactions starting or committing in chronological order. This method doesn't require traversing all possible execution sequences like black-box tools, nor does it require building a dependency graph like other white-box tools. Furthermore, this simulated checking method has incremental characteristics, making it more suitable for online checks compared to graph structures.

[0221] The following describes the implementation process of the offline isolation level checker's offline SI check algorithm. The offline isolation level checker first sorts the timestamps in ascending order to obtain the first timestamp sequence. Then, it iterates through this sequence, checking either the start or commit timestamp of a transaction. These two cases require checking different axioms, ensuring the same axiom isn't checked repeatedly at the start and commit times. Specifically, if the timestamp is the start timestamp of a transaction, the SESSION axiom, INT axiom, and EXT axiom are checked; if it's the commit timestamp, the NOCONFLICT axiom is checked. For the SESSION axiom, hash tables `last_sno` and `last_cts` are maintained to record the auto-incrementing number and commit timestamp of the last executed transaction in each session. When checking a transaction, it compares whether the transaction to be checked is the previous transaction's auto-incrementing number plus one and whether its start timestamp is greater than the previous transaction's commit timestamp. For the INT axiom, during the traversal of transaction operations, only a hash table `int_val` (corresponding to the first internal list in other embodiments) needs to be maintained to record the latest value on the current transaction key. When the transaction has not operated on a certain key for the first time and this time it is a read, it needs to check whether the value read is the same as the value of the previous operation (the previous operation may have been a read or a write). For the EXT axiom, during the traversal of operations, a hash table `ext_val` is maintained to record the latest value of the write operation on the current transaction key. When the transaction is committed, `ext_val` is updated to a global hash table `frontier` (corresponding to the first external list in other embodiments), which records the key values ​​caused by all committed transactions so far. When the transaction to be checked reads a certain key for the first time, it checks this `frontier` to see if the value on that key is the same as the value read. According to the NOCONFLICT axiom, a hash table `ongoing` (corresponding to the first running list in other embodiments) is maintained to record which transactions have performed write operations on each key but have not yet been committed. When a transaction begins to traverse, the key of the write operation and the transaction identifier of this transaction are added to `ongoing`. When a transaction is committed, the key written by the transaction and its own transaction identifier are removed from `ongoing`. If, after deletion, there are still transaction identifiers of other transactions on these keys in `ongoing`, it means that concurrent write operations have occurred on the same key.

[0222] Offline SER checks are simpler: ignore the start timestamp and check the SESSION, INT, and EXT axioms when iterating to the commit timestamp. Aside from the timing, the SESSION, INT, and EXT checks are identical to offline SI checks, and the frontier is also updated when a commit timestamp is encountered. Since the NOCONFLICT axiom is no longer checked, the ongoing data structure is also no longer needed.

[0223] The implementation process of the online SI checking algorithm of the online isolation level checker is explained below. Similar to, but different from, the online isolation level checker needs to maintain hash tables `frontier_ts` and `ongoing_ts` indexed by timestamps to check these axioms. These tables use the entire `frontier` and `ongoing` objects in Chronos as the hash table values, and the timestamps as the hash table keys. This is practically equivalent to using transactions as the hash table keys. They maintain a snapshot of each transaction. The only difference between the online and offline isolation level checkers when checking axioms is that the offline checker queries the global `frontier` and `ongoing` objects, while the online checker needs to query the `frontier_ts` and `ongoing_ts` objects of the last committed transaction based on the timestamp. When checking a new transaction, the online isolation level checker first checks the SESSION, INT, and EXT axioms, similar to Chronos. Due to asynchronicity, the new transaction's timestamp may precede any previously checked transactions. Therefore, it's necessary to acquire transactions whose timestamps overlap with the new transaction's. Each transaction's start and commit timestamps form a time interval. If two transactions' corresponding time intervals overlap, their timestamps are considered to overlap. The new transaction is then checked against these transactions to ensure they satisfy the NOCONFLICT axiom, a process identical to the offline isolation level checker. Similarly, new transactions with smaller timestamps may have written new values ​​to keys, potentially causing errors in the EXT axiom checks performed on transactions with larger timestamps. Therefore, the online isolation level checker needs to re-check these transactions. Upon encountering a commit timestamp, these transactions update their frontier_ts to ensure the key values ​​are correct. Upon encountering a start timestamp, they re-compare the value they initially read on a key with the value in their frontier_ts. For the SESSION and INT axioms, their results after a single check are deterministic and unchanging, thus requiring no re-checking.

[0224] For online SER checks, the process is the same as online SI checks: first, check the SESSION axioms, then iterate through the operations to check the INT and EXT axioms. Online SERs do not need to check NOCONFLICT, nor do they need to maintain ongoing_ts. Finally, when re-checking transactions that have been committed, the process is the same as offline SER checks: ignore the start timestamp, and re-check and update frontier_ts when a commit timestamp is encountered.

[0225] The offline and online isolation level checkers provided in this application use timestamps to check the SI and SER isolation levels of the database, implementing fast offline and online checking algorithms with a throughput of tens of thousands. This makes checking databases that use similar timestamp mechanisms to implement transactions more efficient, and also innovatively supports high-efficiency online checking of SI. This plays a crucial role in verifying the correctness of the database and discovering database defects.

[0226] It is understood that, in the embodiments of this application, data related to transaction operation information sets involving user information, when applied to specific products or technologies, requires user permission or consent, and the collection, use and processing of related data must comply with relevant laws, regulations and standards.

[0227] The following description continues to illustrate the exemplary structure of the transaction detection device 455 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software module stored in the transaction detection device 455 of the memory 450 may include:

[0228] The first acquisition module 4551 acquires a preset detection mode and isolation level, wherein the detection mode is an online mode or an offline mode;

[0229] The first determining module 4552 is used to determine the transaction to be detected based on the detection mode, and to obtain the transaction identifier and time information of the transaction to be detected.

[0230] The second determining module 4553 is used to determine at least one detection axiom corresponding to the transaction to be detected based on the detection mode and the isolation level;

[0231] The transaction detection module 4554 is used to detect the transaction to be detected based on the transaction identifier, the time information and each of the detection axioms, and obtain the detection result of the transaction to be detected.

[0232] In some embodiments, the first determining module 4552 is further configured to: determine the currently executing first transaction as the transaction to be detected when the detection mode is online mode; and determine the transaction to be detected based on multiple executed second transactions when the detection mode is offline mode.

[0233] In some embodiments, the first determining module 4552 is further configured to: when the isolation level is a first isolation level, obtain the start timestamp and commit timestamp of a plurality of second transactions; sort the start timestamps and commit timestamps of the plurality of second transactions in chronological order to obtain a first timestamp sequence; and determine the second transaction corresponding to each first timestamp in the first timestamp sequence as a transaction to be detected.

[0234] In some embodiments, the first determining module 4552 is further configured to: when the isolation level is a second isolation level, obtain the commit timestamps of a plurality of second transactions; sort the commit timestamps of the plurality of second transactions in chronological order to obtain a second timestamp sequence; and determine the second transaction corresponding to each second timestamp in the second timestamp sequence as a transaction to be detected.

[0235] In some embodiments, the second determining module 4553 is further configured to: when the detection mode is offline mode and the isolation level is the first isolation level, if the first timestamp corresponding to the transaction to be detected is the start timestamp, determine that the detection axioms corresponding to the transaction to be detected include the session axiom, the first internal consistency axiom, and the first external consistency axiom; if the first timestamp corresponding to the transaction to be detected is the commit timestamp, determine that the detection axioms corresponding to the transaction to be detected include the first conflict-free axiom.

[0236] When the detection mode is offline mode and the isolation level is the second isolation level, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the first internal consistency axiom, and the first external consistency axiom, and the second isolation level is higher than the first isolation level.

[0237] In some embodiments, the second determining module 4553 is further configured to: when the detection mode is online mode and the isolation level is the first isolation level, determine that the detection axioms corresponding to the transaction to be detected include the session axiom, the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom; when the detection mode is online mode and the isolation level is the second isolation level, determine that the detection axioms corresponding to the transaction to be detected include the session axiom, the second internal consistency axiom, and the second external consistency axiom, wherein the second isolation level is higher than the first isolation level.

[0238] In some embodiments, the transaction detection module 4554 is further configured to: for each of the detection axioms, determine the data to be detected corresponding to the detection axiom based on the transaction identifier to be detected and the time information; detect the transaction to be detected based on the data to be detected to obtain the detection sub-result of the transaction to be detected for the detection axiom; and determine the detection result of the transaction to be detected based on each of the detection sub-results.

[0239] In some embodiments, the time information includes the start timestamp and commit timestamp of the transaction to be detected. The transaction detection module 4554 is further configured to: when the detection axiom is a session axiom, obtain the historical commit timestamp and historical transaction identifier of the previous transaction of the transaction to be detected based on the transaction identifier; and determine the transaction identifier, the start timestamp of the transaction to be detected, the historical commit timestamp of the previous transaction, and the historical transaction identifier as the data to be detected corresponding to the session axiom.

[0240] In some embodiments, the transaction detection module 4554 is further configured to: determine that the detection sub-result of the transaction to be detected for the session axiom is passed when the difference between the transaction identifier to be detected and the historical transaction identifier is a first preset value, and the start timestamp of the transaction to be detected is greater than the historical commit timestamp; and determine that the detection sub-result of the transaction to be detected for the session axiom is failed when the difference between the transaction identifier to be detected and the historical transaction identifier is not a first preset value, or the start timestamp of the transaction to be detected is less than or equal to the historical commit timestamp.

[0241] In some embodiments, the transaction detection module 4554 is further configured to: when the axiom to be detected is a first internal consistency axiom, obtain the operation information set of the transaction to be detected based on the transaction identifier to be detected, determine the first target operation information from the operation information set, wherein the first target operation information is the operation information for a non-first read operation on a first target key; obtain the first value corresponding to the first target key from the first internal list; and determine the first target operation information and the first value as the data to be detected corresponding to the first internal consistency axiom.

[0242] In some embodiments, the transaction detection module 4554 is further configured to: obtain a first read value of the first target key from the first target operation information; when the first read value and the first value are the same, determine that the detection sub-result of the transaction to be detected against the first internal consistency axiom is detected as passed; when the first read value and the first value are different, determine that the detection sub-result of the transaction to be detected against the first internal consistency axiom is detected as failed.

[0243] In some embodiments, the transaction detection module 4554 is further configured to: when the axiom to be detected is a first external consistency axiom, obtain the operation information set of the transaction to be detected based on the transaction identifier to be detected, determine the second target operation information from the operation information set, wherein the second target operation information is the operation information of the first read operation for the second target key; obtain the second value corresponding to the second target key from the first external list; and determine the second target operation information and the second value as the data to be detected corresponding to the first external consistency axiom.

[0244] In some embodiments, the transaction detection module 4554 is further configured to: obtain a second read value of the second target key from the second target operation information; when the second read value and the second value are the same, determine that the detection sub-result of the transaction to be detected against the first external consistency axiom is detected as passed; when the second read value and the second value are different, determine that the detection sub-result of the transaction to be detected against the first external consistency axiom is detected as failed.

[0245] In some embodiments, the transaction detection module 4554 is further configured to: when the axiom to be detected is a first conflict-free axiom, obtain the operation information set of the transaction to be detected based on the transaction identifier to be detected; traverse the operation information set, and when traversing to the third target operation information, add the third target key and the transaction identifier to be detected in the third target operation information to the first running list, wherein the third target operation information is the operation information of a write operation; when it is determined that the transaction to be detected has been committed based on the time information, delete the third target key and the transaction identifier to be detected from the first running list to obtain an updated first running list; and determine the updated first running list as the data to be detected corresponding to the first conflict-free axiom.

[0246] In some embodiments, the transaction detection module 4554 is further configured to: determine that the detection sub-result of the transaction to be detected against the first conflict-free axiom is passed when the updated first run list is empty; and determine that the detection sub-result of the transaction to be detected against the first conflict-free axiom is failed when the updated first run list is not empty.

[0247] In some embodiments, the apparatus further includes: a second acquisition module, configured to acquire a first write value of the third target key from the third target operation information when the submission of the transaction to be detected is determined based on the time information; a first update module, configured to update the value of the third target key in a first internal list to the first write value; and a second update module, configured to update the value of the third target key in a first external list to the first write value.

[0248] In some embodiments, the transaction detection module 4554 is further configured to: when the axiom to be detected is the second internal consistency axiom, obtain the operation information set of the transaction to be detected based on the transaction identifier to be detected, determine the fourth target operation information from the operation information set, wherein the fourth target operation information is the operation information for a non-first read operation on the fourth target key; determine the previous committed transaction of the transaction to be detected based on the time information, and obtain the fourth value corresponding to the fourth target key from the second internal list corresponding to the previous committed transaction; and determine the fourth target operation information and the fourth value as the data to be detected corresponding to the second internal consistency axiom.

[0249] In some embodiments, the transaction detection module 4554 is further configured to: obtain a third read value of the fourth target key from the fourth target operation information; when the third read value and the fourth value are the same, determine that the detection sub-result of the transaction to be detected against the second internal consistency axiom is detected as passed; when the third read value and the fourth value are different, determine that the detection sub-result of the transaction to be detected against the second internal consistency axiom is detected as failed.

[0250] In some embodiments, the transaction detection module 4554 is further configured to: when the axiom to be detected is the second external consistency axiom, obtain the operation information set of the transaction to be detected based on the transaction identifier to be detected, determine the fifth target operation information from the operation information set, wherein the fifth target operation information is the operation information of the first read operation for the fifth target key; determine the previous committed transaction of the transaction to be detected based on the time information, and obtain the fifth value corresponding to the fifth target key from the second external list corresponding to the previous committed transaction; and determine the fifth target operation information and the fifth value as the data to be detected corresponding to the second external consistency axiom.

[0251] In some embodiments, the transaction detection module 4554 is further configured to: obtain a fourth read value of the fifth target key from the fifth target operation information; when the fourth read value and the fifth value are the same, determine that the detection sub-result of the transaction to be detected against the second external consistency axiom is detected as passed; when the fourth read value and the fifth value are different, determine that the detection sub-result of the transaction to be detected against the second external consistency axiom is detected as failed.

[0252] In some embodiments, the transaction detection module 4554 is further configured to: when the axiom to be detected is the second conflict-free axiom, determine the previous committed transaction of the transaction to be detected based on the time information; obtain the operation information set of the transaction to be detected based on the identifier of the transaction to be detected; traverse the operation information set, and when the sixth target operation information is traversed, add the sixth target key and the identifier of the transaction to be detected in the sixth target operation information to the second run list corresponding to the previous committed transaction, wherein the sixth target operation information is the operation information of a write operation; when it is determined that the transaction to be detected has been committed, delete the sixth target key and the identifier of the transaction to be detected from the second run list to obtain an updated second run list; and determine the updated second run list as the data to be detected corresponding to the second conflict-free axiom.

[0253] In some embodiments, the transaction detection module 4554 is further configured to: determine that the detection sub-result of the transaction to be detected against the second conflict-free axiom is passed when the updated second run list is empty; and determine that the detection sub-result of the transaction to be detected against the second conflict-free axiom is failed when the updated second run list is not empty.

[0254] In some embodiments, the apparatus further includes: a third determining module, configured to determine a third transaction based on the time information of the transaction to be detected, wherein there is an overlapping time interval between the time information of the third transaction and the time information of the transaction to be detected; and a first re-detection module, configured to detect the third transaction based on the time information of the third transaction, the identifier of the third transaction, and the second conflict-free axiom, and obtain a detection sub-result of the third transaction against the second conflict-free axiom.

[0255] In some embodiments, the apparatus further includes: a third update module, configured to, when the commit of the transaction to be detected is detected, insert the start timestamp and commit timestamp in the time information into a third timestamp sequence to obtain an updated third timestamp sequence, the third timestamp sequence including the start timestamp and commit timestamp of the detected transaction; and a second re-detection module, configured to traverse backwards from the commit timestamp of the transaction to be detected in the updated third timestamp sequence, and when traversing to the start timestamp, detect the fourth transaction corresponding to the start timestamp based on the second external consistency axiom to obtain a new detection sub-result of the fourth transaction for the second external consistency axiom; and update the detection result of the fourth transaction based on the new detection sub-result of the fourth transaction for the second external consistency axiom.

[0256] In some embodiments, the apparatus further includes: a third acquisition module, configured to acquire a third external list corresponding to the fifth transaction corresponding to the commit timestamp when traversing to the commit timestamp; and a fourth update module, configured to update the value of the sixth target key in the third external list to the second write value.

[0257] This application provides a computer program product, which includes a computer program or computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer program or computer-executable instructions from the computer-readable storage medium and executes the computer program or computer-executable instructions, causing the electronic device to perform the transaction detection method described above in this application.

[0258] This application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the transaction detection method provided in this application. For example, ... Figure 3A The transaction detection method is shown.

[0259] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.

[0260] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.

[0261] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).

[0262] As an example, computer-executable instructions can be deployed to execute on a single electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed across multiple locations and interconnected via a communication network.

[0263] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

Claims

1. A transaction detection method, characterized in that, The method includes: Obtain a preset detection mode and isolation level, wherein the detection mode is either online or offline. The transaction to be detected is determined based on the detection mode, and the transaction identifier and time information of the transaction to be detected are obtained. Based on the detection mode and the isolation level, at least one detection axiom is determined for the transaction to be detected; Based on the identifier of the transaction to be detected, the time information, and each of the detection axioms, the transaction to be detected is detected to obtain the detection result of the transaction to be detected.

2. The method according to claim 1, characterized in that, The step of determining the transaction to be detected based on the detection mode includes: When the detection mode is online mode, the first transaction currently being executed is determined as the transaction to be detected; When the detection mode is offline mode, the transaction to be detected is determined based on multiple executed second transactions.

3. The method according to claim 2, characterized in that, When the detection mode is offline mode, the transaction to be detected is determined based on multiple executed second transactions, including: When the isolation level is the first isolation level, obtain the start timestamp and commit timestamp of multiple second transactions; The start timestamps and commit timestamps of multiple second transactions are sorted in chronological order to obtain the first timestamp sequence; The second transaction corresponding to each first timestamp in the first timestamp sequence is identified as the transaction to be detected.

4. The method according to claim 2, characterized in that, When the detection mode is offline mode, the transaction to be detected is determined based on multiple executed second transactions, including: When the isolation level is the second isolation level, obtain the commit timestamps of multiple second transactions; The commit timestamps of multiple second transactions are sorted in chronological order to obtain the second timestamp sequence; The second transaction corresponding to each second timestamp in the second timestamp sequence is identified as the transaction to be detected.

5. The method according to claim 3, characterized in that, The step of determining at least one detection axiom corresponding to the transaction to be detected based on the detection mode and the isolation level includes: When the detection mode is offline mode and the isolation level is the first isolation level, if the first timestamp corresponding to the transaction to be detected is the start timestamp, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the first internal consistency axiom, and the first external consistency axiom; if the first timestamp corresponding to the transaction to be detected is the commit timestamp, the detection axioms corresponding to the transaction to be detected are determined to include the first conflict-free axiom. When the detection mode is offline mode and the isolation level is the second isolation level, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the first internal consistency axiom, and the first external consistency axiom, and the second isolation level is higher than the first isolation level.

6. The method according to claim 1 or 2, characterized in that, The determination of at least one detection axiom corresponding to the transaction to be detected based on the detection mode and the isolation level includes: When the detection mode is online mode and the isolation level is the first isolation level, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the second internal consistency axiom, the second external consistency axiom, and the second conflict-free axiom. When the detection mode is online mode and the isolation level is the second isolation level, the detection axioms corresponding to the transaction to be detected are determined to include the session axiom, the second internal consistency axiom, and the second external consistency axiom, and the second isolation level is higher than the first isolation level.

7. The method according to claim 1, characterized in that, The step of detecting the transaction based on the identifier of the transaction to be detected, the time information, and each of the detection axioms, and obtaining the detection result of the transaction to be detected, includes: For each of the aforementioned detection axioms, based on the identifier of the transaction to be detected and the time information, the data to be detected corresponding to the detection axiom is determined; Based on the data to be detected, the transaction to be detected is detected to obtain the detection sub-result of the transaction to be detected in accordance with the detection axiom; Based on each of the detection sub-results, the detection result of the transaction to be detected is determined.

8. The method according to claim 7, characterized in that, The time information includes the start timestamp and commit timestamp of the transaction to be detected. The step of determining the data to be detected corresponding to the detection axiom based on the transaction identifier and the time information includes: When the detection axiom is a session axiom, based on the identifier of the transaction to be detected, obtain the historical commit timestamp and historical transaction identifier of the previous transaction of the transaction to be detected; The identifier of the transaction to be detected, the start timestamp of the transaction to be detected, the historical commit timestamp of the previous transaction, and the historical transaction identifier are determined as the data to be detected corresponding to the session axiom.

9. The method according to claim 8, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: When the difference between the identifier of the transaction to be detected and the identifier of the historical transaction is a first preset value, and the start timestamp of the transaction to be detected is greater than the historical commit timestamp, the detection sub-result of the transaction to be detected for the session axiom is determined to be a successful detection. When the difference between the identifier of the transaction to be detected and the identifier of the historical transaction is not a first preset value, or when the start timestamp of the transaction to be detected is less than or equal to the historical submission timestamp, the detection sub-result of the transaction to be detected for the session axiom is determined to be a failed detection.

10. The method according to claim 7, characterized in that, The step of determining the data to be detected corresponding to the detection axiom based on the identifier of the transaction to be detected and the time information includes: When the axiom to be detected is the first internal consistency axiom, the operation information set of the transaction to be detected is obtained based on the transaction identifier to be detected, and the first target operation information is determined from the operation information set. The first target operation information is the operation information for the non-first read operation of the first target key. Retrieve the first value corresponding to the first target key from the first internal list; The first target operation information and the first value are determined as the data to be detected corresponding to the first internal consistency axiom.

11. The method according to claim 10, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: Obtain the first read value of the first target key from the first target operation information; When the first read value is the same as the first value, the detection sub-result of the transaction to be detected against the first internal consistency axiom is determined to be a successful detection; When the first read value is different from the first value, the detection sub-result of the transaction to be detected against the first internal consistency axiom is determined to be a failed detection.

12. The method according to claim 7, characterized in that, The step of determining the data to be detected corresponding to the detection axiom based on the identifier of the transaction to be detected and the time information includes: When the axiom to be detected is the first external consistency axiom, the operation information set of the transaction to be detected is obtained based on the transaction identifier to be detected, and the second target operation information is determined from the operation information set. The second target operation information is the operation information of the first read operation for the second target key. Retrieve the second value corresponding to the second target key from the first external list; The second target operation information and the second value are determined as the data to be detected corresponding to the first external consistency axiom.

13. The method according to claim 12, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: Obtain the second read value of the second target key from the second target operation information; When the second read value and the second value are the same, it is determined that the detection sub-result of the transaction to be detected against the first external consistency axiom is detected as passed; When the second read value and the second value are different, the detection sub-result of the transaction to be detected against the first external consistency axiom is determined to be a failed detection.

14. The method according to claim 7, characterized in that, The step of determining the data to be detected corresponding to the detection axiom based on the identifier of the transaction to be detected and the time information includes: When the axiom to be detected is the first conflict-free axiom, the set of operation information of the transaction to be detected is obtained based on the transaction identifier to be detected; Traverse the set of operation information. When the third target operation information is encountered, add the third target key and the transaction identifier to be detected in the third target operation information to the first run list. The third target operation information is the operation information of a write operation. When the submission of the transaction to be detected is determined based on the time information, the third target key and the identifier of the transaction to be detected are deleted from the first running list to obtain an updated first running list; The updated first running list is determined as the data to be detected corresponding to the first conflict-free axiom.

15. The method according to claim 14, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: When the updated first run list is empty, the detection sub-result of the transaction to be detected for the first conflict-free axiom is determined to be a successful detection; When the updated first run list is not empty, the detection sub-result of the transaction to be detected for the first conflict-free axiom is determined to be a failed detection.

16. The method according to claim 14, characterized in that, The method further includes: When the time information determines that the transaction to be detected has been committed, the first write value of the third target key is obtained from the third target operation information; Update the value of the third target key in the first internal list to the first write value; Update the value of the third target key in the first external list to the first write value.

17. The method according to claim 7, characterized in that, The step of determining the data to be detected corresponding to the detection axiom based on the identifier of the transaction to be detected and the time information includes: When the axiom to be detected is the second internal consistency axiom, the operation information set of the transaction to be detected is obtained based on the transaction identifier to be detected, and the fourth target operation information is determined from the operation information set. The fourth target operation information is the operation information for the non-first read operation of the fourth target key. Based on the time information, determine the previous committed transaction of the transaction to be detected, and obtain the fourth value corresponding to the fourth target key from the second internal list corresponding to the previous committed transaction; The fourth target operation information and the fourth value are determined as the data to be detected corresponding to the second internal consistency axiom.

18. The method according to claim 17, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: Obtain the third read value of the fourth target key from the fourth target operation information; When the third read value and the fourth value are the same, the detection sub-result of the transaction to be detected against the second internal consistency axiom is determined to be a successful detection; When the third read value and the fourth value are different, the detection sub-result of the transaction to be detected against the second internal consistency axiom is determined to be a failed detection.

19. The method according to claim 7, characterized in that, The step of determining the data to be detected corresponding to the detection axiom based on the identifier of the transaction to be detected and the time information includes: When the axiom to be detected is the second external consistency axiom, the operation information set of the transaction to be detected is obtained based on the transaction identifier to be detected, and the fifth target operation information is determined from the operation information set. The fifth target operation information is the operation information of the first read operation for the fifth target key. Based on the time information, determine the previous committed transaction of the transaction to be detected, and obtain the fifth value corresponding to the fifth target key from the second external list corresponding to the previous committed transaction; The fifth target operation information and the fifth value are determined as the data to be detected corresponding to the second external consistency axiom.

20. The method according to claim 19, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: Obtain the fourth read value of the fifth target key from the fifth target operation information; When the fourth read value and the fifth value are the same, the detection sub-result of the transaction to be detected against the second external consistency axiom is determined to be a successful detection; When the fourth read value and the fifth value are different, the detection sub-result of the transaction to be detected against the second external consistency axiom is determined to be a failed detection.

21. The method according to claim 7, characterized in that, The step of determining the data to be detected corresponding to the detection axiom based on the identifier of the transaction to be detected and the time information includes: When the axiom to be detected is the second conflict-free axiom, the previous committed transaction of the transaction to be detected is determined based on the time information; Based on the identifier of the transaction to be detected, obtain the set of operation information of the transaction to be detected; Traverse the set of operation information. When the sixth target operation information is encountered, add the sixth target key and the transaction identifier to be detected in the sixth target operation information to the second run list corresponding to the previous committed transaction. The sixth target operation information is the operation information of the write operation. When it is determined that the transaction to be detected has been committed, the sixth target key and the identifier of the transaction to be detected are deleted from the second running list to obtain an updated second running list; The updated second running list is determined as the data to be detected corresponding to the second conflict-free axiom.

22. The method according to claim 21, characterized in that, The step of detecting the transaction based on the data to be detected, and obtaining the detection sub-result of the transaction to be detected according to the detection axiom, includes: When the updated second run list is empty, the detection sub-result of the transaction to be detected for the second conflict-free axiom is determined to be a successful detection; When the updated second run list is not empty, the detection sub-result of the transaction to be detected for the second conflict-free axiom is determined to be a failed detection.

23. The method according to claim 21, characterized in that, The method further includes: Based on the time information of the transaction to be detected, a third transaction is determined, wherein there is an overlapping time interval between the time information of the third transaction and the time information of the transaction to be detected. The third transaction is detected based on its time information, identifier, and the second conflict-free axiom, resulting in a detection sub-result of the third transaction against the second conflict-free axiom.

24. The method according to claim 21, characterized in that, The method further includes: When the commit of the transaction to be detected is detected, the start timestamp and commit timestamp in the time information are inserted into the third timestamp sequence to obtain the updated third timestamp sequence, which includes the start timestamp and commit timestamp of the detected transaction. Starting from the commit timestamp of the transaction to be detected in the updated third timestamp sequence, the system iterates backward. When the system reaches the start timestamp, the fourth transaction corresponding to the start timestamp is detected based on the second external consistency axiom, and a new detection sub-result of the fourth transaction based on the second external consistency axiom is obtained. The detection result of the fourth transaction is updated based on the new detection sub-result of the fourth transaction for the second external consistency axiom.

25. The method according to claim 24, characterized in that, The method further includes: When traversing to the commit timestamp, obtain the third external list corresponding to the fifth transaction corresponding to the commit timestamp; Update the value of the sixth target key in the third external list to the second write value.

26. A transaction detection device, characterized in that, The device includes: The first acquisition module acquires a preset detection mode and isolation level, wherein the detection mode is either online mode or offline mode; The first determining module is used to determine the transaction to be detected based on the detection mode, and to obtain the transaction identifier and time information of the transaction to be detected; The second determining module is used to determine at least one detection axiom corresponding to the transaction to be detected based on the detection mode and the isolation level; The transaction detection module is used to detect the transaction to be detected based on the transaction identifier, the time information, and each of the detection axioms, and to obtain the detection result of the transaction to be detected.

27. A computer device, characterized in that, The computer device includes: Memory is used to store executable instructions for a computer; A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the method according to any one of claims 1 to 25.

28. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, they implement the method described in any one of claims 1 to 25.

29. A computer program product comprising computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, they implement the method according to any one of claims 1 to 25.