Transaction visibility judgment method, device, equipment and storage medium

By determining the visibility of transactions in a distributed database and using the target snapshot sequence number and commit sequence number to optimize the processing flow of single-node transactions, the problem of low efficiency in distributed transaction processing is solved and more efficient execution is achieved.

CN116302371BActive Publication Date: 2025-09-19SHANGHAI DAMENG DATABASE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310272390.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-17
Publication Date
2025-09-19
Estimated Expiration
2043-03-17

AI Technical Summary

Technical Problem

In the prior art, when a distributed transaction involves only one data node, the processing efficiency is low, which affects the execution efficiency of the distributed transaction.

Method used

By determining the type of the current transaction, obtaining the target snapshot sequence number and target commit sequence number, and judging whether the record is visible, the visibility judgment process of single-node transactions is optimized to avoid frequent inter-node communication.

Benefits of technology

It improves the processing efficiency of distributed transactions in single-node situations, reduces communication overhead, and improves execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116302371B_ABST
    Figure CN116302371B_ABST
Patent Text Reader

Abstract

The present invention discloses a transaction visibility judgment method, apparatus, device and storage medium. The method includes: determining the current transaction and the current execution statement of the current transaction; determining the transaction type of the current transaction when executing the current execution statement; obtaining the transaction corresponding to the record involved in the current execution statement, and determining the target snapshot sequence number and the target commit sequence number according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record; and judging whether the record and the current execution statement are visible according to the target snapshot sequence number and the target commit sequence number. This method can improve the execution efficiency of distributed transactions by determining the target snapshot sequence number and the target commit sequence number according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and judging whether the record is visible according to the target snapshot sequence number and the target commit sequence number.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of databases, and in particular to a transaction visibility determination method, apparatus, device, and storage medium. Background Art

[0002] To ensure transaction consistency in a distributed environment, the metadata node (MD) must provide nodes with globally unique commit sequence numbers. This ensures that distributed transactions are visible or invisible to the same active transaction on different data nodes (DNs). Distributed transactions must ensure atomicity, requiring either all commits or all rollbacks on different nodes. Therefore, distributed transactions require a two-phase commit. These two issues require frequent communication during distributed transaction execution, and this increased communication overhead significantly impacts distributed transaction efficiency.

[0003] When a distributed transaction involves only one data node DN, it is essentially no different from a single-machine database transaction. However, when processing single-node distributed transactions, the existing technology determines the visibility of the single-node distributed transaction through the global commit sequence number, requiring frequent inter-node communication and low processing efficiency. Summary of the Invention

[0004] The present invention provides a transaction visibility judgment method, apparatus, device and storage medium to solve the problem of low processing efficiency when a distributed transaction involves only one data node in the prior art, thereby improving the execution efficiency of the distributed transaction.

[0005] According to one aspect of the present invention, a transaction visibility determination method is provided, which is applied to a data node. The method includes:

[0006] Determining a current transaction and a currently executed statement of the current transaction;

[0007] Determining a transaction type of the current transaction when executing the current execution statement;

[0008] Obtaining a transaction corresponding to the record involved in the currently executed statement, and determining a target snapshot sequence number and a target commit sequence number according to a transaction type of the current transaction and a transaction type of the transaction corresponding to the record;

[0009] Whether the record is visible is determined according to the target snapshot sequence number and the target commit sequence number.

[0010] According to another aspect of the present invention, a transaction visibility determination device is provided, the device comprising:

[0011] A first determining module, configured to determine a transaction type of the current transaction when executing the current execution statement;

[0012] A second determining module is used to determine the transaction type of the currently executed statement;

[0013] an acquisition module, configured to acquire a transaction corresponding to a record involved in the currently executed statement, and determine a target snapshot sequence number and a target commit sequence number according to a transaction type of the current transaction and a transaction type of a transaction corresponding to the record;

[0014] A judgment module is used to judge whether the record is visible according to the target snapshot sequence number and the target commit sequence number.

[0015] According to another aspect of the present invention, there is provided an electronic device, comprising: at least one processor; and

[0016] a memory communicatively connected to the at least one processor; wherein,

[0017] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the transaction visibility determination method described in any embodiment of the present invention.

[0018] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the transaction visibility determination method described in any embodiment of the present invention when executed.

