CN116302371A - Transaction visibility judging method, device, equipment and storage medium - Google Patents

Transaction visibility judging method, device, equipment and storage medium Download PDF

Info

Publication number
CN116302371A
CN116302371A CN202310272390.7A CN202310272390A CN116302371A CN 116302371 A CN116302371 A CN 116302371A CN 202310272390 A CN202310272390 A CN 202310272390A CN 116302371 A CN116302371 A CN 116302371A
Authority
CN
China
Prior art keywords
transaction
sequence number
current
target
determining
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310272390.7A
Other languages
Chinese (zh)
Inventor
陶志远
郭琰
韩朱忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Dameng Database Co Ltd
Original Assignee
Shanghai Dameng Database Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Dameng Database Co Ltd filed Critical Shanghai Dameng Database Co Ltd
Priority to CN202310272390.7A priority Critical patent/CN116302371A/en
Publication of CN116302371A publication Critical patent/CN116302371A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a transaction visibility judging method, device, equipment and storage medium. The method comprises the following steps: determining a current transaction and a current execution statement of the current transaction; determining a transaction type of the current transaction when the current execution statement is executed; acquiring a transaction corresponding to a record related to the current execution statement, and 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; and judging whether the current execution statement recorded is visible or not according to the target snapshot sequence number and the target commit sequence number. According to the method, the target snapshot sequence number and the target commit sequence number are determined according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and whether the record is visible or not is judged according to the target snapshot sequence number and the target commit sequence number, so that the execution efficiency of the distributed transaction can be improved.

Description

