CN110865874B - Transaction commit method and device - Google Patents

Transaction commit method and device Download PDF

Info

Publication number
CN110865874B
CN110865874B CN201911086637.6A CN201911086637A CN110865874B CN 110865874 B CN110865874 B CN 110865874B CN 201911086637 A CN201911086637 A CN 201911086637A CN 110865874 B CN110865874 B CN 110865874B
Authority
CN
China
Prior art keywords
transaction
stage
transactions
data
execution
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.)
Active
Application number
CN201911086637.6A
Other languages
Chinese (zh)
Other versions
CN110865874A (en
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.)
Guangzhou Huaduo Network Technology Co Ltd
Original Assignee
Guangzhou Huaduo Network Technology 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 Guangzhou Huaduo Network Technology Co Ltd filed Critical Guangzhou Huaduo Network Technology Co Ltd
Priority to CN201911086637.6A priority Critical patent/CN110865874B/en
Publication of CN110865874A publication Critical patent/CN110865874A/en
Application granted granted Critical
Publication of CN110865874B publication Critical patent/CN110865874B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • 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)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a transaction submitting method, and belongs to the technical field of data processing. The method comprises the following steps: receiving a plurality of transactions operating on a database at stage n+1; performing conflict verification on the plurality of transactions and the transactions in the suspension transaction set of the N stage to obtain an execution transaction set of the N+1 stage and a suspension transaction set of the N+1 stage, wherein no conflict exists among the transactions in the execution transaction set; operating on the data in the modified version data set based on each transaction in the execution transaction set of the n+1 stage; copying the modified data in the modified version data set with the completed operation to a stable version data set; writing to disk based on the data in the copied stable version data set. By adopting the method and the device, the technical problem of large delay of transaction submission in the related technology can be effectively solved.

Description