[0019] A transaction visibility judgment method, apparatus, device, and storage medium according to an embodiment of the present invention include: determining a current transaction and a current execution statement of the current transaction; determining the transaction type of the current transaction when executing the current execution statement; obtaining the transaction corresponding to the record involved in the current execution statement, and determining a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record; and judging whether the record and the current execution statement are visible based on the target snapshot sequence number and the target commit sequence number. This method solves the problem of low processing efficiency in the prior art when a distributed transaction involves only one data node by determining the target snapshot sequence number and the target commit sequence number based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and judging whether the record is visible based on the target snapshot sequence number and the target commit sequence number. This can improve the execution efficiency of distributed transactions.

[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A flowchart of a transaction visibility determination method provided in the first embodiment of the present invention;

[0023] Figure 2 A flowchart of a transaction visibility determination method provided in the second embodiment of the present invention;

[0024] Figure 3 A schematic diagram of the structure of a transaction visibility determination device provided in the third embodiment of the present invention;

[0025] Figure 4 A structural diagram of an electronic device for a transaction visibility determination method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only embodiments of a part of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present invention. It should be understood that the various steps described in the method implementation mode of the present invention can be performed in different orders and / or in parallel. In addition, the method implementation mode may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0027] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.

[0028] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] It should be noted that the modifications of "one" and "multiple" mentioned in the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0030] The names of the messages or information exchanged between multiple devices in the embodiments of the present invention are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0031] Example 1

[0032] Figure 1 A flowchart of a transaction visibility determination method provided in Example 1 of the present invention is provided. The method can be applied to situations where the visibility of a transaction is determined in a distributed database. The method can be executed by a transaction visibility determination device, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device. In this embodiment, the electronic device includes but is not limited to: computers and other devices.

[0033] like Figure 1 As shown, a transaction visibility determination method provided in the first embodiment of the present invention is applied to a data node and includes the following steps:

[0034] S110: Determine a current transaction and a currently executed statement of the current transaction.

[0035] A transaction is a series of rigorous operations within an application. All operations must complete successfully, otherwise all changes made in each operation will be undone. Transactions are atomic; either all operations within a transaction succeed or none of them do. Transactions have four properties: atomicity, consistency, isolation, and durability. The current transaction is the transaction currently being executed, and a transaction can consist of one or more SQL statements. The currently executing statement is the statement currently being executed, or a statement within the current transaction. A statement can involve a single node or multiple nodes during execution, and the nodes involved in the statement execution can be data nodes.

[0036] In this embodiment, after receiving the information sent by the computing node, the data node can determine the current transaction being executed based on the transaction information carried in the information, and use the statement in the statement currently scheduled by the computing node as the current execution statement.

[0037] Furthermore, determining the current transaction and the current execution statement of the current transaction includes: receiving transaction information sent by a computing node; determining the transaction corresponding to the transaction information as the current transaction; and using the statement currently scheduled by the computing node as the current execution statement.

[0038] The computing node can receive and process various requests from the client. The transaction information may include a transaction identifier, a transaction type identifier, and other information, which is not limited in this embodiment.

[0039] In this embodiment, after receiving transaction information sent by a compute node, the data node may use the transaction corresponding to the transaction information as the current transaction. After determining the current transaction, the data node may use the statement currently being scheduled by the compute node as the currently executed statement. For example, if the current transaction includes multiple statements, such as statement A, statement B, and statement C, when the compute node schedules statement A, the data node may use statement A as the currently executed statement.

[0040] S120: Determine the transaction type of the current transaction when executing the current execution statement.

[0041] The transaction type can be considered as information reflecting the type of transaction, and the transaction type can include single-node transactions and global transactions (multi-node transactions). A single-node transaction can be a transaction involving only one node, and a global transaction can be a transaction involving multiple nodes.

[0042] In this embodiment, when the currently executing statement is executed, the data node can determine the transaction type of the current transaction based on the transaction type identifier marked by the compute node. If a transaction includes multiple statements, the transaction type of the current transaction may not be the same when different statements are scheduled. Once the scheduled statement involves multiple nodes, the compute node no longer marks the current transaction as a single-node transaction.

[0043] For example, if the current transaction includes statement A, statement B, and statement C, where statements A and C involve a single node, and statement B involves multiple nodes. Assuming that the statements are executed in the order of statement A, statement B, and statement C, then when the currently executed statement is statement A, the transaction type of the current transaction is a single-node transaction. When statement B is executed, the transaction type of the current transaction is a global transaction, and the node is no longer marked as a single-node transaction. When statement C is subsequently executed, the transaction type of the current transaction is also a global transaction.

[0044] Furthermore, determining the transaction type of the current transaction when executing the currently executed statement includes: obtaining a transaction type identifier carried in the transaction information; if the transaction type identifier is a single-node identifier, determining that the transaction type of the current transaction is a single-node transaction; otherwise, the transaction type of the current transaction is a global transaction.

[0045] The transaction type identifier may be a transaction type identifier, through which it can be determined whether the transaction is a single-node transaction. The transaction type identifier may be a computing node tag.

[0046] In this embodiment, when determining the transaction type of the current transaction, the transaction type identifier carried in the transaction information may be obtained, and the transaction type of the current transaction may be directly determined according to the transaction type identifier.

[0047] S130: Acquire a transaction corresponding to the record involved in the currently executed statement, and determine a target snapshot sequence number and a target commit sequence number according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record.

[0048] The record can be the execution object of the currently executed statement, or a record stored in the database. A record corresponds to a transaction. The transaction corresponding to a record can be understood as a previously scheduled transaction whose execution object is the record. For example, the transaction corresponding to a record can be a transaction that modifies the record. The target snapshot sequence number can be the snapshot sequence number used to determine visibility. The target commit sequence number can be the commit sequence number used to determine visibility. The snapshot sequence number provides a static view to control data visibility. The snapshot sequence number defines which data is visible to which transactions and which is not.

[0049] In this embodiment, a currently executed statement may involve one or more records. After determining the records involved in the currently executed statement, the transaction corresponding to the record can be determined based on the correspondence between records and transactions stored in the database. The transaction type of the current transaction or the transaction corresponding to the record can be determined to be a single-node transaction. If so, visibility can be determined using the local snapshot sequence number and the local commit sequence number.

[0050] For example, if the records involved in the currently executed statement include record A and record B, and in the database, record A corresponds to transaction A and record B corresponds to transaction B, then the transactions corresponding to the currently executed statement can be determined as transaction A and transaction B, and the visibility of record A and record B can be determined separately.

[0051] S140: Determine whether the record is visible according to the target snapshot sequence number and the target commit sequence number.

[0052] In this embodiment, after obtaining the target snapshot sequence number and the target commit sequence number, whether the record is visible can be determined based on the size relationship between the target snapshot sequence number and the target commit sequence number. For example, if the target snapshot sequence number is greater than or equal to the target commit sequence number, it means that the record is visible and the record can be returned at this time.

[0053] For example, a table t contains two records: (1, 1) and (100, 100). If the currently executed statement queries table t, and if record (100, 100) is not visible but record (1, 1) is, the query statement returns the result (1, 1). If both records are not visible, the query statement returns an empty result.

[0054] A transaction visibility determination method is provided in a first embodiment of the present invention, the method comprising: determining a current transaction and a current execution statement of the current transaction; determining the transaction type of the current transaction when executing the current execution statement; obtaining the transaction corresponding to the record involved in the current execution statement, and determining a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record; and determining whether the record and the current execution statement are visible based on the target snapshot sequence number and the target commit sequence number. This method solves the problem of low processing efficiency in the prior art when a distributed transaction involves only one data node by determining the target snapshot sequence number and the target commit sequence number based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and determining whether the record is visible based on the target snapshot sequence number and the target commit sequence number, thereby improving the execution efficiency of distributed transactions.

[0055] Based on the above embodiment, a modified embodiment of the above embodiment is proposed. It should be noted that, in order to simplify the description, only the differences from the above embodiment are described in the modified embodiment.

[0056] In one embodiment, the method further comprises:

[0057] After all currently executed statements in the current transaction are scheduled, register a local commit sequence number in the local transaction registration information;

[0058] If the current transaction is a single-node transaction, a local commit is performed; otherwise, a two-phase commit is performed.

[0059] The local transaction registration information may be transaction registration information stored locally on the node, which may contain the commit sequence number and other information for each transaction. The local commit sequence number may be the commit sequence number registered locally on the data node. Local commit may be performed directly on the data node. Two-phase commit may involve performing a pre-commit followed by a commit after the pre-commit is complete. This embodiment does not elaborate on this.