Transaction visibility judging method, device, equipment and storage medium
Technical Field
The embodiment of the invention relates to the field of databases, in particular to a transaction visibility judging method, device, equipment and storage medium.
Background
The distributed environment needs to ensure the consistency of the transaction, and the metadata node MD must provide a globally unique commit sequence number for the node, so that the distributed transaction is visible or invisible to the same active transaction on different data nodes DNs. Distributed transactions need to guarantee atomicity, either all commit or all rollback at different nodes, so distributed transactions need to do two-phase commit. The two problems cause frequent communication in the execution process of the distributed transaction, and the excessive communication cost naturally and obviously affects the execution efficiency of the distributed transaction.
When the distributed transaction only relates to one data node DN, the distributed transaction is basically indistinguishable from a single-machine database transaction, but when the single-node distributed transaction is processed in the prior art, the visibility of the single-node distributed transaction is judged through the global commit sequence number, the inter-node communication is required to be frequently carried out, and the processing efficiency is low.
Disclosure of Invention
The invention provides a transaction visibility judging method, device, equipment and storage medium, which are used for solving the problem of low processing efficiency when a distributed transaction only relates to one data node in the prior art, so that the execution efficiency of the distributed transaction can be improved.
According to an aspect of the present invention, there is provided a transaction visibility determination method, applied to a data node, the method comprising:
determining a current transaction and a current execution statement of the current transaction;
determining a transaction type of the current transaction when the current execution statement is executed;
acquiring a transaction corresponding to a record related to the current execution statement, and 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;
and judging whether the record is visible or not according to the target snapshot sequence number and the target commit sequence number.
According to another aspect of the present invention, there is provided a transaction visibility judging device including:
a first determining module, configured to determine a transaction type of the current transaction when the current execution statement is executed;
a second determining module, configured to determine a transaction type of the current execution statement;
the acquisition module is used for acquiring the transaction corresponding to the record related to the current execution statement, and 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;
and the judging module is used for judging whether the record is visible or not according to the target snapshot sequence number and the target submission sequence number.
According to another aspect of the present invention, there is provided an electronic apparatus including: at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the transaction visibility determination method according to any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to implement the transaction visibility determination method according to any one of the embodiments of the present invention when executed.
The embodiment of the invention discloses a transaction visibility judging method, a device, equipment and a storage medium, wherein the method comprises the following steps: determining a current transaction and a current execution statement of the current transaction; determining a transaction type of the current transaction when the current execution statement is executed; acquiring a transaction corresponding to a record related to the current execution statement, and 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; and judging whether the current execution statement recorded is visible or not according to the target snapshot sequence number and the target commit sequence number. According to the method, the target snapshot sequence number and the target commit sequence number are determined according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and whether the record is visible or not is judged according to the target snapshot sequence number and the target commit sequence number, so that the problem that the processing efficiency is low when the distributed transaction only relates to one data node in the prior art is solved, and the execution efficiency of the distributed transaction can be improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flow chart of a transaction visibility judging method according to a first embodiment of the present invention;
fig. 2 is a flow chart of a transaction visibility judging method according to a second embodiment of the present invention;
fig. 3 is a schematic structural diagram of a transaction visibility determination device according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to a transaction visibility determination method in an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention. It should be understood that the various steps recited in the method embodiments of the present invention may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the invention is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is 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"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those skilled in the art will appreciate that "one or more" is intended to be construed as "one or more" unless the context clearly indicates otherwise.
The names of messages or information interacted between the devices in the embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of such messages or information.
Example 1
Fig. 1 is a flow chart of a transaction visibility determination method according to a first embodiment of the present invention, which is applicable to a case of determining visibility of a transaction in a distributed database, and the method may be performed by a transaction visibility determination device, where the device may be implemented by software and/or hardware and is generally integrated on an electronic device, and in this embodiment, the electronic device includes but is not limited to: a computer, etc.
As shown in fig. 1, a transaction visibility determination method provided in an embodiment of the present invention is applied to a data node, and includes the following steps:
s110, determining a current transaction and a current execution statement of the current transaction.
Where a transaction is a series of strict operations in an application, all operations must be completed successfully, otherwise all changes made in each operation are undone. Transactions are atomic, and a series of operations in a transaction are either all successful or none. The transaction has 4 attributes: atomicity, consistency, isolation, durability. The current transaction may be a transaction being executed at the current time, and a transaction may be composed of one or more SQL statements. The currently executing statement may be a statement currently being executed, and the currently executing statement may be a statement in the current transaction. A statement may refer to a single node or to multiple nodes when executed, and the node to which the statement refers when executed may be a data node.
In this embodiment, after receiving the information sent by the computing node, the data node may determine, according to the transaction information carried in the information, a current transaction being executed, and use a statement in the statement currently scheduled by the computing node as a current execution statement.
Further, determining a current transaction and a 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 a current transaction; and taking the statement currently scheduled by the computing node as a current execution statement.
Wherein the computing node may receive and process various requests of the client. The transaction information may include information such as transaction identification, transaction type identification, etc., which is not limited in this embodiment.
In this embodiment, after receiving the transaction information sent by the computing node, the data node may use the transaction corresponding to the transaction information as a current transaction, and after determining the current transaction, may use the statement currently being scheduled by the computing node as a current execution statement. For example, if the current transaction includes multiple sentences, the multiple sentences are sentence a, sentence B, and sentence C, respectively. When the computing node schedules statement a, the data node may then take statement a as the current execution statement.
S120, determining the transaction type of the current transaction when executing the current execution statement.
The transaction type may be considered as information reflecting the type of transaction, and may include single-node transactions and global transactions (multi-node transactions). A single-node transaction may be a transaction involving only one node, and a global transaction may be a transaction involving multiple nodes.
In this embodiment, when the current execution statement is executed, the data node may determine the transaction type of the current transaction from the transaction type identification marked by the compute node. When a plurality of sentences are included in the transaction, the transaction types of the current transaction are not necessarily the same when different sentences are scheduled; once the scheduled statement involves multiple nodes, the computing node no longer marks the current transaction as a single-node transaction.
Illustratively, if the current transaction includes statement a, statement B, statement C, where statement a, statement C involves a single node and statement B involves multiple nodes. Assuming that the execution sequence of the statement is statement a, statement B and statement C in turn, when the current execution 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.
Further, the determining a transaction type of the current transaction when the current execution statement is executed includes: acquiring a transaction type identifier carried in the transaction information; and 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, determining that the transaction type of the current transaction is a global transaction.
The transaction type identifier may be a type identifier of a transaction, and it may be determined whether the transaction is a single-node transaction through the transaction type identifier. The transaction type identification may be computing node marked.
In this embodiment, when determining the transaction type of the current transaction, the transaction type identifier carried in the transaction information may be acquired, and the transaction type of the current transaction may be directly determined according to the transaction type identifier.
S130, acquiring a transaction corresponding to a record related to the current execution statement, and 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.
The record may be an execution object of the current execution statement, and the record may be a record stored in the database. One record corresponds to one transaction. A transaction corresponding to a record may be understood as a transaction for which an execution object was previously scheduled, e.g., a transaction corresponding to a record may be a transaction for which this record was modified. The target snapshot sequence number may be a snapshot sequence number used to determine visibility. The target commit sequence number may be a commit sequence number used to determine visibility. The snapshot sequence number is used to provide a static view to control the visibility of the data, and defines which data is visible to which transactions and not visible to which transactions.
In this embodiment, one current execution statement may relate to one or more records, and after determining a record related to the current execution statement, a transaction corresponding to the record may be determined according to a correspondence between the record stored in the database and the transaction, and whether a transaction type of the current transaction or a transaction type of the transaction corresponding to the record is a single-node transaction is determined. If yes, the visibility judgment can be performed through the local snapshot sequence number and the local commit sequence number.
For example, if the record related to the current execution statement includes record a and record B, record a corresponds to transaction a, and record B corresponds to transaction B in the database. The transaction corresponding to the current execution statement may be determined as transaction a and transaction B and the visibility of record a and record B may be determined, respectively.
And S140, judging whether the record is visible or not according to the target snapshot sequence number and the target submission sequence number.
In this embodiment, after the target snapshot sequence number and the target commit sequence number are obtained, whether the record is visible or not may be determined according to 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 is indicated that the record is visible, and at this time, the record may be returned.
Illustratively, there are two records (1, 1) and (100 ) in a table t. If the currently executing statement is a statement of the lookup table t, if the record (100 ) is not visible, the record (1, 1) is visible, and the query statement returns the result (1, 1). If neither record is visible, the query statement returns a null result.
The first embodiment of the invention provides a transaction visibility judging method, which comprises the following steps: determining a current transaction and a current execution statement of the current transaction; determining a transaction type of the current transaction when the current execution statement is executed; acquiring a transaction corresponding to a record related to the current execution statement, and 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; and judging whether the current execution statement recorded is visible or not according to the target snapshot sequence number and the target commit sequence number. According to the method, the target snapshot sequence number and the target commit sequence number are determined according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, and whether the record is visible or not is judged according to the target snapshot sequence number and the target commit sequence number, so that the problem that the processing efficiency is low when the distributed transaction only relates to one data node in the prior art is solved, and the execution efficiency of the distributed transaction can be improved.
On the basis of the above embodiments, modified embodiments of the above embodiments are proposed, and it is to be noted here that only the differences from the above embodiments are described in the modified embodiments for the sake of brevity of description.
In one embodiment, the method further comprises:
after all current execution sentences in the current transaction are scheduled, registering a local commit sequence number in local transaction registration information;
if the current transaction is a single-node transaction, carrying out local submission; otherwise, two-stage commit is performed.
The local transaction registration information may be transaction registration information stored locally at the node, where the transaction registration information may store a commit sequence number of each transaction, and other information. The local commit sequence number may be a commit sequence number registered locally at the data node. The local commit may be directly performed at the data node, and the two-stage commit may be performed first and then performed after the pre-commit is completed, which is not described in detail in this embodiment.
In this embodiment, after all statements in the current transaction are scheduled, the transaction may be committed. Before the transaction is submitted, whether the current transaction is a single-node transaction needs to be judged, if all sentences in the current transaction relate to the same node, the current transaction is the single-node transaction, the local submission can be performed, and otherwise, the two-stage submission is performed. When a transaction is submitted, whether the current transaction is a single-node transaction or not, the current local submitted sequence number needs to be registered in the local transaction registration information, and the local submitted sequence number is +1 so as to judge the visibility when the single-node transaction is queried when the subsequent transaction is scheduled.
In the embodiment, the execution flow of the single-node transaction omits the multi-time communication between the two-stage submitting computing node and the data node and the multi-time communication between the computing node and the data node and between the data node and the metadata node when the global submitting sequence number is acquired, so that the execution efficiency is greatly improved. Moreover, as the single-node transaction is submitted only at a single node, the problem that the distributed transaction is submitted at different nodes and is not submitted is solved, so that two-stage submission can be avoided; as only one node is involved, the problem that the visibility judgment of the same transaction on different nodes is different does not occur, and the visibility judgment is not needed through the global commit sequence number.
Example two
Fig. 2 is a flow chart of a transaction visibility judging method according to a second embodiment of the present invention, where the second embodiment is optimized based on the above embodiments. For details not yet described in detail in this embodiment, refer to embodiment one.
As shown in fig. 2, a transaction visibility determination method provided in a second embodiment of the present invention is applied to a data node, and includes the following steps:
s210, determining a current transaction and a current execution statement of the current transaction.
S220, determining the transaction type of the current transaction when executing the current execution statement.
S230, acquiring the transaction corresponding to the record related to the current execution statement.
S240, determining a corresponding snapshot sequence number based on the transaction type of the current transaction.
In this embodiment, when the transaction types of the current transaction are different, the target snapshot sequence number and the target commit sequence number that may be used in performing the visibility determination are not necessarily different, so that the snapshot sequence number that may be used needs to be acquired first according to the transaction type of the current transaction.
In the embodiment, when the current statement execution is scheduled, as long as the statement related to different nodes exists in the current transaction, the global commit sequence number can be directly acquired, and the current transaction is not recorded as a single-node transaction any more.
Further, determining a corresponding snapshot sequence number based on the transaction type of the current transaction includes:
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 numbers are the global snapshot sequence number and the local snapshot sequence number.
The local snapshot sequence number may be a snapshot sequence number recorded locally at the node. The global snapshot sequence number may be a snapshot sequence number common to all nodes.
In this embodiment, if the current transaction is a single-node transaction, a local snapshot sequence number needs to be obtained locally at the data node; if the current transaction is a global transaction, the global snapshot sequence number and the local snapshot sequence number need to be acquired simultaneously, and the data node can acquire the global snapshot sequence number from the transaction information received by the computing node and acquire the local snapshot sequence number from the local.
S250, 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.
In this embodiment, if any one of the current transaction and the transaction corresponding to the record is a single-node transaction, the visibility may 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.
Further, 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, including:
if the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, determining the local snapshot sequence number of the current transaction as the target snapshot sequence number, and determining the local commit sequence number of the transaction corresponding to the record as the target commit sequence number; otherwise, the global snapshot sequence number is determined to be the target snapshot sequence number, and the global commit sequence number is determined to be the target commit sequence number.
The local commit sequence number can be a commit sequence number recorded locally at the node, and can be used for sequentially counting transaction commitments in the local node, and each node stores the local commit sequence number. The global commit sequence number may be a commit sequence number common to all nodes.
In this embodiment, when the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, there is essentially no difference from a database transaction of a single machine, and the global commit sequence number may not be used to determine visibility, so that the local snapshot sequence number of the current transaction may be used as the target snapshot sequence number, and the local commit sequence number of the transaction corresponding to the record may be used as the target commit sequence number. Otherwise, the global snapshot sequence number and the global commit sequence number can be directly obtained to serve as the target snapshot sequence number and the target commit sequence number.
And S260, judging whether the record is visible or not according to the target snapshot sequence number and the target submission sequence number.
The second embodiment of the invention provides a transaction visibility judging method, which comprises the following steps: determining a current transaction and a current execution statement of the current transaction; determining a transaction type of the current transaction when the current execution statement is executed; acquiring a transaction corresponding to a record related to the current execution statement; determining 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; and judging whether the record is visible or not according to 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 when judging the visibility can be determined according to the transaction type of the current transaction and the transaction type of the transaction corresponding to the record, the problem that in the prior art, when the distributed transaction only involves one data node, the processing efficiency is low is solved, and the execution efficiency of the distributed transaction can be improved.
Example III
Fig. 3 is a schematic structural diagram of a transaction visibility determination device according to a third embodiment of the present invention, where the device may be adapted to determine the visibility of a transaction in a distributed database, and the device may be implemented by software and/or hardware and is generally integrated on an electronic device.
As shown in fig. 3, the apparatus includes:
a first determining module 310, configured to determine a transaction type of the current transaction when the current execution statement is executed;
a second determining module 320, configured to determine a transaction type of the current execution statement;
an obtaining module 330, configured to obtain a transaction corresponding to a record related to the current execution 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 the transaction corresponding to the record;
and a judging module 340, configured to judge whether the record is visible according to the target snapshot sequence number and the target commit sequence number.
The transaction visibility determination device provided in the third embodiment includes: a first determining module, configured to determine a transaction type of the current transaction when the current execution statement is executed; a second determining module, configured to determine a transaction type of the current execution statement; the acquisition module is used for acquiring the transaction corresponding to the record related to the current execution statement, and 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; and the judging module is used for judging whether the record is visible or not according to the target snapshot sequence number and the target submission sequence number. The device determines the target snapshot sequence number and the target commit sequence number according to the transaction type of the transaction corresponding to the current transaction and the transaction type of the transaction corresponding to the record, and judges whether the record is visible according to the target snapshot sequence number and the target commit sequence number, so that the problem of low processing efficiency when the distributed transaction only relates to one data node in the prior art is solved, and the execution efficiency of the distributed transaction can be improved.
Further, the first determining module 310 includes:
the receiving unit is used for receiving the transaction information sent by the computing node;
the transaction determining unit is used for determining the transaction corresponding to the transaction information as the current transaction;
and the statement determination element is used for taking the statement currently scheduled by the computing node as a current execution statement.
Further, the second determining module 320 includes:
the identification acquisition unit is used for acquiring the transaction type identification carried in the transaction information;
and the transaction type determining unit is used for determining that the transaction type of the current transaction is a single-node transaction if the transaction type identifier is a single-node identifier, and otherwise, determining that the transaction type of the current transaction is a global transaction.
Further, the obtaining module 330 includes:
a snapshot sequence number determining unit, configured to determine a corresponding snapshot sequence number based on a transaction type of the current transaction;
and the target sequence number determining unit is used for 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.
Further, the snapshot sequence number determining unit includes:
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 numbers are the global snapshot sequence number and the local snapshot sequence number.
Further, 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, determining the local snapshot sequence number of the current transaction as the target snapshot sequence number, and determining the local commit sequence number of the transaction corresponding to the record as the target commit sequence number; otherwise, the global snapshot sequence number is determined to be the target snapshot sequence number, and the global commit sequence number is determined to be the target commit sequence number.
Further, the apparatus further comprises:
after all current execution sentences in the current transaction are scheduled, registering a local commit sequence number in local transaction registration information;
if the current transaction is a single-node transaction, carrying out local submission; otherwise, two-stage commit is performed.
The transaction visibility judging device can execute the transaction visibility judging method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the executing method.
Example IV
Fig. 4 shows a schematic diagram of the structure of an electronic device that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 4, 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., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may 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. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various 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, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, 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.
The processor 11 may be a variety of general and/or special purpose processing components having 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 running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the respective methods and processes described above, such as the transaction visibility determination method.
In some embodiments, the transaction visibility determination method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the transaction visibility determination method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the transaction visibility determination method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out 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, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here 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 a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, 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: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A transaction visibility determination method, applied to a data node, the method comprising:
determining a current transaction and a current execution statement of the current transaction;
determining a transaction type of the current transaction when the current execution statement is executed;
acquiring a transaction corresponding to a record related to the current execution statement, and 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;
and judging whether the record is visible or not according to the target snapshot sequence number and the target commit sequence number.
2. The method of claim 1, determining a current transaction and a current execution statement for the current transaction, comprising:
receiving transaction information sent by a computing node;
determining the transaction corresponding to the transaction information as a current transaction;
and taking the statement currently scheduled by the computing node as a current execution statement.
3. The method of claim 2, the determining a transaction type of the current transaction when the current execution statement is executed comprising:
acquiring a transaction type identifier carried in the transaction information;
and 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, determining that the transaction type of the current transaction is a global transaction.
4. The method of claim 1, determining a target snapshot sequence number and a target commit sequence number from a transaction type of the current transaction and a transaction type of a transaction corresponding to the record, comprising:
determining a corresponding snapshot sequence number based on the transaction type of the current transaction;
and 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.
5. The method of claim 4, determining a corresponding snapshot sequence number based on a transaction type of the current transaction, comprising:
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 numbers are the global snapshot sequence number and the local snapshot sequence number.
6. The method of claim 4, determining a target snapshot sequence number and a target commit sequence number based on a transaction type of the current transaction, a transaction type of a transaction to which the record corresponds, and the snapshot sequence number, comprising:
if the current transaction is a single-node transaction or the transaction corresponding to the record is a single-node transaction, determining the local snapshot sequence number of the current transaction as the target snapshot sequence number, and determining the local commit sequence number of the transaction corresponding to the record as the target commit sequence number; otherwise, the global snapshot sequence number is determined to be the target snapshot sequence number, and the global commit sequence number is determined to be the target commit sequence number.
7. The method of claim 1, the method further comprising:
after all current execution sentences in the current transaction are scheduled, registering a local commit sequence number in local transaction registration information;
if the current transaction is a single-node transaction, carrying out local submission; otherwise, two-stage commit is performed.
8. A transaction visibility determination device, the device comprising:
a first determining module, configured to determine a transaction type of the current transaction when the current execution statement is executed;
a second determining module, configured to determine a transaction type of the current execution statement;
the acquisition module is used for acquiring the transaction corresponding to the record related to the current execution statement, and 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;
and the judging module is used for judging whether the record is visible or not according to the target snapshot sequence number and the target submission sequence number.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the transaction visibility determination method of any one of claims 1-7.
10. A computer readable storage medium storing computer instructions for causing a processor to implement the transaction visibility determination method of any one of claims 1-7 when executed.
CN202310272390.7A 2023-03-17 2023-03-17 Transaction visibility judging method, device, equipment and storage medium Pending CN116302371A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310272390.7A CN116302371A (en) 2023-03-17 2023-03-17 Transaction visibility judging method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310272390.7A CN116302371A (en) 2023-03-17 2023-03-17 Transaction visibility judging method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116302371A true CN116302371A (en) 2023-06-23