Transaction commit method and device
Technical Field
The present application relates to the field of data processing technologies, and in particular, to a method and apparatus for transaction commit.
Background
A database transaction is a sequence of data operations that access and potentially manipulate data, with the operations in the sequence of data operations either all being performed or none being performed, being an indivisible unit of work (called atomicity of the transaction). Database transactions may be referred to simply as transactions, which consist of all data operations between the beginning of a transaction and the end of the transaction.
In the related art, in order to ensure the atomicity of a transaction, the transaction needs to write a log to a centralized buffer before writing to a disk during commit. A successful write disk indicates successful transaction commit, and a failed write disk indicates failed transaction commit. When the transaction commit fails, some data operations in the transaction may have been successfully executed, and some data operations may have failed to be executed, at which time the data may be rolled back to a consistent state through a previously written log, so that the transaction may be re-committed, and atomicity of the transaction is guaranteed.
In the process of implementing the present application, the inventors found that the related art has at least the following problems:
in the process, in order to avoid the mutual influence of the logs of different transactions, locking is needed, namely, after a certain transaction locks the buffer, only the log of the transaction can be written, and the logs of the rest of the transactions cannot be written temporarily, so that great delay is caused to the transaction submission.
Disclosure of Invention
The embodiment of the application provides a method and a device for submitting a transaction, which can solve the technical problems in the related technology. The technical scheme of the method and the device for submitting the transaction is as follows:
in a first aspect, a method of transaction commit is provided, the method comprising:
receiving a plurality of transactions of stage n+1 operating on a database, wherein the database comprises a modified version data set and a stable version data set, the N being an integer greater than or equal to 1;
performing conflict verification on the plurality of transactions and the transactions in the suspension transaction set of the N stage to obtain an execution transaction set of the N+1 stage and a suspension transaction set of the N+1 stage, wherein no conflict exists among the transactions in the execution transaction set;
operating on the data in the modified version data set based on each transaction in the execution transaction set of the n+1 stage;
copying the modified data in the modified version data set with the completed operation to a stable version data set;
writing to disk based on the data in the copied stable version data set.
In one possible implementation manner, the performing conflict verification on the plurality of transactions and the transactions in the suspended transaction set of the nth stage to obtain the executed transaction set of the n+1th stage and the suspended transaction set of the n+1th stage includes:
determining the transaction with earliest receiving time in the suspension transaction set of the N stage as the first transaction in the execution transaction set of the N+1 stage;
the plurality of transactions and the transaction except the transaction with earliest receiving time in the suspension transaction set of the N stage are sequentially subjected to conflict verification with the transactions in the execution transaction set of the N+1 stage according to the sequence of receiving the transactions, and for each transaction, if the transaction does not conflict with the transaction in the execution transaction set of the N+1 stage, the transaction is added into the execution transaction set of the N+1 stage;
and adding the transaction which is not added to the execution transaction set of the N+1th stage to the suspension transaction set of the N+1th stage.
In one possible implementation manner, after the receiving the plurality of transactions operating on the database in the n+1th stage, the method further includes:
for each transaction received in the n+1 stage, performing conflict verification on the transaction and the transaction in the execution transaction set in the N stage, and if no conflict exists and the operation on the data in the modified version data set is not completed based on each transaction in the execution transaction set in the N stage, adding the transaction into the execution transaction set in the N stage.
In one possible implementation manner, the operating on the data in the modified version data set based on each transaction in the n+1-th stage execution transaction set includes:
for each thing in the execution transaction set of the n+1 stage, if the operation on the target data in the modified version data set fails based on the transaction, rolling back the target data to a consistency state based on the corresponding data of the target data in the stable version data set, and operating on the target data in the modified version data set again based on the transaction.
In one possible implementation manner, the writing to the disk based on the data in the updated stable version data set includes:
and writing the modified data in the updated stable version data set into a disk.
In a second aspect, there is provided an apparatus for transaction commit, the apparatus comprising:
a receiving module, configured to receive a plurality of transactions operating on a database in an n+1 stage, where the database includes a modified version data set and a stable version data set, and N is an integer greater than or equal to 1;
the verification module is used for carrying out conflict verification on the plurality of transactions and the transactions in the suspension transaction set of the N stage to obtain an execution transaction set of the N+1 stage and the suspension transaction set of the N+1 stage, wherein no conflict exists among the transactions in the execution transaction set;
an operation module, configured to operate on data in the modified version data set based on each transaction in the execution transaction set in the n+1 stage;
the copying module is used for copying the data with the modification in the modified version data set after the operation is completed to the stable version data set;
and the writing module is used for writing the data in the copied stable version data set into the disk.
In one possible implementation manner, the verification module is configured to:
determining the transaction with earliest receiving time in the suspension transaction set of the N stage as the first transaction in the execution transaction set of the N+1 stage;
the plurality of transactions and the transaction except the transaction with earliest receiving time in the suspension transaction set of the N stage are sequentially subjected to conflict verification with the transactions in the execution transaction set of the N+1 stage according to the sequence of receiving the transactions, and for each transaction, if the transaction does not conflict with the transaction in the execution transaction set of the N+1 stage, the transaction is added into the execution transaction set of the N+1 stage;
and adding the transaction which is not added to the execution transaction set of the N+1th stage to the suspension transaction set of the N+1th stage.
In a possible implementation manner, the apparatus further includes an adding module, configured to:
for each transaction received in the n+1 stage, performing conflict verification on the transaction and the transaction in the execution transaction set in the N stage, and if no conflict exists and the operation on the data in the modified version data set is not completed based on each transaction in the execution transaction set in the N stage, adding the transaction into the execution transaction set in the N stage.
In one possible implementation manner, the operation module is configured to:
for each thing in the execution transaction set of the n+1 stage, if the operation on the target data in the modified version data set fails based on the transaction, rolling back the target data to a consistency state based on the corresponding data of the target data in the stable version data set, and operating on the target data in the modified version data set again based on the transaction.
In one possible implementation, the copying module is configured to:
and writing the data with the modification in the copied stable version data set into a disk.
In a third aspect, a server is provided, the server comprising a memory and a processor, the memory having stored therein at least one instruction that is loaded and executed by the processor to implement the method of transaction commit according to the first aspect.
In a fourth aspect, there is provided a computer readable storage medium having stored therein at least one instruction that is loaded and executed by a processor to implement the method of transaction commit according to the first aspect.
The beneficial effects that technical scheme that this application embodiment provided include at least:
the method for transaction commit provided by the embodiment of the application is implemented by maintaining two versions of data sets, namely a modified version data set and a stable version data set, in a database. In operating on data based on transactions, only data in the modified version data set is operated on, and no changes are made to data in the stable version data set. Therefore, when the data operation in the modified version data set fails, the data in the modified version data set can be rolled back to a consistency state based on the data in the stable version data set, so that the transaction operation can be re-executed, the log is not required to be written in advance, locking is not required, and the delay of transaction submission is shortened to a certain extent. In addition, when the transaction is submitted, the transaction is submitted in batches by generating an execution transaction set, so that the delay of the transaction is shortened.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that 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 method of transaction commit provided by an embodiment of the present application;
FIG. 2 is a schematic diagram of an apparatus for transaction commit according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a server according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a process for performing conflict verification on transactions according to an embodiment of the present application;
FIG. 5 is an environmental diagram of an implementation of a method of transaction commit provided by an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail below with reference to the accompanying drawings.
The embodiment of the application provides a transaction submitting method which can be realized by a server. The server may be a single server or a server cluster.
The embodiment of the application provides a transaction submitting method which can be particularly applied to a database system. Fig. 5 is a diagram of an implementation environment of a method for transaction commit provided in an embodiment of the present application, where the implementation environment includes a plurality of terminals and a server cluster, where two versions of a dataset are maintained, a modified version dataset and a stable version dataset, respectively. When the user wants to operate on the data in the database, the user operates on the terminal, and the terminal is triggered to send a transaction for operating the database to the server. Then there may be multiple transactions sent to the server for a period of time, either from the same terminal or from different terminals. Then, the server can receive a plurality of transactions operating on the database in the n+1 stage, and perform conflict verification on the received plurality of transactions and transactions in the suspended transaction set in the N stage to obtain an executing transaction set in the n+1 stage and a suspended transaction set in the n+1 stage. The data in the modified version data set is operated on (as shown in fig. 5) based on each transaction in the execution transaction set at stage n+1. After the operation is completed, the data in the modified version data set with the modification is copied to the stable version data set (as shown in fig. 5). And finally, writing the data in the copied stable version data set into a disk. After the transaction commit is completed, corresponding data may also be returned to the terminal. For example, when a read operation is included in the transaction, the server returns the terminal request read data to the terminal after completing the read operation in the transaction.
As shown in fig. 1, the process flow of the method of transaction commit may include the steps of:
in step 101, a plurality of transactions operating on a database of phase n+1 are received.
Wherein the database comprises a modified version data set and a stable version data set, N being an integer greater than or equal to 1. The modified version data set and the stable version data set contain the same data prior to performing the operation.
A transaction may also be referred to as a database transaction, which includes a sequence of data operations, and in particular may include a set of read operations and a set of write operations.
The n+1th phase is a time concept, and the time duration of each phase may be equal, for example, may be 10ms, each phase is ordered according to time sequence, for example, the first phase is 1-10ms, the second phase is 10ms-20ms, the third phase is 20ms-30ms, and so on.
In implementation, when the time reaches the beginning of the n+1 stage, a plurality of transactions operating on the database of the n+1 stage are started to be accepted.
In step 102, conflict verification is performed on a plurality of transactions received in the n+1 stage and transactions in the suspended transaction set in the N stage, so as to obtain an executed transaction set in the n+1 stage and a suspended transaction set in the n+1 stage.
Wherein, no conflict exists between each transaction in the execution transaction set. There may be no or no conflict between the transactions in the set of pending transactions, and the specific situation may vary according to the transactions included in the set of pending transactions.
The nth stage suspended transaction set refers to a set of transactions that fail to commit at the nth stage, where the transactions of the nth stage suspended transaction set conflict with the transactions of the nth stage executing transaction set.
Conflict verification refers to verifying whether or not there is a conflict between transactions, and the transactions with the conflict cannot be committed at the same stage.
In implementation, conflict verification is performed on transactions that fail to be committed in the nth stage (i.e., transactions in the suspended transaction set in the nth stage) and transactions received in the n+1 stage, resulting in the executed transaction set in the n+1 stage and the suspended transaction set in the n+1 stage.
Specifically, when performing conflict verification, the data operation in the read operation set and the write operation set included in the transaction can be subjected to conflict verification, so as to verify whether the conflict exists between the transactions.
In addition, if no transaction operating on the database is received in the n+1 stage, the corresponding processing in step 102 is to perform conflict verification on the transaction in the suspended transaction set in the N stage, so as to obtain the executed transaction set in the n+1 stage and the suspended transaction set in the n+1 stage.
In performing conflict verification, at least one reference transaction needs to be determined first as the first transaction of the execution transaction set of the n+1 stage. Specifically, two transactions can be randomly selected for conflict verification, if conflict exists, one transaction is randomly selected to be added into the execution transaction set of the n+1 stage, and the first transaction in the execution transaction set of the n+1 stage is used; if there is no conflict, both transactions may be added to the set of executing transactions for phase n+1.
In one possible implementation, to allow transactions with early receive times to commit as early as possible, the process of step 102 may determine the transaction with the earliest receive time in the set of pending transactions for the nth phase as the first transaction in the set of executing transactions for the n+1 phase as described below. And carrying out conflict verification on a plurality of transactions and transactions except for the transaction with earliest receiving time in the suspension transaction set of the N stage and the transactions in the execution transaction set of the N+1 stage in sequence according to the receiving sequence of the transactions, and adding the transactions to the execution transaction set of the N+1 stage if the transactions do not conflict with the transactions in the execution transaction set of the N+1 stage for each transaction. Transactions in the set of executing transactions that are not added to phase n+1 are added to the set of pending transactions in phase n+1.
The transaction with the earliest receiving time in the suspension transaction set in the nth stage is the transaction with the earliest receiving time in the plurality of transactions which are not submitted at present, namely the reference transaction.
In implementation, the transaction with the earliest receiving time is made to commit as first as possible by taking the transaction with the earliest receiving time in the suspension transaction set of the N-th stage as the first transaction in the execution transaction set of the N+1-th stage. In addition, by performing conflict verification on each transaction and the transaction in the execution transaction set of the n+1 stage according to the receiving sequence of the transactions and adding the transaction without conflict to the execution transaction set of the n+1 stage, the transaction with the early receiving time is submitted as early as possible.
Transactions in the set of executing transactions that are not added to the n+1 stage are added to the set of pending transactions in the n+1 stage.
In addition, to reduce latency in transaction commit, to enable a received transaction to commit as early as possible, in one possible implementation, for each transaction received in stage n+1, the transaction is conflict-verified with transactions in the set of executing transactions in stage N, and if there is no conflict and based on each transaction in the set of executing transactions in stage N, operations on data in the modified version data set have not yet been completed, the transaction is added to the set of executing transactions in stage N.
In implementation, for the transaction received in the n+1th stage, if there is no conflict with the transaction in the execution transaction set in the N stage, and the operation on the data in the modified version data set is not completed based on each transaction in the execution transaction set in the N stage, the transaction received in the n+1th stage can be advanced to the N stage for commit, thereby reducing the time for the transaction to wait for commit. Alternatively, each time a transaction is received in phase n+1, it is validated against the transaction set in the N-th phase of executing the transaction set.
As shown in FIG. 4, a process diagram for conflict verification of transactions is provided. First, data for operating the database is received in the n+1 stage. Then, whether the transaction operation in the execution transaction set of the current N-th stage is completed is judged.
If so, the transaction is conflict verified with the transaction in the execution transaction set of the n+1 stage. If there is a conflict, adding the transaction to the pending transaction set for phase n+1; if there is no conflict, the transaction is added to the set of executing transactions for phase n+1.
If not, the transaction is conflict verified with the transaction in the N-stage execution transaction set. If no conflict exists, adding the transaction to the N-stage execution transaction set; if there is a conflict, the transaction is validated against the transaction in the N+1th stage of execution transaction set, if there is still a conflict, the transaction is added to the N+1th stage of suspension transaction set, if there is no conflict, the transaction is added to the N+1th stage of execution transaction set.
As can be seen from the above discussion, the transaction committed by the N-th phase does not necessarily commit to completion within the corresponding time period of the N-th phase, i.e., the transaction committed by the N-th phase may run within the corresponding time period of the N+1-th phase.
It should be added that if the transaction is the first-stage transaction, the corresponding steps are to perform conflict verification on the plurality of transactions received by the first stage, so as to obtain the first-stage execution transaction set and the first-stage suspension transaction set.
Specifically, first, a transaction with the earliest receiving time among a plurality of transactions received in the first stage is determined as a first transaction in the execution transaction set in the first stage. And each transaction received subsequently to the first stage is sequentially subjected to conflict verification with the transaction in the execution transaction set of the first stage according to the sequence of transaction receiving, and if the transaction does not conflict with the transaction in the execution transaction set of the first stage, the transaction is added into the execution transaction set of the next stage. Transactions in the set of executing transactions that are not added to the first phase are added to the set of pending transactions of the first phase.
In addition, there may be no precedence relationship between step 101 and step 102, that is, while the transaction for receiving the n+1th stage and operating the database is performed, the conflict verification of the transaction may also be performed, and step 101 and step 102 may be performed simultaneously, or may be performed each time a transaction is received in the n+1th stage, that is, the conflict verification is performed on the transaction and the transaction in the n+1th stage in which the transaction is performed.
In step 103, the data in the modified version data set is operated on based on each transaction in the set of executing transactions of phase n+1.
In implementation, corresponding data in the modified version data set is subjected to corresponding read operations and write operations according to a read operation set and a write operation set included in each transaction in the execution transaction set. For each transaction, if the read operation set and the read operation and the write operation set included in the transaction are successful, the transaction operation is successful.
For each transaction, if either one of the set of read operations and the set of write operations included in the transaction fails, then a transaction operation failure is declared. If the operation fails, the data operation should be performed again based on the transaction. In addition, when the transaction operation fails, since some data operations in the transaction are already executed and some data operations are not executed, the corresponding data will be in an inconsistent state, and the corresponding data should be rolled back to a consistent state at this time, and then the data operation can be performed again based on the transaction.
For example, where a transaction is a transaction regarding a bank account transfer, the transaction may include two data operations, a first data operation to reduce a target amount of money in a first account and a second data operation to increase a target amount of money in a second account. Both data operations either operate successfully or do not. If the first data operation is successful and the second data operation fails, the data needs to be rolled back to the state before the first data operation, and then the first data operation and the second data operation are performed again.
When a transaction fails, the specific processing may be as follows.
For each thing in the execution transaction set of the n+1 stage, if the operation on the target data in the modified version data set fails based on the transaction, the target data is rolled back to a consistency state based on the corresponding data of the target data in the stable version data set, and the operation on the target data in the modified version data set is performed again based on the transaction.
According to the method provided by the embodiment of the application, the data in the modified version data set can be rolled back to the consistency state through the data in the stable version data set by maintaining the modified version data set and the stable version data set in the database, so that log writing is not needed in advance, locking is not needed, and delay of transaction price lifting is shortened.
It will be appreciated that the above step 103 is performed on the premise that each transaction in the nth stage of executing transaction set has been committed successfully, i.e. the nth stage of writing disk has been completed. If the transactions in the N-th stage of executing transaction set have not been committed successfully, the process of step 103 will not be performed to avoid commit conflicts for both batches of transactions, even if the N+1-th stage of executing transaction set has been determined.
In addition, step 103 and step 102 may not have a precedence relationship, that is, while the data in the modified version data set is operated on based on the transaction in the execution transaction set, the conflict verification of the transaction may be performed, and step 103 and step 102 may be performed simultaneously.
In step 104, the modified version data set with the modifications in the operation completed is copied to the stable version data set.
Where modified data refers to data affected by transactions in the n+1 stage of executing transaction set, such as modified data, added data, deleted data, etc.
In implementation, when the operation is completed, the data with the modification in the modification version data set is copied into the stable version data set, so that the data in the stable version data set is updated, and the modification version data set and the data in the stable version data set are kept consistent before the transaction of the next stage is submitted.
In step 105, writing to disk is performed based on the data in the copied stable version data set.
The copied stable version data set refers to the stable version data set after the modified data in the modified version data set is copied to the stable version data set.
In practice, after the modified data in the modified version data set is copied to the stable version data set, the data in the stable version data set may be written to disk. In one possible implementation, all of the data in the modified version data set may be written to disk.
In another possible implementation, to increase efficiency, the copied stable version data set may be written to disk with modified data.
Where modified data refers to data affected by transactions in the n+1 stage of executing transaction set, such as modified data, added data, deleted data, etc.
In the implementation, only the data with the modifications in the copied stable version data set is written into the disk, so that the writing efficiency of the disk is improved, the transaction submitting efficiency is further improved, and the transaction submitting delay is reduced.
When the writing of the disk is successful, it indicates that the transaction of the n+1th stage is successful, and then the transaction of the next stage can be submitted, i.e. the transaction of the n+2th stage is submitted.
In addition, when writing the magnetic disk, the data after executing a plurality of transaction operations in the transaction set is written once, so that the moving times of the magnetic disk magnetic head are reduced, the efficiency of writing the magnetic disk is further improved, and the delay of transaction submission is shortened.
The method for transaction commit provided by the embodiment of the application is implemented by maintaining two versions of data sets, namely a modified version data set and a stable version data set, in a database. In operating on data based on transactions, only data in the modified version data set is operated on, and no changes are made to data in the stable version data set. Therefore, when the data operation in the modified version data set fails, the data in the modified version data set can be rolled back to a consistency state based on the data in the stable version data set, so that the transaction operation can be re-executed, the log is not required to be written in advance, locking is not required, and the delay of transaction submission is shortened to a certain extent. In addition, when the transaction is submitted, the transaction is submitted in batches by generating an execution transaction set, so that the delay of the transaction is shortened. Moreover, by making the transaction received in the n+1 stage, under the condition that the conflict with the transaction in the execution transaction set of the N stage is not satisfied and the transaction in the execution transaction set of the N stage is not completed, the transaction can be added into the execution transaction set of the N stage, and the waiting time of the transaction commit is shortened, so that the delay of the transaction commit can also be shortened.
In addition, to make the present case more clear, the method of transaction commit in the first stage is supplemented, and includes:
receiving a plurality of transactions of a first stage operating on a database;
performing conflict verification on a plurality of transactions received in the first stage to obtain an execution transaction set in the first stage and a suspension transaction set in the first stage;
operating on the data in the modified version data set based on each transaction in the execution transaction set of the first stage;
copying the modified data in the modified version data set with the completed operation to a stable version data set;
writing to disk based on the data in the copied stable version data set.
It can be seen that, during the transaction commit process of the first stage, when performing conflict verification, since there is no suspended transaction set at this time, the conflict verification is only performed on the transaction received by the first stage, so as to obtain the executing transaction set of the first stage and the suspended transaction set of the first stage. The remaining steps of the transaction commit of the first phase are similar to the corresponding steps of the transaction commit of the remaining phases, and reference is made in particular to the corresponding content of the foregoing.
Based on the same technical concept, the embodiment of the present application further provides a device for submitting a transaction, where the device may be a server in the foregoing embodiment, as shown in fig. 2, and the device includes:
a receiving module 201, configured to receive a plurality of transactions operating on a database in phase n+1, where the database includes a modified version data set and a stable version data set, and N is an integer greater than or equal to 1;
a verification module 202, configured to perform conflict verification on a plurality of transactions and transactions in a suspended transaction set in an nth stage, to obtain an executed transaction set in an n+1th stage and a suspended transaction set in an n+1th stage, where there is no conflict between each transaction in the executed transaction set;
an operation module 203, configured to operate on data in the modified version data set based on each transaction in the execution transaction set in the n+1th stage;
a copy module 204, configured to copy the modified version data set with the modified data after the operation to the stable version data set;
the writing module 205 is configured to write to the disk based on the data in the copied stable version data set.
In one possible implementation, the verification module 202 is configured to:
determining the transaction with earliest receiving time in the suspension transaction set of the N-th stage as the first transaction in the execution transaction set of the N+1-th stage;
the method comprises the steps that a plurality of transactions received in an N+1 stage and transactions except for the transaction with earliest receiving time in a suspended transaction set in the N stage are sequentially subjected to conflict verification with the transactions in an executing transaction set in the N+1 stage according to the receiving sequence of the transactions, and if each transaction does not conflict with the transactions in the executing transaction set in the N+1 stage, the transaction is added into the executing transaction set in the N+1 stage;
transactions in the set of executing transactions that are not added to phase n+1 are added to the set of pending transactions in phase n+1.
In one possible implementation, the apparatus for transaction commit further includes an adding module configured to:
for each transaction received in the n+1 stage, performing conflict verification on the transaction and the transaction in the execution transaction set in the N stage, and if no conflict exists and the operation on the data in the modified version data set is not completed based on each transaction in the execution transaction set in the N stage, adding the transaction into the execution transaction set in the N stage.
In one possible implementation, the operation module 203 is configured to:
for each thing in the execution transaction set of the n+1 stage, if the operation on the target data in the modified version data set fails based on the transaction, the target data is rolled back to a consistency state based on the corresponding data of the target data in the stable version data set, and the operation on the target data in the modified version data set is performed again based on the transaction.
In one possible implementation, the copy module 204 is configured to:
and writing the data with the modification in the copied stable version data set into a disk.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
It should be noted that: in the transaction submitting device provided in the above embodiment, only the division of the above functional modules is used for illustration, and in practical application, the above functional allocation may be completed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device for transaction commit provided in the above embodiment belongs to the same concept as the method embodiment for transaction commit, and the specific implementation process of the device is detailed in the method embodiment, which is not described herein again.
Fig. 3 is a schematic structural diagram of a server according to an embodiment of the present application, where the server 300 may have a relatively large difference due to different configurations or performances, and may include one or more processors (central processing units, CPU) 301 and one or more memories 302, where at least one instruction is stored in the memories 302, and the at least one instruction is loaded and executed by the processors 301 to implement the method for submitting a transaction as described above.
In an exemplary embodiment, there is also provided a computer readable storage medium having stored therein at least one instruction that is loaded and executed by a processor to implement the method of transaction commit in the above embodiments. For example, the computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program for instructing relevant hardware, where the program may be stored in a computer readable storage medium, and the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description of the preferred embodiments of the present application is not intended to limit the invention to the particular embodiments of the present application, but to limit the scope of the invention to the particular embodiments of the present application.

Claims (9)

1. A method of transaction commit, the method comprising:
receiving a plurality of transactions of stage n+1 operating on a database, wherein the database comprises a modified version data set and a stable version data set, N being an integer greater than or equal to 1;
performing conflict verification on the plurality of transactions and the transactions in the suspension transaction set of the N stage to obtain an execution transaction set of the N+1 stage and a suspension transaction set of the N+1 stage, wherein no conflict exists among the transactions in the execution transaction set;
operating on data in the modified version data set based on each transaction in the n+1th stage of execution transaction set, and if the operation on the target data in the modified version data set fails based on the transaction, rolling back the target data to a consistency state based on the corresponding data of the target data in the stable version data set, and operating on the target data in the modified version data set again based on the transaction;
copying the modified data in the modified version data set with the completed operation to a stable version data set;
writing to disk based on the data in the copied stable version data set.
2. The method of claim 1, wherein performing conflict verification on the plurality of transactions and the transactions in the N-th stage suspended transaction set to obtain the n+1-th stage executed transaction set and the n+1-th stage suspended transaction set, comprises:
determining the transaction with earliest receiving time in the suspension transaction set of the N stage as the first transaction in the execution transaction set of the N+1 stage;
the plurality of transactions and the transaction except the transaction with earliest receiving time in the suspension transaction set of the N stage are sequentially subjected to conflict verification with the transactions in the execution transaction set of the N+1 stage according to the sequence of receiving the transactions, and for each transaction, if the transaction does not conflict with the transaction in the execution transaction set of the N+1 stage, the transaction is added into the execution transaction set of the N+1 stage;
and adding the transaction which is not added to the execution transaction set of the N+1th stage to the suspension transaction set of the N+1th stage.
3. The method of claim 1, wherein after receiving the plurality of n+1-th stage transactions operating on the database, further comprising:
for each transaction received in the n+1 stage, performing conflict verification on the transaction and the transaction in the execution transaction set in the N stage, and if no conflict exists and the operation on the data in the modified version data set based on each transaction in the execution transaction set in the N stage is not completed, adding the transaction into the execution transaction set in the N stage.
4. A method according to any of claims 1-3, wherein writing to disk based on the data in the copied stable version dataset comprises:
and writing the data with the modification in the copied stable version data set into a disk.
5. An apparatus for transaction commit, the apparatus comprising:
a receiving module, configured to receive a plurality of transactions operating on a database in an n+1 stage, where the database includes a modified version data set and a stable version data set, and N is an integer greater than or equal to 1;
the verification module is used for carrying out conflict verification on the plurality of transactions and the transactions in the suspension transaction set of the N stage to obtain an execution transaction set of the N+1 stage and the suspension transaction set of the N+1 stage, wherein no conflict exists among the transactions in the execution transaction set;
an operation module, configured to operate on data in the modified version data set based on each transaction in the n+1st stage of execution transaction set, and if operation on the target data in the modified version data set based on a transaction fails, rollback the target data to a consistent state based on corresponding data of the target data in the stable version data set, and operate on the target data in the modified version data set based on a transaction again;
the copying module is used for copying the data with the modification in the modified version data set after the operation is completed to the stable version data set;
and the writing module is used for writing the data in the copied stable version data set into the disk.
6. The apparatus of claim 5, wherein the authentication module is configured to:
determining the transaction with earliest receiving time in the suspension transaction set of the N stage as the first transaction in the execution transaction set of the N+1 stage;
the plurality of transactions and the transaction except the transaction with earliest receiving time in the suspension transaction set of the N stage are sequentially subjected to conflict verification with the transactions in the execution transaction set of the N+1 stage according to the sequence of receiving the transactions, and for each transaction, if the transaction does not conflict with the transaction in the execution transaction set of the N+1 stage, the transaction is added into the execution transaction set of the N+1 stage;
and adding the transaction which is not added to the execution transaction set of the N+1th stage to the suspension transaction set of the N+1th stage.
7. The apparatus of claim 5, further comprising an adding module for:
for each transaction received in the n+1 stage, performing conflict verification on the transaction and the transaction in the execution transaction set in the N stage, and if no conflict exists and the operation on the data in the modified version data set based on each transaction in the execution transaction set in the N stage is not completed, adding the transaction into the execution transaction set in the N stage.
8. A server comprising a memory and a processor, the memory having stored therein at least one instruction that is loaded and executed by the processor to implement the method of transaction commit of any of claims 1-4.
9. A computer readable storage medium having stored therein at least one instruction that is loaded and executed by a processor to implement the method of transaction commit as claimed in any one of claims 1 to 4.
CN201911086637.6A 2019-11-08 2019-11-08 Transaction commit method and device Active CN110865874B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911086637.6A CN110865874B (en) 2019-11-08 2019-11-08 Transaction commit method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911086637.6A CN110865874B (en) 2019-11-08 2019-11-08 Transaction commit method and device

Publications (2)

Publication Number Publication Date
CN110865874A CN110865874A (en) 2020-03-06
CN110865874B true CN110865874B (en) 2023-07-04

Family

ID=69653195

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911086637.6A Active CN110865874B (en) 2019-11-08 2019-11-08 Transaction commit method and device

Country Status (1)

Country Link
CN (1) CN110865874B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6748589B1 (en) * 1999-10-20 2004-06-08 Transmeta Corporation Method for increasing the speed of speculative execution
CN102722401A (en) * 2012-04-25 2012-10-10 华中科技大学 Pseudo associated multi-version data management method for hardware transaction memory system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6748589B1 (en) * 1999-10-20 2004-06-08 Transmeta Corporation Method for increasing the speed of speculative execution
CN102722401A (en) * 2012-04-25 2012-10-10 华中科技大学 Pseudo associated multi-version data management method for hardware transaction memory system

Also Published As

Publication number Publication date
CN110865874A (en) 2020-03-06

Similar Documents

Publication Publication Date Title
US9389905B2 (en) System and method for supporting read-only optimization in a transactional middleware environment
US11386065B2 (en) Database concurrency control through hash-bucket latching
US9501502B2 (en) Locking protocol for partitioned and distributed tables
EP2825958B1 (en) Systems and methods for supporting transaction recovery based on a strict ordering of two-phase commit calls
CN112598525B (en) Intelligent contract clustering parallel block chain implementation method and device
CN102282548A (en) Transaction processing in transactional memory
US9652492B2 (en) Out-of-order execution of strictly-ordered transactional workloads
US11663170B2 (en) Method for associating data between a plurality of blockchain networks and apparatus thereof
Wojciechowski et al. Model-driven comparison of state-machine-based and deferred-update replication schemes
US20210303403A1 (en) Transaction processing method, apparatus, and electronic device for blockchain
US20230394027A1 (en) Transaction execution method, computing device, and storage medium
CN115408411A (en) Data writing method and device, electronic equipment and storage medium
CN105938446B (en) The data supported based on RDMA and hardware transactional memory replicate fault-tolerance approach
CN112559496B (en) Method and device for realizing transaction atomicity of distributed database
CN112765126B (en) Database transaction management method, device, computer equipment and storage medium
US11237925B2 (en) Systems and methods for implementing persistent data structures on an asymmetric non-volatile memory architecture
CN110865874B (en) Transaction commit method and device
US11132351B2 (en) Executing transactions based on success or failure of the transactions
CN114846458A (en) Distributed serializable concurrency control scheme
CN110162569A (en) Data processing method, device and computer equipment based on GG synchronized process
CN115760405A (en) Transaction execution method, device, computer equipment and medium
CN114816682A (en) Distributed transaction processing method, system and device
CN115292335A (en) Transaction processing method and device and electronic equipment
CN114253720A (en) Multithreading task execution method and device, electronic equipment and storage medium
CN112508577A (en) Block generation and verification method and device, electronic equipment and readable storage medium

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
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20200306

Assignee: GUANGZHOU CUBESILI INFORMATION TECHNOLOGY Co.,Ltd.

Assignor: GUANGZHOU HUADUO NETWORK TECHNOLOGY Co.,Ltd.

Contract record no.: X2021440000031

Denomination of invention: Method and device of transaction submission

License type: Common License

Record date: 20210125

GR01 Patent grant
GR01 Patent grant