[0060] In this embodiment, after all statements in the current transaction are scheduled, the transaction can be committed. Before committing a transaction, it is necessary to determine whether the current transaction is a single-node transaction. If all statements in the current transaction involve the same node, the current transaction is a single-node transaction and a local commit can be performed. Otherwise, a two-phase commit is performed. When committing a transaction, regardless of whether the current transaction is a single-node transaction, the current local commit sequence number must be registered in the local transaction registration information, and the local commit sequence number must be increased by 1. This will be used to determine visibility when querying single-node transactions during subsequent transaction scheduling.

[0061] The single-node transaction execution process in this embodiment omits the multiple communications between compute nodes and data nodes during a two-phase commit, as well as the multiple communications between compute nodes and data nodes, and between data nodes and metadata nodes, when obtaining the global commit sequence number. This significantly improves execution efficiency. Furthermore, since single-node transactions are committed only at a single node, the issue of distributed transactions being committed at different nodes while others are not will not arise, eliminating the need for a two-phase commit. Since only a single node is involved, the visibility of the same transaction will not differ across different nodes, eliminating the need for visibility determination based on the global commit sequence number.

[0062] Example 2

[0063] Figure 2 This is a flowchart of a transaction visibility determination method provided by the second embodiment of the present invention. This second embodiment is optimized based on the above embodiments. For details not yet fully described in this embodiment, please refer to the first embodiment.

[0064] like Figure 2 As shown, a transaction visibility determination method provided in the second embodiment of the present invention is applied to a data node and includes the following steps:

[0065] S210: Determine a current transaction and a currently executed statement of the current transaction.

[0066] S220: Determine the transaction type of the current transaction when executing the current execution statement.

[0067] S230: Obtain the transaction corresponding to the record involved in the currently executed statement.

[0068] S240: Determine a corresponding snapshot sequence number based on the transaction type of the current transaction.

[0069] In this embodiment, when the transaction type of the current transaction is different, the target snapshot sequence number and target commit sequence number that may be used in visibility judgment may not be different. Therefore, it is necessary to first obtain the snapshot sequence number that may be used according to the transaction type of the current transaction.

[0070] When scheduling the execution of the current statement, this embodiment can directly obtain the global commit sequence number as long as there are statements involving different nodes in the current transaction, and the current transaction is no longer recorded as a single-node transaction.

[0071] Furthermore, determining a corresponding snapshot sequence number based on the transaction type of the current transaction includes:

[0072] If the transaction type of the current transaction is a single-node transaction, the corresponding snapshot sequence number is a local snapshot sequence number; otherwise, the corresponding snapshot sequence number is a global snapshot sequence number and a local snapshot sequence number.

[0073] The local snapshot sequence number may be a snapshot sequence number recorded locally on the node, and the global snapshot sequence number may be a snapshot sequence number shared by all nodes.

[0074] In this embodiment, if the current transaction is a single-node transaction, it is necessary to obtain the local snapshot sequence number locally on the data node; if the current transaction is a global transaction, it is necessary to obtain both the global snapshot sequence number and the local snapshot sequence number. The data node can obtain the global snapshot sequence number from the transaction information received from the computing node and obtain the local snapshot sequence number locally.

[0075] S250: Determine a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number.

[0076] In this embodiment, if any of the current transaction and the transaction corresponding to the record is a single-node transaction, visibility can be determined by the local snapshot sequence number and the local commit sequence number, and the local snapshot sequence number and the local commit sequence number are used as the target snapshot sequence number and the target commit sequence number.

[0077] Furthermore, determining a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number includes:

[0078] If the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, the local snapshot sequence number of the current transaction is determined as the target snapshot sequence number, and the local commit sequence number of the transaction corresponding to the record is determined as the target commit sequence number; otherwise, the global snapshot sequence number is determined as the target snapshot sequence number, and the global commit sequence number is determined as the target commit sequence number.

[0079] The local commit sequence number can be a commit sequence number recorded locally on the node. The local commit sequence number can be used to sequentially count transaction commits on the local node. Each node stores its own local commit sequence number. The global commit sequence number can be a commit sequence number shared by all nodes.

[0080] In this embodiment, if the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, it is essentially the same as a single-node database transaction. The global commit sequence number can be used to determine visibility, so the local snapshot sequence number of the current transaction can be used as the target snapshot sequence number, and the local commit sequence number of the transaction corresponding to the record can be used as the target commit sequence number. Otherwise, the global snapshot sequence number and global commit sequence number can be directly obtained to serve as the target snapshot sequence number and target commit sequence number.

[0081] S260: Determine whether the record is visible according to the target snapshot sequence number and the target commit sequence number.

[0082] A transaction visibility judgment method is provided in a second embodiment of the present invention, the method comprising: determining a current transaction and a current execution statement of the current transaction; determining the transaction type of the current transaction when executing the current execution statement; obtaining the transaction corresponding to the record involved in the current execution statement; determining the corresponding snapshot sequence number based on the transaction type of the current transaction; determining a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number; and judging whether the record is visible based on the target snapshot sequence number and the target commit sequence number. The method further determines the target snapshot sequence number and the target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number, so that the target snapshot sequence number and the target commit sequence number used for judging visibility can be determined based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, solving the problem of low processing efficiency when a distributed transaction involves only one data node in the prior art, thereby improving the execution efficiency of distributed transactions.

[0083] Example 3

[0084] Figure 3 This is a structural diagram of a transaction visibility judgment device provided in Example 3 of the present invention. The device can be used to judge the visibility of transactions in a distributed database, wherein the device can be implemented by software and / or hardware and is generally integrated on an electronic device.

[0085] like Figure 3 As shown, the device includes:

[0086] A first determining module 310 is configured to determine a transaction type of the current transaction when executing the current execution statement;

[0087] A second determining module 320 is configured to determine the transaction type of the currently executed statement;

[0088] An acquisition module 330 is configured to acquire a transaction corresponding to a record involved in the currently executed statement, and determine a target snapshot sequence number and a target commit sequence number based on a transaction type of the current transaction and a transaction type of a transaction corresponding to the record;

[0089] The judgment module 340 is configured to judge whether the record is visible according to the target snapshot sequence number and the target commit sequence number.

[0090] The third embodiment provides a transaction visibility judgment device, comprising: a first determination module for determining the transaction type of the current transaction when executing the current execution statement; a second determination module for determining the transaction type of the current execution statement; an acquisition module for acquiring the transaction corresponding to the record involved in the current execution statement, and determining a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record; and a judgment module for judging whether the record is visible based on the target snapshot sequence number and the target commit sequence number. This device solves the problem of low processing efficiency in the prior art when a distributed transaction involves only one data node by determining the target snapshot sequence number and the target commit sequence number based on the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and judging whether the record is visible based on the target snapshot sequence number and the target commit sequence number. This can improve the execution efficiency of distributed transactions.

[0091] Furthermore, the first determining module 310 includes:

[0092] A receiving unit, configured to receive transaction information sent by a computing node;

[0093] a transaction determining unit, configured to determine the transaction corresponding to the transaction information as the current transaction;

[0094] The statement determination element is used to set the statement currently scheduled by the computing node as the current execution statement.

[0095] Furthermore, the second determining module 320 includes:

[0096] an identification obtaining unit, configured to obtain a transaction type identification carried in the transaction information;

[0097] The transaction type determining unit is configured to determine that the transaction type of the current transaction is a single-node transaction if the transaction type identifier is a single-node identifier; otherwise, the transaction type of the current transaction is a global transaction.

[0098] Furthermore, the acquisition module 330 includes:

[0099] a snapshot sequence number determining unit, configured to determine a corresponding snapshot sequence number based on a transaction type of the current transaction;

[0100] The target sequence number determining unit is configured to determine a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number.

[0101] Furthermore, the snapshot sequence number determination unit includes:

[0102] If the transaction type of the current transaction is a single-node transaction, the corresponding snapshot sequence number is a local snapshot sequence number; otherwise, the corresponding snapshot sequence number is a global snapshot sequence number and a local snapshot sequence number.

[0103] Furthermore, the target sequence number determination unit includes:

[0104] If the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, the local snapshot sequence number of the current transaction is determined as the target snapshot sequence number, and the local commit sequence number of the transaction corresponding to the record is determined as the target commit sequence number; otherwise, the global snapshot sequence number is determined as the target snapshot sequence number, and the global commit sequence number is determined as the target commit sequence number.

[0105] Furthermore, the device further comprises:

[0106] After all currently executed statements in the current transaction are scheduled, register a local commit sequence number in the local transaction registration information;

[0107] If the current transaction is a single-node transaction, a local commit is performed; otherwise, a two-phase commit is performed.

[0108] The above-mentioned transaction visibility judgment device can execute the transaction visibility judgment method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0109] Example 4

[0110] Figure 4 A schematic diagram of the structure of an electronic device that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0111] like Figure 4As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0112] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0113] Processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any other suitable processor, controller, microcontroller, etc. Processor 11 executes the various methods and processes described above, such as the transaction visibility determination method.

[0114] In some embodiments, the transaction visibility determination method can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the transaction visibility determination method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to execute the transaction visibility determination method in any other appropriate manner (for example, by means of firmware).

[0115] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0116] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0117] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0118] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0119] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0120] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0121] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0122] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A transaction visibility judgment method, characterized in that: Applied to a data node, the method includes: Determining a current transaction and a currently executed statement of the current transaction; Determining a transaction type of the current transaction when executing the current execution statement; Obtaining a transaction corresponding to a record involved in the currently executed statement, and determining a target snapshot sequence number and a target commit sequence number based on a transaction type of the current transaction and a transaction type of a transaction corresponding to the record; the record is an execution target of the currently executed statement; Determining whether the record is visible based on the magnitude relationship between the target snapshot sequence number and the target commit sequence number; Determining a target snapshot sequence number and a target commit sequence number according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record includes: Determine a corresponding snapshot sequence number based on the transaction type of the current transaction; Determining a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number includes: If the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, the local snapshot sequence number of the current transaction is determined as the target snapshot sequence number, and the local commit sequence number of the transaction corresponding to the record is determined as the target commit sequence number; otherwise, the global snapshot sequence number is determined as the target snapshot sequence number, and the global commit sequence number is determined as the target commit sequence number.

2. The method according to claim 1, wherein determining a current transaction and a currently executed statement of the current transaction comprises: Receive transaction information sent by computing nodes; Determining the transaction corresponding to the transaction information as the current transaction; The statement currently scheduled by the compute node is used as the current execution statement.

3. The method according to claim 2, wherein determining the transaction type of the current transaction when executing the currently executed statement comprises: Obtaining a transaction type identifier carried in the transaction information; If the transaction type identifier is a single-node identifier, it is determined that the transaction type of the current transaction is a single-node transaction; otherwise, the transaction type of the current transaction is a global transaction.

4. The method according to claim 1, wherein determining a corresponding snapshot sequence number based on the transaction type of the current transaction comprises: If the transaction type of the current transaction is a single-node transaction, the corresponding snapshot sequence number is the local snapshot sequence number; Otherwise, the corresponding snapshot sequence numbers are the global snapshot sequence number and the local snapshot sequence number.

5. The method according to claim 1, further comprising: After all currently executed statements in the current transaction are scheduled, register a local commit sequence number in the local transaction registration information; If the current transaction is a single-node transaction, perform local commit; Otherwise, perform a two-phase commit.

6. A transaction visibility judgment device, characterized in that: The device comprises: A first determining module, configured to determine a current transaction and a currently executed statement of the current transaction; A second determining module is used to determine the transaction type of the current transaction when executing the current execution statement; an acquisition module, configured to acquire a transaction corresponding to a record involved in the currently executed statement, and determine a target snapshot sequence number and a target commit sequence number based on a transaction type of the current transaction and a transaction type of a transaction corresponding to the record; the record being an execution object of the currently executed statement; A judgment module, configured to judge whether the record is visible according to a magnitude relationship between the target snapshot sequence number and the target commit sequence number; Get modules, including: a snapshot sequence number determining unit, configured to determine a corresponding snapshot sequence number based on a transaction type of the current transaction; a target sequence number determining unit, configured to determine a target snapshot sequence number and a target commit sequence number based on the transaction type of the current transaction, the transaction type of the transaction corresponding to the record, and the snapshot sequence number; The target sequence number determination unit includes: If the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, the local snapshot sequence number of the current transaction is determined as the target snapshot sequence number, and the local commit sequence number of the transaction corresponding to the record is determined as the target commit sequence number; otherwise, the global snapshot sequence number is determined as the target snapshot sequence number, and the global commit sequence number is determined as the target commit sequence number.

7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor. The computer program is executed by the at least one processor to enable the at least one processor to execute the transaction visibility determination method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the transaction visibility determination method according to any one of claims 1 to 5 when executed.

Citation Information

Patent Citations

  • Execution method, device and equipment of distributed transaction and storage medium

    CN110716793A

  • Transaction processing method and device, computer equipment and storage medium

    CN111338766A