Family

ID=86837617

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310272390.7A Pending CN116302371A (en) 2023-03-17 2023-03-17 Transaction visibility judging method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116302371A (en)

Similar Documents

Publication Publication Date Title
CN113722600B (en) Data query method, device, equipment and product applied to big data
CN116545905A (en) Service health detection method and device, electronic equipment and storage medium
CN116383207A (en) Data tag management method and device, electronic equipment and storage medium
CN116185389A (en) Code generation method and device, electronic equipment and medium
CN116302371A (en) Transaction visibility judging method, device, equipment and storage medium
CN115237426A (en) Method, device and equipment for determining database difference and storage medium
CN114579260A (en) Transaction processing method and system
CN116955394A (en) Data query method, device, equipment and medium
CN117194435A (en) Index data updating method, device, equipment and storage medium
CN116719825A (en) Visibility determination method, device, equipment and storage medium
CN114637738A (en) Data visibility judgment method and device, database node and medium
CN115858104A (en) Method, device and equipment for acquiring snapshot of transaction commit sequence number and storage medium
CN116401269A (en) Data query method and device, electronic equipment and storage medium
CN116361388A (en) Data processing method, device, equipment and storage medium
CN117421322A (en) Data reading method, device, equipment and medium
CN117668083A (en) Heterogeneous database synchronization method and device, electronic equipment and storage medium
CN115983222A (en) EasyExcel-based file data reading method, device, equipment and medium
CN117093274A (en) Application running stack analysis method, device, equipment and storage medium
CN116301634A (en) Method, device, equipment and medium for detecting resource interaction state
CN116881368A (en) Data synchronization method and device, electronic equipment and storage medium
CN118012902A (en) Database query method and device, electronic equipment and storage medium
CN118012936A (en) Data extraction method, device, equipment and storage medium
CN117669570A (en) Information matching method and device, electronic equipment and storage medium
CN117596298A (en) Data processing method and device, electronic equipment and storage medium
CN115543691A (en) Data backup method, device, equipment and medium for cloud native application

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination