WO2017107811A1 - 数据库操作方法及装置 - Google Patents

数据库操作方法及装置 Download PDF

Info

Publication number
WO2017107811A1
WO2017107811A1 PCT/CN2016/109666 CN2016109666W WO2017107811A1 WO 2017107811 A1 WO2017107811 A1 WO 2017107811A1 CN 2016109666 W CN2016109666 W CN 2016109666W WO 2017107811 A1 WO2017107811 A1 WO 2017107811A1
Authority
WO
WIPO (PCT)
Prior art keywords
database
operation instruction
instruction
database operation
execution
Prior art date
Application number
PCT/CN2016/109666
Other languages
English (en)
French (fr)
Inventor
王晶昱
Original Assignee
阿里巴巴集团控股有限公司
王晶昱
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 阿里巴巴集团控股有限公司, 王晶昱 filed Critical 阿里巴巴集团控股有限公司
Priority to JP2018532425A priority Critical patent/JP6877435B2/ja
Priority to EP16877622.7A priority patent/EP3396560B1/en
Publication of WO2017107811A1 publication Critical patent/WO2017107811A1/zh
Priority to US16/013,851 priority patent/US20180300147A1/en

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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/38Concurrent instruction execution, e.g. pipeline or look ahead
    • G06F9/3836Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution
    • G06F9/3842Speculative instruction execution
    • 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/23Updating
    • 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
    • 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/23Updating
    • G06F16/2358Change logging, detection, and notification
    • 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/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • 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/23Updating
    • G06F16/2379Updates performed during online database operations; commit 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/24Querying
    • G06F16/245Query processing
    • G06F16/2453Query optimisation
    • G06F16/24534Query rewriting; Transformation
    • G06F16/24549Run-time optimisation
    • 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/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • 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/25Integrating or interfacing systems involving database management systems
    • 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/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms
    • G06F9/528Mutual exclusion algorithms by using speculative mechanisms

Definitions

  • the present application relates to the field of database technologies, and in particular, to a database operation method and apparatus.
  • Database Transaction refers to a series of operations performed as a single logical unit of work, either completely or completely.
  • a transaction consists of a series of database manipulation instructions, such as statements.
  • transaction isolation level In the database operation, in order to ensure the correctness of concurrent read data, the concept of transaction isolation level is proposed.
  • SQL Standard Structured Query Language
  • four transaction isolation levels are defined. Among them, Read Committed is the isolation level that most applications prefer to avoid dirty reads. And it has better concurrency performance, but still encounters the problem of non-repeatable reading.
  • aspects of the present application provide a database operation method and apparatus for ensuring concurrent performance of a database system, improving transaction execution efficiency, and increasing transaction throughput.
  • An aspect of the present application provides a database operation method, including:
  • the operation instruction belongs to the modification number Recording the predicted execution data generated by the prediction execution according to one of the library class instruction and the locked non-modified database class instruction;
  • the database corresponding to the application server is controlled to actually execute the target transaction according to the database operation instruction recorded locally and the predicted execution data.
  • Another aspect of the present application provides a database operation method, including:
  • the database corresponding to the application server is controlled to actually execute the target transaction according to the database operation instruction recorded locally and the predicted execution data.
  • a database operating device including:
  • An obtaining module configured to sequentially acquire a database operation instruction in the target transaction executed by the application server during a process of executing a target transaction by the application server;
  • a predictive execution module configured to perform predictive execution on the database operation instruction, return a predicted execution result to the application server, for the application server to determine a next database operation instruction to be executed, and locally record the database operation And predicting execution data generated by the prediction execution when the database operation instruction belongs to one of a modification database class instruction and a locked non-modified database class instruction;
  • control execution module configured to: when the transaction commit instruction in the target transaction is obtained, control the database corresponding to the application server to actually execute the target transaction according to the database operation instruction recorded locally and the predicted execution data .
  • a database operating device including:
  • An obtaining module configured to acquire the in-process during the execution of the target transaction by the application server a database operation instruction in the target transaction to which the application server executes;
  • a predictive execution module configured to perform predictive execution on the database operation instruction, return a predicted execution result to the application server, for the application server to determine a next database operation instruction to be executed, and locally record the database operation And predicting execution data generated by the prediction execution when the database operation instruction belongs to a locked non-modified database class instruction;
  • control execution module configured to: when the transaction commit instruction in the target transaction is obtained, control the database corresponding to the application server to actually execute the target transaction according to the database operation instruction recorded locally and the predicted execution data .
  • the database operating device cooperates with the application server to join the predictive execution process in the process of executing the target transaction by the application server, and obtains and records all the database operation instructions that need to be executed in the target transaction in advance, and only refers to the instructions belonging to the modified database class and The database operation instruction of the locked non-modified database class instruction, or the prediction execution data generated by the prediction execution only for the database operation instruction belonging to the locked non-modified database class instruction, to adapt to the read isolation level
  • the locking scheme provides conditions for the real execution of the transaction, and then controls the database corresponding to the application server to actually execute the target transaction according to the recorded database operation instruction and the predicted execution data, which is beneficial to improve the execution efficiency and thereby increase the transaction throughput.
  • FIG. 1 is a deployment diagram of a database application system in the prior art
  • FIG. 2 is a deployment diagram of a database application system according to an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of a database operation method according to another embodiment of the present application.
  • FIG. 4 is a schematic flowchart of a database operation method according to another embodiment of the present application.
  • FIG. 5 is a schematic structural diagram of a database operating device according to another embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a database operating device according to another embodiment of the present disclosure.
  • FIG. 1 is a deployment diagram of a database application system in the prior art.
  • the system includes an application server 10 and a database 20.
  • the application server 10 may be one or multiple.
  • the database 20 may be one or plural. Only one application server 10 and one database 20 are shown by way of example in FIG.
  • the application server 10 executes transaction logic to sequentially apply database operation instructions in the transaction to the database 20. Because the database operation instructions that need to be executed in the transaction cannot be known in advance, the transaction execution efficiency is low, especially in the scheme of locking the data by the for update statement under the configuration read commit isolation level, the execution efficiency is lower. Transaction throughput is low.
  • the present application provides a new database application system, as shown in FIG. 2 .
  • the system adds a database operating device 30 between the application server 10 and the database 20.
  • the database operating device 30 is configured to execute the database operation method provided by the present application, and implement a new transaction execution logic in the locking scheme that has been submitted under the isolation level, that is, the prediction execution is performed on the transaction, and the transaction is obtained in advance.
  • Database operation instructions that need to be executed to implement the prediction of the execution path, and in conjunction with reading the isolation level that has been committed and locked, only for database operation instructions belonging to the modified database class instruction and the locked non-modified database class instruction, Or the prediction execution data generated by the prediction execution of the database operation instruction belonging to the locked non-modified database class instruction is recorded, and the database operation instruction obtained based on the prediction execution and the prediction execution data actually execute the transaction on the database 20.
  • Transaction throughput is the number of transactions processed per unit of time.
  • the database operating device 30 is actually a logical processing device, which can be deployed separately, between the application server 10 and the database 20, or deployed at one end of the application server 10, or can be deployed in the database 20. Implemented at one end.
  • FIG. 3 is a schematic flowchart diagram of a database operation method according to another embodiment of the present application. As shown in FIG. 3, the method includes:
  • the present embodiment refers to a transaction that the application server needs to perform as a target transaction.
  • the target transaction mainly includes operation instructions for operating on the database, and in addition to the database operation instructions, some control instructions for controlling the execution state of the target transaction, such as a transaction start instruction, a transaction commit instruction, a transaction rollback instruction, and the like.
  • These instructions are actually statements written in the database language. Depending on the database language, these instructions can be statements written in different languages. For example, if SQL is used, the above database operation instructions and control instructions are actually a series of SQL statements.
  • the transaction processing needs to select some records first, and then process the records, so it is necessary to add an exclusive lock to the selected records.
  • the database operation instruction in this embodiment may be a locked database operation instruction. For example, suppose from Bob Transfer 100 yuan in the account, this operation is completed in three steps, query Bob's account, determine whether the account is enough for 100 yuan, and reduce the amount of money in Bob's account by 100. If there are two transfer operations in parallel, when the first transfer operation finds the balance of Bob's account, it finds that there are 100. If there is another transfer operation at this time, Bob's account is also checked, and Bob's account is also found.
  • the method provided in this embodiment is applicable to operating a database whose isolation level is read and submitted.
  • Some databases default to reading the isolation level that has been submitted.
  • the Oracle database defaults to read the isolation level that has been submitted.
  • Some databases do not read the isolation level by default.
  • the MySQL database is repeatable by default.
  • An isolation level Based on this, before performing the method provided in this embodiment, it can be determined whether the isolation level of the database is a read commit, and if not, the database needs to be pre-configured to read the isolation level. For example, you can configure the database to read this isolation level before the target server performs the target transaction.
  • the method provided in this embodiment can be executed to execute the target transaction in the database.
  • the specific process is as follows:
  • the application server controls the execution logic of the entire target transaction, and the target transaction can be executed in the existing manner.
  • the database operating device sequentially acquires database operation instructions in the target transaction executed by the application server during the execution of the target transaction by the application server.
  • the application server sends database operation instructions to the database in an existing manner to enable access to the database.
  • the database operating device can monitor the communication between the application server and the database to intercept the database operation instructions sent by the application server to the database.
  • the processing logic of the application server is slightly modified to change the processing logic that originally sent the database operation instructions to the database to the database operating device. Based on this, the database operating device can receive the database operation actively issued by the application server. instruction.
  • the first instruction in the target transaction is a transaction start instruction, such as a begin transaction, based on which the database operation device obtains the database operation instruction executed by the application server.
  • the database operating device may receive a transaction start instruction in the target transaction actively issued by the application server before acquiring the database operation instruction executed by the application server, and according to the transaction start instruction, learn that the target transaction needs to be executed.
  • the target transaction is an implicit transaction
  • the first instruction of the target transaction is the database operation instruction, and does not include the step of obtaining the transaction start instruction.
  • the database operation device After acquiring the database operation instruction executed by the application server, the database operation device performs predictive execution on the acquired database operation instruction, returns the predicted execution result to the application server, and uses the server to determine the next database operation instruction to be executed.
  • the predicted execution result determines the execution path of the target transaction, where the execution path refers to the jump logic between the database operation instructions.
  • the purpose of controlling the execution logic of the entire target transaction by the application server is achieved by returning the predicted execution result to the application server.
  • the database operating device also needs to locally record the acquired database operation instruction, and when the database operation instruction belongs to one of modifying the database class instruction and the locked non-modifying database class instruction, recording the database operation instruction Predictive execution data generated by the execution of the forecast.
  • the modified database class instruction refers to a database operation instruction that has a modification to the database, for example, an instruction starting with update, insert, etc.; generally, an instruction beginning with a select does not belong to a modified database class instruction (referred to as a non-modified database class instruction).
  • the predicted execution data mainly refers to some data in the process of predictive execution of the database operation instruction, such as data operated by the database operation instruction, and the primary key ID of the data and the version number information corresponding to the primary key ID.
  • the database operating device can locally create a memory library, and store the acquired database operation instructions and predicted execution data into the memory library. Further, if the predicted execution data does not include the predicted execution result, the predicted execution result may also be stored in the memory bank.
  • this embodiment is directed to one of the non-modified database class instructions belonging to the modified database class instruction and the locked database class.
  • the database operation instruction records the predicted execution data generated by the prediction execution, but does not record the prediction execution data corresponding to the database operation instruction of the unmodified database type instruction that is not locked. It can be seen that in the case of implementing the locking scheme under the isolation level that the read has been submitted, the amount of recorded data is relatively small, so that the subsequent database operation instructions and prediction execution data based on the local record are actually executed in the database. During the target transaction, the amount of data to be processed is relatively small, which is beneficial to further improve execution efficiency and performance, and increase transaction throughput.
  • the operation of the database operation instruction on the database is mainly to access the data in the database, then the data environment of the database operation instruction can be simulated, and the database operation instruction is predicted and executed based on the simulated data environment.
  • the database operation instruction can be directly predicted and executed in the database, thereby saving the operation of the simulation data environment, and the implementation is relatively simple. Conducive to saving resources and improving execution efficiency.
  • a database operation instruction belonging to a modified database class instruction since it causes a change in the database (mainly, the data in the database is changed), it is necessary to simulate the data environment and perform prediction execution in the simulated data environment.
  • the database operation instruction belongs to the modify database class instruction, it is in the locally created memory library. Simulating the data environment of the database operation instruction, and performing prediction execution on the database operation instruction based on the simulated data environment;
  • the database operation instruction belongs to a non-modified database class instruction
  • the database operation instruction is executed in the database to perform prediction execution on the database operation instruction.
  • a data environment simulating a database operation instruction in a locally created memory library, and an implementation manner of predicting execution of the database operation instruction based on the simulated data environment includes:
  • the obtained database operation instruction is split into a read instruction and a write instruction, and the read instruction is run on a real database, that is, the read instruction is executed in the database to obtain a read data set (ReadSet), and the read data set is stored.
  • the read instruction is executed in the database to obtain a read data set (ReadSet), and the read data set is stored.
  • the write instruction is applied to the memory library to implement predictive execution of the database operation instruction, that is, the write instruction is executed in the memory library to modify the read data set, for example, to update or query the related data in the read data set.
  • executing a write instruction to modify the read data set may generate a result data set (affectRowInMemdb), the result data set including a predicted execution result.
  • the database operation device may locally record the read data set read by the read instruction and the result data set generated by executing the write instruction.
  • the predicted execution data may include a read data set and a result data set, or may also include partial data in the read data set and the result data set, such as some data that can have a beneficial effect on actually executing the target transaction in the database.
  • various indexes of some values such as a primary index, a secondary index, a primary key ID, a version number, and the like.
  • the database operation instruction belongs to the locked non-modified database class instruction
  • only the primary key ID and the version number of the data operated by the database operation instruction may be recorded as the predicted execution data.
  • the amount of data to be processed is further reduced, which is beneficial to further improve the execution efficiency and performance, and increase the transaction throughput.
  • the data may be modified several times during the transaction, but eventually returns to the initial value, but the primary key ID and version number of the data will not change.
  • this embodiment uses only recording data. The way of the primary key ID and version number is less probable when the prediction execution is compared with the real execution, and the rollback probability is lower.
  • the database operation device acquires the transaction commit instruction in the target transaction (that is, the application server executes to the transaction commit instruction)
  • the database corresponding to the locally recorded database operation instruction and the predicted execution data may be used to control the database corresponding to the application server to actually execute the target transaction.
  • an optional implementation manner of controlling the database corresponding to the actual execution target transaction of the application server includes:
  • the database operating device sends the locally recorded database operation instruction to the database to instruct the database to execute the database operation instruction, and receives the actual execution result of the database operation instruction returned by the database; and then, the actual execution result of the database operation instruction and the prediction execution The result is compared. If the actual execution result is the same as the predicted execution result, the transaction commit instruction is sent to the database for the database to submit the target transaction; if the actual execution result is different from the predicted execution result, the transaction rollback instruction is sent to the database. For the database to roll back the target transaction.
  • the database operation instruction can be executed sequentially according to the execution logic of the transaction, which causes frequent interaction between the application server and the database, which is A lot of network resources will be consumed in the remote application scenario.
  • all the database operation instructions that need to be executed by the target transaction that is, the database operation instructions of the local record
  • the database operation instruction of the local record has been obtained in advance by the prediction execution process, so the database operation instruction of the local record is sent to the database to instruct the database to execute the database.
  • the database operation instruction of the local record can be simultaneously and/or sent to the database, which is conducive to saving network resources.
  • the database can also operate in parallel, which is beneficial to further improve transaction execution efficiency and increase transaction throughput.
  • all the database operation instructions of the local record can be sent to the database together with the locally recorded predicted execution data.
  • the database operating device may determine, according to the locally recorded database operation instruction, whether the target transaction is a stand-alone transaction; if the determination result is yes, the database operation according to the local record
  • the instruction and the prediction execution data control the database to actually execute the target transaction by the single machine transaction processing logic; if the judgment result is no, the distributed transaction logic controls the database to actually execute the target transaction according to the locally recorded database operation instruction and the predicted execution data.
  • the database operation instruction obtained during the prediction execution process can identify whether the target transaction is a stand-alone transaction or a distributed transaction. For example, it can be determined whether the operation object of the database operation instruction recorded locally acts on the same physical device. If the determination result is yes, the target transaction can be determined to be a stand-alone transaction; if the determination result is no, the target transaction can be determined as Distributed transactions.
  • the processing logic of distributed transactions is different from the processing logic of stand-alone transactions, the processing logic of single-machine transactions is relatively simple, for example, it does not involve problems such as read-write and lock, so the resources consumed are relatively small.
  • the present embodiment uses the processing logic of the single-machine transaction to identify whether the target transaction is a stand-alone transaction, and does not use the distributed transaction processing logic to process the same as the prior art, which is beneficial to improve. Processing efficiency and saving processing costs.
  • the database operation device acquires a transaction rollback instruction in the target transaction (that is, the application server performs a transaction rollback instruction)
  • the database operation instruction of the local record and the prediction execution data may be deleted, for example, Clear the local memory library directly to implement the rollback operation.
  • the target transaction since the target transaction is not actually executed in the database, the database does not need to perform a rollback operation. It can be seen that in the case of transaction rollback, the transaction efficiency can be improved by using the method of this embodiment.
  • the database operating device cooperates with the application server to join the predictive execution process in the process of executing the target transaction by the application server, and the execution path of the target transaction can be obtained in advance during the predictive execution process.
  • the prediction execution data generated by the prediction execution is adapted to Read the lock scheme under the submitted isolation level, true
  • the real execution transaction provides conditions, and then when the target transaction is actually executed according to the recorded database operation instruction and the predicted execution data, for example, based on the predicted execution data, the related data information can be acquired in advance and the jump between the instructions can be reduced, and thus Improve execution efficiency and increase transaction throughput.
  • the isolation level of the database is the isolation level that the read has been submitted.
  • the SQL code for the inventory reduction transaction is as follows, the text in parentheses is a comment:
  • the application server is responsible for the entire logic of the inventory reduction transaction.
  • the database operation device (or also called the execution server) only obtains the start transaction executed by the application server, the SQL statement that needs to be executed, and the commit/return. Roll instruction.
  • the database operating device creates a memory library locally
  • the database operation device will get the rollback statement.
  • the application server executes the commit command at this time.
  • the database operating device When the database operating device obtains the commit command, it is based on the SQL in the local memory library.
  • the statement and the forecast execution data are executed in the database, and the transaction execution process is actually performed.
  • the locally recorded SQL statement and the predicted execution data are as follows:
  • the database operating device can submit all the SQL statements in the local memory library to the database at one time, and the database performs the execution based on this, which is beneficial to save network resources consumed by the transmission of the SQL statement.
  • This real execution will also return the execution result.
  • FIG. 4 is a schematic flowchart diagram of a database operation method according to another embodiment of the present application. As shown in FIG. 4, the method includes:
  • This embodiment is similar to the embodiment shown in FIG. 3, except that only the prediction execution data generated by the prediction execution of the locked non-modified database class instruction in the target transaction is recorded, and the prediction for the prediction execution of the modified database class instruction is generated.
  • the predicted execution data generated by the execution execution of the data and the unmodified non-modified database class instructions are not recorded.
  • the embodiment is applicable to the case where the target transaction includes the unlocked non-modified database class instruction, and the operated database may not only be a database scenario in which the isolation level is read or submitted, but also various other database scenarios.
  • the method provided in this embodiment is applied to the database whose isolation level is read, it is considered that some databases default to read and submit the isolation level.
  • the Oracle database defaults to read the isolation level submitted, and some By default, the database does not read the isolation level.
  • the MySQL database defaults to the isolation level. Therefore, before executing the method provided in this embodiment, it can be determined whether the isolation level of the database is read. If not, You will need to pre-configure the database to read this isolation level. For example, you can configure the database to read this isolation level before the target server performs the target transaction.
  • the application server sends database operation instructions to the database in an existing manner to enable access to the database.
  • the database operating device can monitor the communication between the application server and the database to intercept the database operation instructions sent by the application server to the database.
  • the processing logic of the application server is slightly modified to change the processing logic that originally sent the database operation instructions to the database to the database operating device. Based on this, the database operating device can receive the database operation instruction actively issued by the application server.
  • the first instruction in the target transaction is a transaction start instruction, such as a begin transaction, based on which the database operation device obtains the database operation instruction executed by the application server.
  • the database operating device may receive a transaction start instruction in the target transaction actively issued by the application server before acquiring the database operation instruction executed by the application server, and according to the transaction start instruction, learn that the target transaction needs to be executed.
  • the target transaction is an implicit transaction
  • the first instruction of the target transaction is the database operation instruction, and does not include the step of obtaining the transaction start instruction.
  • the database operation device After acquiring the database operation instruction executed by the application server, the database operation device performs predictive execution on the acquired database operation instruction, returns the predicted execution result to the application server, and uses the server to determine the next database operation instruction to be executed.
  • the predicted execution result determines the execution path of the target transaction, where the execution path refers to the jump logic between the database operation instructions.
  • the purpose of controlling the execution logic of the entire target transaction by the application server is achieved by returning the predicted execution result to the application server.
  • the database operating device also needs to locally record the acquired database operation instruction, and record the predicted execution data generated by the predictive execution of the database operation instruction when the database operation instruction belongs to the locked non-modified database type instruction.
  • the modified database class instruction refers to a database operation instruction that has a modification to the database, for example, an instruction starting with update, insert, etc.; generally, an instruction beginning with a select does not belong to a modified database class instruction (referred to as a non-modified database class instruction).
  • some non-modified database class instructions may need to be locked by the for update statement. For example, in the above transfer example, the select instruction needs to be locked to form a select...for update form.
  • Database operation instructions such instructions can be referred to as locked non-modified database class instructions.
  • the predicted execution data mainly refers to some data in the process of predictive execution of the database operation instruction, such as data operated by the database operation instruction and the primary key ID (itemId) of the data and the version number information corresponding to the primary key ID.
  • the same database operation instruction it is either a modified database class instruction, a locked non-modified database class instruction, or an unlocked non-modified database class instruction.
  • the predicted execution data generated for all of the locked non-modified database class instruction prediction executions in the target transaction is recorded locally.
  • the database operating device can create a memory library locally, and the acquired database
  • the operation instructions and the predicted execution data are stored in the memory bank. Further, if the predicted execution data does not include the predicted execution result, the predicted execution result may also be stored in the memory bank.
  • the present embodiment records the predicted execution data generated by the prediction execution for the database operation instruction of the locked non-modified database class instruction, but does not record Predictive execution data corresponding to other database operation instructions. It can be seen that in the case of implementing the locking scheme, the amount of recorded data is relatively small, so that in the process of subsequently executing the target transaction in the database in the database operation instruction and the prediction execution data based on the local record, the required processing is required. The relatively small amount of data is beneficial to further improve execution efficiency and performance, and increase transaction throughput.
  • the database operation instruction belongs to the locked non-modified database class instruction
  • only the primary key ID and the version number of the data operated by the database operation instruction may be recorded as the predicted execution data.
  • the amount of data to be processed is further reduced, which is beneficial to further improve the execution efficiency and performance, and increase the transaction throughput.
  • the data may be modified several times during the transaction, but eventually returns to the initial value, but the primary key ID and version number of the data will not change.
  • the data may be different when the prediction execution is compared with the real execution, and the rollback occurs, and the rollback is costly.
  • the method of recording only the primary key ID and the version number is adopted, and the probability of occurrence of inconsistency when the prediction execution is compared with the real execution is low, and the rollback probability is low.
  • the operation of the database operation instruction on the database is mainly to access the data in the database, then the data environment of the database operation instruction can be simulated, and the database operation instruction is predicted and executed based on the simulated data environment.
  • the database operation instruction belonging to the non-modified database class instruction does not cause a change of the database
  • the database operation instruction can be directly predicted and executed in the database, thereby saving the operation of the simulation data environment, and the implementation is relatively simple. Conducive to saving resources and improving execution efficiency.
  • a database operation instruction belonging to a modified database class instruction since it causes a change in the database (mainly, the data in the database is changed), it is necessary to simulate the data environment and perform prediction execution in the simulated data environment.
  • the data environment of the database operation instruction is simulated in the locally created memory library, and the database operation instruction is predicted and executed based on the simulated data environment;
  • the database operation instruction belongs to a non-modified database class instruction
  • the database operation instruction is executed in the database to perform prediction execution on the database operation instruction.
  • a data environment simulating a database operation instruction in a locally created memory library, and an implementation manner of predicting execution of the database operation instruction based on the simulated data environment includes:
  • the obtained database operation instruction is split into a read instruction and a write instruction, and the read instruction is run on a real database, that is, the read instruction is executed in the database to obtain a read data set (ReadSet), and the read data set is stored.
  • the read instruction is executed in the database to obtain a read data set (ReadSet), and the read data set is stored.
  • the write instruction is applied to the memory library to implement predictive execution of the database operation instruction, that is, the write instruction is executed in the memory library to modify the read data set, for example, to update or query the related data in the read data set.
  • executing a write instruction to modify the read data set may generate a result data set (affectRowInMemdb), the result data set including a predicted execution result.
  • the database operation device acquires the transaction commit instruction in the target transaction (that is, the application server executes to the transaction commit instruction)
  • the database corresponding to the locally recorded database operation instruction and the predicted execution data may be used to control the database corresponding to the application server to actually execute the target transaction.
  • an optional implementation manner of controlling the database corresponding to the actual execution target transaction of the application server includes:
  • the database operating device sends a locally recorded database operation instruction to the database to instruct the database to execute the database operation instruction, and receives the actual execution result of the database operation instruction returned by the database; and then, the actual execution result of the database operation instruction and the predicted execution result are performed. Comparing, if the actual execution result is the same as the predicted execution result, the transaction commit instruction is sent to the database for the database to submit the target transaction; if the actual execution result is different from the predicted execution result, the transaction rollback instruction is sent to the database for The database rolls back the target transaction.
  • the database operation instruction can be executed sequentially according to the execution logic of the transaction, which causes frequent interaction between the application server and the database, which is A lot of network resources will be consumed in the remote application scenario.
  • all the database operation instructions that need to be executed by the target transaction that is, the database operation instructions of the local record
  • the database operation instruction of the local record has been obtained in advance by the prediction execution process, so the database operation instruction of the local record is sent to the database to instruct the database to execute the database.
  • the database operation instruction of the local record can be simultaneously and/or sent to the database, which is conducive to saving network resources.
  • the database can also operate in parallel, which is beneficial to further improve transaction execution efficiency and increase transaction throughput.
  • all the database operation instructions of the local record can be sent to the database together with the locally recorded predicted execution data.
  • the database operation device may determine whether the target transaction is based on the locally recorded database operation instruction. For a stand-alone transaction; if the result of the determination is yes, according to the locally recorded database operation instruction and the predicted execution data, the single-machine transaction logic is used to control the database to actually execute the target transaction; if the judgment result is no, the database operation instruction according to the local record and Predictive execution data, with distributed transaction processing logic to control the database to actually execute the target transaction.
  • the database operation instruction obtained during the prediction execution process can identify whether the target transaction is a stand-alone transaction or a distributed transaction. For example, it can be determined whether the operation object of the database operation instruction recorded locally acts on the same physical device. If the determination result is yes, the target transaction can be determined to be a stand-alone transaction; if the determination result is no, the target transaction can be determined as Distributed transactions.
  • the processing logic of distributed transactions is different from the processing logic of stand-alone transactions, the processing logic of single-machine transactions is relatively simple, for example, it does not involve problems such as read-write and lock, so the resources consumed are relatively small. Based on this, the embodiment recognizes whether the target transaction is a stand-alone transaction. Instead of using distributed transaction processing logic for processing in a stand-alone transaction, it is better to improve processing efficiency and save processing costs.
  • the database operation device acquires a transaction rollback instruction in the target transaction (that is, the application server performs a transaction rollback instruction)
  • the database operation instruction of the local record and the prediction execution data may be deleted, for example, Clear the local memory library directly to implement the rollback operation.
  • the target transaction since the target transaction is not actually executed in the database, the database does not need to perform a rollback operation. It can be seen that in the case of transaction rollback, the transaction efficiency can be improved by using the method of this embodiment.
  • the database operating device cooperates with the application server to join the predictive execution process in the process of executing the target transaction by the application server, and the execution path of the target transaction can be obtained in advance during the predictive execution process. That is, the database operation instruction that really needs to be executed, and only predictive execution data generated by the prediction execution for the database operation instruction belonging to the locked non-modified database class instruction, to adapt to the locking scheme, and provide conditions for the real execution transaction, Then, when the target transaction is actually executed according to the recorded database operation instruction and the predicted execution data, for example, based on the predicted execution data, the related data information can be acquired in advance and the jump between the instructions can be reduced, etc., thereby improving execution efficiency and increasing the transaction. Throughput.
  • FIG. 5 is a schematic structural diagram of a database operating device according to another embodiment of the present disclosure. As shown in FIG. 5, the apparatus includes an acquisition module 51, a prediction execution module 52, and a control execution module 53.
  • the obtaining module 51 is configured to sequentially acquire the target server in the process of executing the target transaction The database operation instruction in the target transaction to which the server executes.
  • the prediction execution module 52 is configured to perform predictive execution on the database operation instruction, return the predicted execution result to the application server to supply the server to determine the next database operation instruction to be executed, and locally record the database operation instruction and the database operation instruction belongs to The predicted execution data generated by the prediction execution is recorded when one of the database class instruction and the locked non-modified database class instruction is modified.
  • the control execution module 53 is configured to, when acquiring the transaction commit instruction in the target transaction, control the database corresponding to the application server to actually execute the target transaction according to the locally recorded database operation instruction and the predicted execution data.
  • the prediction execution module 52 is configured to: in the process of recording the predicted execution data generated by the prediction execution when the database operation instruction belongs to one of the modified database class instruction and the locked non-modified database class instruction, specifically:
  • the apparatus further includes: a configuration module, configured to configure the database to read the submitted isolation level before the application server performs the target transaction.
  • the prediction execution module 52 is specifically configured to:
  • the data environment of the database operation instruction is simulated in the locally created memory library, and the database operation instruction is predicted and executed based on the simulated data environment;
  • the database operation instruction belongs to a non-modified database class instruction
  • the database operation instruction is executed in the database to perform prediction execution on the database operation instruction.
  • the prediction execution module 52 simulates the data environment of the database operation instruction in the locally created memory library, and performs prediction execution on the database operation instruction based on the simulated data environment, specifically to:
  • a write instruction is executed in the memory bank to modify the read data set.
  • control execution module 53 is specifically configured to:
  • the database operation instruction of the local record is sent to the database to instruct the database to execute the database operation instruction, and receives the actual execution result of the database operation instruction returned by the database;
  • the transaction commit instruction is sent to the database for the database to submit the target transaction
  • a transaction rollback instruction is issued to the database for the database to roll back the target transaction.
  • the database operating device cooperates with the application server to join the predictive execution process in the process of executing the target transaction by the application server, and obtains and records all the database operation instructions that need to be executed in the target transaction in advance, and only refers to the instructions belonging to the modified database class. And the database operation instruction of the locked non-modified database class instruction, or the prediction execution data generated by the prediction execution only for the database operation instruction belonging to the locked non-modified database class instruction, to adapt to the read isolation level
  • the locking scheme provides conditions for the real execution of the transaction, and then controls the database corresponding to the application server to actually execute the target transaction according to the recorded database operation instruction and the predicted execution data, which is beneficial to improving the execution efficiency and thereby increasing the transaction throughput.
  • FIG. 6 is a schematic structural diagram of a database operating device according to another embodiment of the present disclosure. As shown in FIG. 6, the apparatus includes an acquisition module 61, a prediction execution module 62, and a control execution module 63.
  • the obtaining module 61 is configured to sequentially acquire a database operation instruction in the target transaction executed by the application server during the execution of the target transaction by the application server.
  • the prediction execution module 62 is configured to perform predictive execution on the database operation instruction, return the predicted execution result to the application server to supply the server to determine the next database operation instruction to be executed, and locally record the database operation instruction and the database operation instruction belongs to The predicted execution data generated by the prediction execution is recorded when the locked non-modified database class instruction is executed.
  • the control execution module 63 is configured to, when acquiring the transaction commit instruction in the target transaction, control the database corresponding to the application server to actually execute the target transaction according to the locally recorded database operation instruction and the predicted execution data.
  • the prediction execution module 62 is specifically configured to:
  • the apparatus further includes: a configuration module, configured to configure the database to read the submitted isolation level before the application server performs the target transaction.
  • the prediction execution module 62 is specifically configured to:
  • the data environment of the database operation instruction is simulated in the locally created memory library, and the database operation instruction is predicted and executed based on the simulated data environment;
  • the database operation instruction belongs to a non-modified database class instruction
  • the database operation instruction is executed in the database to perform prediction execution on the database operation instruction.
  • the prediction execution module 62 simulates the data environment of the database operation instruction in the locally created memory library when the database operation instruction belongs to the modified database class instruction, and performs prediction execution on the database operation instruction based on the simulated data environment, specifically to:
  • a write instruction is executed in the memory bank to modify the read data set.
  • control execution module 63 is specifically configured to:
  • the database operation instruction of the local record is sent to the database to instruct the database to execute the database operation instruction, and receives the actual execution result of the database operation instruction returned by the database;
  • the transaction commit instruction is sent to the database for the database to submit the target transaction
  • a transaction rollback instruction is issued to the database for the database to roll back the target transaction.
  • the database operating device cooperates with the application server to join the predictive execution process in the process of executing the target transaction by the application server, and obtains and records all database operation instructions that need to be executed in the target transaction in advance, and only belongs to the locked operation.
  • Non-modified database class The database operation instruction records the predicted execution data generated by the prediction execution to adapt to the locking scheme, provides conditions for the real execution transaction, and then controls the database corresponding to the application server to actually execute the data according to the recorded database operation instruction and the predicted execution data.
  • Target transactions help improve execution efficiency and increase transaction throughput.
  • the disclosed system, apparatus, and method may be implemented in other manners.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • there may be another division manner for example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or unit, and may be in an electrical, mechanical or other form.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
  • the above-described integrated unit implemented in the form of a software functional unit can be stored in a computer readable storage medium.
  • the software functional unit described above is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to perform the methods described in various embodiments of the present application. Part of the steps.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like, which can store program codes. .

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Fuzzy Systems (AREA)
  • Mathematical Physics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种数据库(20)操作方法及装置。一种方法包括:在应用服务器(10)执行目标事务的过程中,依次获取应用服务器(10)执行到的目标事务中的数据库操作指令(301);对数据库操作指令进行预测执行,将预测执行结果返回给应用服务器(10)以供应用服务器(10)确定下一个需要执行的数据库操作指令,并在本地记录数据库操作指令以及在数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录预测执行产生的预测执行数据(302);当获取到目标事务中的事务提交指令时,根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器(10)对应的数据库(20)实际执行目标事务(303)。可以提高事务执行效率,提高吞吐量。

Description

数据库操作方法及装置 【技术领域】
本申请涉及数据库技术领域,尤其涉及一种数据库操作方法及装置。
【背景技术】
数据库事务(Database Transaction),是指作为单个逻辑工作单元执行的一系列操作,要么完全地执行,要么完全地不执行。一个事务由一系列数据库操作指令构成,例如语句。
在数据库操作中,为了保证并发读取数据的正确性,提出了事务隔离级别的概念。在标准结构化查询语言(Structured Query Language,SQL)规范中,定义了4个事务隔离级别,其中,读已提交(Read Committed)是多数应用程序优选考虑的隔离级别,它可以避免脏读取,而且具有较好的并发性能,但仍会遇到不可重复读的问题。
对于读已提交隔离级别事务面临的不可重复读问题,可以通过for update语句临时性的提升读已提交隔离级别事务中某个数据的隔离级别,以保证该数据可重复读取,但这会严重降低系统的并发性能,导致执行效率较低,事务吞吐量较低。
【发明内容】
本申请的多个方面提供一种数据库操作方法及装置,用以保证数据库系统的并发性能,提高事务执行效率并增大事务吞吐量。
本申请的一方面,提供一种数据库操作方法,包括:
在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于修改数 据库类指令和被加锁的非修改数据库类指令其中之一时记录所述预测执行产生的预测执行数据;
当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
本申请的另一方面,提供一种数据库操作方法,包括:
在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于被加锁的非修改数据库类指令时记录所述预测执行产生的预测执行数据;
当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
本申请的又一方面,提供一种数据库操作装置,包括:
获取模块,用于在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
预测执行模块,用于对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录所述预测执行产生的预测执行数据;
控制执行模块,用于当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
本申请的又一方面,提供一种数据库操作装置,包括:
获取模块,用于在应用服务器执行目标事务的过程中,依次获取所述 应用服务器执行到的所述目标事务中的数据库操作指令;
预测执行模块,用于对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于被加锁的非修改数据库类指令时记录所述预测执行产生的预测执行数据;
控制执行模块,用于当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
在本申请中,数据库操作装置与应用服务器相互配合,在应用服务器执行目标事务的过程加入预测执行过程,预先获得并记录目标事务需要执行的全部数据库操作指令,并仅针对属于修改数据库类指令和被加锁的非修改数据库类指令的数据库操作指令,或者仅针对属于被加锁的非修改数据库类指令的数据库操作指令记录预测执行产生的预测执行数据,以适应于读已提交隔离级别下的加锁方案,为真实执行事务提供了条件,之后根据记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行该目标事务,有利于提高执行效率,进而增大事务吞吐量。
【附图说明】
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为现有技术中数据库应用系统的部署图;
图2为本申请一实施例提供的数据库应用系统的部署图;
图3为本申请另一实施例提供的数据库操作方法的流程示意图;
图4为本申请又一实施例提供的数据库操作方法的流程示意图;
图5为本申请又一实施例提供的数据库操作装置的结构示意图;
图6为本申请又一实施例提供的数据库操作装置的结构示意图。
【具体实施方式】
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
图1为现有技术中数据库应用系统的部署图。如图1所示,该系统包括:应用服务器10和数据库20。其中,应用服务器10可以为一个,也可以为多个。数据库20可以为一个,也可以为多个。图1中仅示例性的示出一个应用服务器10和一个数据库20。当需要以事务方式对数据库20进行访问时,应用服务器10执行事务逻辑,依次将事务中的数据库操作指令作用于数据库20上。由于无法预先获知事务中需要执行的数据库操作指令,导致事务执行效率较低,尤其是在配置读已提交隔离级别下通过for update语句对数据进行加锁的方案中,其执行效率会更低,事务吞吐量较低。
针对现有技术存在的缺陷,本申请提供一种新的数据库应用系统,如图2所示。该系统在应用服务器10和数据库20之间增加数据库操作装置30。数据库操作装置30用以执行本申请提供的数据库操作方法,在读已提交这一隔离级别下的加锁方案中实现一种新的事务执行逻辑,即先对事务进行预测执行,提前获得该事务中需要执行的数据库操作指令,实现执行路径的预测,并且结合读已提交这一隔离级别且加锁的情况,仅仅针对属于修改数据库类指令和被加锁的非修改数据库类指令的数据库操作指令,或者仅仅针对属于被加锁的非修改数据库类指令的数据库操作指令记录对其进行预测执行所产生的预测执行数据,进而基于预测执行得到的数据库操作指令以及预测执行数据在数据库20上实际执行事务,有利于提 高事务执行效率,增大事务吞吐量。事务吞吐量是指单位时间内处理事务的数量。
值得说明的是,数据库操作装置30实际上是一种逻辑处理装置,其可以单独部署,位于应用服务器10和数据库20之间,也可以部署于应用服务器10一端实现,或者也可以部署于数据库20一端实现。
下面实施例将具体说明本申请技术方案的方法流程。
图3为本申请另一实施例提供的数据库操作方法的流程示意图。如图3所示,该方法包括:
301、在应用服务器执行目标事务的过程中,依次获取应用服务器执行到的目标事务中的数据库操作指令。
302、对数据库操作指令进行预测执行,将预测执行结果返回给应用服务器以供应用服务器确定下一个需要执行的数据库操作指令,并在本地记录数据库操作指令以及在数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录预测执行产生的预测执行数据。
303、当获取到目标事务中的事务提交指令时,根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务。
首先说明,为便于描述,本实施例将应用服务器需要执行的事务称为目标事务。目标事务主要包括用于对数据库进行操作的操作指令,除数据库操作指令之外还包括一些用于控制目标事务执行状态的控制指令,例如事务开始指令、事务提交指令、事务回滚指令等。这些指令实际上是由数据库语言编写的语句。根据数据库语言的不同,这些指令可以是不同语言编写的语句。举例说明,若采用SQL,则上述数据库操作指令和控制指令实际上是一系列的SQL语句。
另外,在一些应用场景中,事务的处理需要先选中一些记录,再对这些记录进行处理,因此需要对选择的记录加排他锁。这意味着,本实施例中的数据库操作指令可能是加锁的数据库操作指令。例如,假设从Bob的 账户里转出100元,这个操作由三步完成,查询Bob的账户,判断该账户是否够100元,将Bob的账户里的钱减少100块。如果有两个转账操作并行进行,当第一个转账操作查出Bob的账户的余额,发现有100块,如果这时候有另外一个转账操作也去查了Bob的账户,也发现Bob的账户里有100块,于是这两个转账操作都会进行转账,于是,第一个操作从Bob的账户减去100块钱,另一个操作也从Bob的账户减去100块钱,这时候,Bob的账户余额就可能是负数。为了避免这种情况,需要使用for update来对Bob的账户加锁,保证在第一个转账操作进行过程中,第二个转账操作无法获得这个锁,也就无法进行查询。
本实施例提供的方法适用于对隔离级别为读已提交的数据库进行操作。其中,有些数据库默认是读已提交这一隔离级别,例如,Oracle数据库默认是读已提交这一隔离级别的,有些数据库默认不是读已提交这一隔离级别,例如MySQL数据库默认是可重复读这一隔离级别。基于此,在执行本实施例提供的方法之前,可以确定数据库的隔离级别是否是读已提交,若不是,则需要预先配置数据库为读已提交这一隔离级别。例如,可以在应用服务器执行目标事务之前,配置数据库为读已提交这一隔离级别。
在数据库的隔离级别为读已提交的前提下,可以执行本实施例提供的方法以在数据库中执行目标事务。具体流程如下:
应用服务器控制整个目标事务的执行逻辑,可以按照现有方式执行目标事务。数据库操作装置在应用服务器执行目标事务的过程中,依次获取应用服务器执行到的目标事务中的数据库操作指令。
在一可选实施方式中,应用服务器按照现有方式向数据库发送数据库操作指令,以实现对数据库的访问。数据库操作装置可以对应用服务器与数据库之间的通信进行监控,以拦截应用服务器发往数据库的数据库操作指令。
在另一可选实施方式中,对应用服务器的处理逻辑进行稍微修改,将原来向数据库发送数据库操作指令的处理逻辑改为向数据库操作装置发送。基于此,数据库操作装置可以接收应用服务器主动下发的数据库操作 指令。
在此说明,若目标事务是显式事务,则目标事务中的首个指令是事务开始指令,如开始事务(begin transaction),基于此,数据库操作装置在获取应用服务器执行到的数据库操作指令之前,可以拦截应用服务器发往数据库的目标事务中的事务开始指令,根据该事务开始指令,获知需要执行目标事务。或者,数据库操作装置在获取应用服务器执行到的数据库操作指令之前,可以接收应用服务器主动下发的目标事务中的事务开始指令,根据该事务开始指令,获知需要执行目标事务。若目标事务是隐式事务,则目标事务的首个指令就是数据库操作指令,不包括获取事务开始指令的步骤。
数据库操作装置在获取应用服务器执行到的数据库操作指令后,对获取到的数据库操作指令进行预测执行,将预测执行结果返回给应用服务器,以供应用服务器确定下一个需要执行的数据库操作指令。其中,预测执行结果决定着目标事务的执行路径,这里的执行路径是指数据库操作指令之间的跳转逻辑。通过将预测执行结果返回给应用服务器,从而达到由应用服务器控制整个目标事务的执行逻辑的目的。
另外,数据库操作装置还需要在本地记录所获取到的数据库操作指令,以及在该数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时,记录对该数据库操作指令进行预测执行产生的预测执行数据。所述修改数据库类指令是指对数据库有修改的数据库操作指令,例如以update、insert等开头的指令;一般以select开头的指令不属于修改数据库类指令(称为非修改数据库类指令)。虽然从本质而言,读已提交隔离级别只保证写入多个数据是原子的,不在读取的时候加锁,但为了保证事务的一致性,降低回滚概率,有些非修改数据库类指令可能需要通过for update语句进行加锁,例如在上面转账举例中,select指令需要加锁,形成select……for update形式的数据库操作指令,这种指令可称为被加锁的非修改数据库类指令。所述预测执行数据主要是指对数据库操作指令进行预测执行过程中的一些数据,例如数据库操作指令所操作的数据以及数据的主键ID和主键ID对应的版本号信息(version)等。
值得说明的是,对于同一数据库操作指令来说,要么属于修改数据库类指令,要么属于被加锁的非修改数据库类指令,要么属于未加锁的非修改数据库类指令。但是,从整个目标事务来看,对于该目标事务中所有修改数据库类指令以及所有被加锁的非修改数据库类指令预测执行产生的预测执行数据都会被记录在本地。
例如,数据库操作装置可以在本地创建内存库,将所获取到的数据库操作指令以及预测执行数据存入内存库中。进一步,若预测执行数据不包括预测执行结果,则也可以将预测执行结果存入内存库中。
为了在预测执行这一核心思想的基础上实现对读已提交这一隔离级别下的加锁方案的模拟,本实施例针对属于修改数据库类指令和被加锁的非修改数据库类指令其中之一的数据库操作指令,记录其预测执行产生的预测执行数据,却不记录属于未被加锁的非修改数据库类指令的数据库操作指令对应的预测执行数据。由此可见,在实现读已提交这一隔离级别下的加锁方案的情况下,所记录的数据量相对较少,这样在后续基于本地记录的数据库操作指令和预测执行数据在数据库中真实执行目标事务的过程中,所需处理的数据量相对较少,有利于进一步提高执行效率和性能,增大事务吞吐量。
其中,数据库操作指令对数据库的操作主要是访问数据库中的数据,则可以模拟数据库操作指令的数据环境,基于所模拟的数据环境对数据库操作指令进行预测执行。进一步,考虑到属于非修改数据库类指令的数据库操作指令不会引起数据库的变化,因此可以直接在数据库中对该数据库操作指令进行预测执行,这样可以节约模拟数据环境的操作,实现相对简单,有利于节约资源,提高执行效率。但是,对于属于修改数据库类指令的数据库操作指令,由于其会引起数据库的变化(主要是指数据库中的数据被改变),因此需要模拟数据环境,在所模拟的数据环境中进行预测执行。
基于上述分析,一种对数据库操作指令进行预测执行的方式可以是:
对获取到的数据库操作指令的类别进行识别;
若数据库操作指令属于修改数据库类指令,则在本地创建的内存库中 模拟数据库操作指令的数据环境,基于所模拟的数据环境对数据库操作指令进行预测执行;
若数据库操作指令属于非修改数据库类指令,在数据库中执行该数据库操作指令,以对该数据库操作指令进行预测执行。
进一步,一种在本地创建的内存库中模拟数据库操作指令的数据环境,基于所模拟的数据环境对数据库操作指令进行预测执行的实施方式包括:
将获取到的数据库操作指令拆分为一个读指令和一个写指令,将读指令运行于真正的数据库上,即在数据库中执行该读指令以获取读数据集(ReadSet),将读数据集存入本地内存库中,以模拟数据库操作指令所需的数据环境。然后,将写指令作用于内存库上,以实现对数据库操作指令的预测执行,即在内存库中执行写指令以修改读数据集,例如对读数据集中的有关数据进行更新或查询处理等。其中,执行写指令以修改读数据集可以产生结果数据集(affectRowInMemdb),该结果数据集包括预测执行结果。
在上述预测执行过程中,若数据库操作指令属于修改数据库类指令,则数据库操作装置可以在本地记录读指令所读取的读数据集以及执行写指令产生的结果数据集。由此可见,所述预测执行数据可以包括读数据集和结果数据集,或者也可以包括读数据集和结果数据集中的部分数据,例如能够对在数据库中实际执行目标事务产生有益效果的一些数据,例如一些数值的各种索引,例如一级索引、二级索引、主键ID、版本号等。
较优的,为了进一步减少记录的数据量,在数据库操作指令属于被加锁的非修改数据库类指令时,可以仅记录该数据库操作指令所操作的数据的主键ID和版本号作为预测执行数据。这样在后续基于本地记录的数据库操作指令和预测执行数据在数据库中真实执行目标事务的过程中,所需处理的数据量会进一步较少,有利于进一步提高执行效率和性能,增大事务吞吐量。另外,有时数据在事务过程中可能会经过多次修改,但最终又回到初始值,但数据的主键ID和版本号不会发生变化。因此,若采用记录数据本身的方式,在预测执行与真实执行进行比较时数据可能不一样,就要发生回滚,而回滚的代价较大。但是,本实施例采用只记录数据 的主键ID和版本号的方式,在预测执行与真实执行进行比较时出现不一致的概率较低,回滚概率较低。
当数据库操作装置获取到目标事务中的事务提交指令(即应用服务器执行到事务提交指令)时,则可以根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务。
上述根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务的一种可选实施方式包括:
数据库操作装置向数据库下发本地记录的所述数据库操作指令,以指示数据库执行数据库操作指令,并接收数据库返回的数据库操作指令的实际执行结果;然后,将数据库操作指令的实际执行结果与预测执行结果进行比较,若实际执行结果与预测执行结果相同,向数据库下发事务提交指令,以供数据库提交该目标事务;若实际执行结果与预测执行结果不相同,向数据库下发事务回滚指令,以供数据库回滚该目标事务。
在上述实施方式中,考虑到事务的原子性,通过将实际执行结果与预测执行结果进行比较,可以避免事务执行过程出错,有利于提高事务执行的成功概率。
进一步,在现有技术中,由于无法预先知道事务需要执行的全部数据库操作指令,所以只能按照事务的执行逻辑依次执行数据库操作指令,这会导致应用服务器与数据库之间的频繁交互,这在远程应用场景中将会消耗大量网络资源。但在本实施例中,通过预测执行过程已经预先获得目标事务需要执行的全部数据库操作指令,即本地记录的数据库操作指令,因此在向数据库下发本地记录的数据库操作指令,以指示数据库执行数据库操作指令的过程中,可以将本地记录的数据库操作指令同时(或者一并)下发到数据库,有利于节约网络资源。另外,对于一些并行的数据库操作指令,数据库还可以并行操作,有利于进一步提高事务执行效率,增大事务吞吐量。
进一步,还可以将本地记录的所有数据库操作指令连同本地记录的预测执行数据一并下发给数据库。
进一步,在一种根据本地记录的数据库操作指令以及预测执行数据, 控制应用服务器对应的数据库实际执行目标事务的可选实施方式中,数据库操作装置可以根据本地记录的数据库操作指令,判断目标事务是否为单机事务;若判断结果为是,则根据本地记录的数据库操作指令以及预测执行数据,以单机事务处理逻辑控制数据库实际执行目标事务;若判断结果为否,则根据本地记录的数据库操作指令以及预测执行数据,以分布式事务处理逻辑控制数据库实际执行目标事务。
其中,基于预测执行过程中获得的数据库操作指令可以识别出目标事务是单机事务还是分布式事务。例如,可以判断本地记录的数据库操作指令的操作对象是否作用于同一物理设备上,若判断结果为是,则可以确定该目标事务为单机事务;若判断结果为否,则可以确定该目标事务为分布式事务。
由于分布式事务的处理逻辑和单机事务的处理逻辑有所不同,单机事务的处理逻辑相对简单,例如不涉及读写加锁等问题,所以所消耗的资源也相对较少。基于此,本实施例通过识别目标事务是否为单机事务,在识别为单机事务时采用单机事务的处理逻辑进行处理,而不是像现有技术那样统一采用分布式事务处理逻辑进行处理,有利于提高处理效率,节约处理成本。
在一可选实施方式中,若数据库操作装置获取到目标事务中的事务回滚指令(即应用服务器执行到事务回滚指令)时,可以删除本地记录的数据库操作指令以及预测执行数据,例如可以直接清空本地内存库,实现回滚操作。在该情况下,由于目标事务并未在数据库中真正执行,所以数据库无需执行回滚操作,可见,在事务回滚这种情况下,采用本实施例方法也可以提高事务执行效率。
由上述可见,在本实施例提供的方法中,数据库操作装置与应用服务器相互配合,在应用服务器执行目标事务的过程加入预测执行过程,在预测执行过程中,可以提前获得目标事务的执行路径,即真正需要执行的数据库操作指令,并仅针对属于修改数据库类指令的数据库操作指令,或者仅针对属于被加锁的非修改数据库类指令的数据库操作指令记录预测执行产生的预测执行数据,以适应于读已提交隔离级别下的加锁方案,为真 实执行事务提供了条件,之后在根据记录的数据库操作指令以及预测执行数据实际执行该目标事务时,例如基于预测执行数据可以提前获取有关数据信息并且可以减少指令之间的跳转等,因此可以提高执行效率,增大事务吞吐量。
下面以减库存事务为例,详细说明本申请技术方案的工作流程。其中,数据库的隔离级别为读已提交这一隔离级别。
减库存事务的SQL代码如下,括号内的文字为注释:
begin transaction(开始事务)
select*from inventory where itemId=?for update(用商品id查看当前库存,注意这里用for update外部显示加锁)
if(item.inventory>0)
item.inventory--;
update inventory set item.inventory=$item.inventory where itemId=?
commit;
else
rollback;(如果当前库存大于0,则减少、更新商品库存并提交,否则回滚)
在实际执行过程中,应用服务器负责该减库存事务的整个逻辑,数据库操作装置(或者也可称为执行服务器)只会获取应用服务器执行到的开始事务,需要执行的SQL语句,以及提交/回滚指令。
首先,开始事务后,数据库操作装置在本地创建内存库;
当数据库操作装置获取到select*from inventory where itemId=?for update这条SQL语句时,识别出这条SQL语句不会修改数据库,因此将这条SQL语句直接作用在实际数据库中,即在数据库中执行该条SQL语句以获得查询结果,即读数据集,将全部查询结果返回给应用服务器,以供应用服务器确定下一个需要执行的SQL语句,并在本地内存库中记录这条SQL语句。虽然是读已隔离级别,但由于该语句被加锁,故需要记录执 行该条SQL语句有关的数据,优选的可以仅记录该SQL语句所查询的数据的主键ID和版本号(version)。
应用服务器收到数据库操作装置返回的查询结果后,判断查询结果中当前库存量是否大于0,若判断结果为是,则将当前库存量减少,并执行更新语句,即update inventory set item.inventory=$item.inventory where itemId=?;若判断结果为否,则执行rollback语句。
第一种情况,假设应用服务器执行了rollback语句,则数据库操作装置会获取到rollback语句。一旦数据库存储装置获取到rollback语句,则清空本地内存库,主要是指清空之前记录的select*from inventory where itemId=?for update这条SQL语句。在这种情况下,因为事务并没有在数据库中执行,所以无需数据库执行回滚操作。
第二种情况,假设应用服务器执行了update inventory set item.inventory=$item.inventory where itemId=?这条语句,则数据库操作装置会获取到update inventory set item.inventory=$item.inventory where itemId=?这条语句。则数据库操作装置获取到update inventory set item.inventory=?where itemId=?这条SQL语句时,识别出该SQL语句会修改数据库,于是将这条SQL语句拆解为一个读指令,即select*from inventory where itemId=?和一个写指令,即update inventory set item.inventory=?where itemId=?;接着,将select*from inventory where itemId=?这个语句下发到数据库中,获得读数据集,将读数据集中的数据写入本地内存库中;其中,读数据集中包括主键列表(itemId)和该主键对应的版本号(version)。然后,根据update inventory set item.inventory=?where itemId=?这个语句在本地内存库中进行更新操作,以获得结果数据集,并将结果数据集返回给应用服务器。该结果数据集可以是类似修改了几条记录这样的修改记录信息,例如,affectRow=1表示修改了一条记录;或者,结果数据集也可以是记录修改详细信息的修改详情信息。其中,结果数据集和读数据集构成预测执行数据。
应用服务器此时执行commit指令。
当数据库操作装置获取到commit指令后,基于本地内存库中的SQL 语句以及预测执行数据,在数据库中执行该减库存事务,这次事务执行过程是真实执行的。例如,本地记录的SQL语句以及预测执行数据如下所示:
Figure PCTCN2016109666-appb-000001
优选的,数据库操作装置可以一次性将本地内存库中的SQL语句全部提交到数据库中,数据库基于此进行执行,有利于节约传输SQL语句所消耗的网络资源。
这次真实执行也会返回执行结果,可以将预测执行结果与实际执行结果进行比较,例如可以先比较两个结果中的主键ID和版本号,然后再比较两个结果中的affectRow;如果比较结果为相同,则可以在数据库中提交这次事务,而如果比较结果为不相同,则认为提交是失败的,由于在这种情况下,事务本身其实一直都没有真正的在数据库中执行提交,所以可以简单地回滚整个请求,让应用服务器重新提交即可。
其中,经过上述预测执行,已经获得了所有的需要执行的SQL语句,以及相应的预测执行数据,例如全部切分条件,数值的索引、版本号等,而这些数据足以让我们提前对事务是否是单机事务做出判断。基于此,可以采用相应的事务处理逻辑进行处理,有利于节约资源。
图4为本申请又一实施例提供的数据库操作方法的流程示意图。如图4所示,该方法包括:
401、在应用服务器执行目标事务的过程中,依次获取应用服务器执行到的目标事务中的数据库操作指令。
402、对数据库操作指令进行预测执行,将预测执行结果返回给应用服务器以供应用服务器确定下一个需要执行的数据库操作指令,并在本地记录数据库操作指令以及在数据库操作指令属于被加锁的非修改数据库 类指令时记录预测执行产生的预测执行数据。
403、当获取到目标事务中的事务提交指令时,根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务。
本实施例与图3所示实施例相类似,区别在于:仅记录目标事务中被加锁的非修改数据库类指令的预测执行产生的预测执行数据,对于修改数据库类指令的预测执行产生的预测执行数据以及未加锁的非修改数据库类指令的预测执行产生的预测执行数据不作记录。另外,本实施例适用于目标事务包括被加锁的非修改数据库类指令的情况,所操作的数据库不仅可以是隔离级别为读已提交的数据库场景,也可以是其它各种数据库场景。
若将本实施例提供的方法应用于隔离级别为读已提交的数据库,则考虑到有些数据库默认是读已提交这一隔离级别,例如,Oracle数据库默认是读已提交这一隔离级别的,有些数据库默认不是读已提交这一隔离级别,例如MySQL数据库默认是可重复读这一隔离级别,于是在执行本实施例提供的方法之前,可以确定数据库的隔离级别是否是读已提交,若不是,则需要预先配置数据库为读已提交这一隔离级别。例如,可以在应用服务器执行目标事务之前,配置数据库为读已提交这一隔离级别。
在一可选实施方式中,应用服务器按照现有方式向数据库发送数据库操作指令,以实现对数据库的访问。数据库操作装置可以对应用服务器与数据库之间的通信进行监控,以拦截应用服务器发往数据库的数据库操作指令。
在另一可选实施方式中,对应用服务器的处理逻辑进行稍微修改,将原来向数据库发送数据库操作指令的处理逻辑改为向数据库操作装置发送。基于此,数据库操作装置可以接收应用服务器主动下发的数据库操作指令。
在此说明,若目标事务是显式事务,则目标事务中的首个指令是事务开始指令,如开始事务(begin transaction),基于此,数据库操作装置在获取应用服务器执行到的数据库操作指令之前,可以拦截应用服务器发往数 据库的目标事务中的事务开始指令,根据该事务开始指令,获知需要执行目标事务。或者,数据库操作装置在获取应用服务器执行到的数据库操作指令之前,可以接收应用服务器主动下发的目标事务中的事务开始指令,根据该事务开始指令,获知需要执行目标事务。若目标事务是隐式事务,则目标事务的首个指令就是数据库操作指令,不包括获取事务开始指令的步骤。
数据库操作装置在获取应用服务器执行到的数据库操作指令后,对获取到的数据库操作指令进行预测执行,将预测执行结果返回给应用服务器,以供应用服务器确定下一个需要执行的数据库操作指令。其中,预测执行结果决定着目标事务的执行路径,这里的执行路径是指数据库操作指令之间的跳转逻辑。通过将预测执行结果返回给应用服务器,从而达到由应用服务器控制整个目标事务的执行逻辑的目的。
另外,数据库操作装置还需要在本地记录所获取到的数据库操作指令,以及在该数据库操作指令属于被加锁的非修改数据库类指令时,记录对该数据库操作指令进行预测执行产生的预测执行数据。所述修改数据库类指令是指对数据库有修改的数据库操作指令,例如以update、insert等开头的指令;一般以select开头的指令不属于修改数据库类指令(称为非修改数据库类指令)。有时,为了保证事务的一致性,降低回滚概率,有些非修改数据库类指令可能需要通过for update语句进行加锁,例如在上面转账举例中,select指令需要加锁,形成select……for update形式的数据库操作指令,这种指令可称为被加锁的非修改数据库类指令。所述预测执行数据主要是指对数据库操作指令进行预测执行过程中的一些数据,例如数据库操作指令所操作的数据以及数据的主键ID(itemId)和主键ID对应的版本号信息(version)。
值得说明的是,对于同一数据库操作指令来说,要么属于修改数据库类指令,要么属于被加锁的非修改数据库类指令,要么属于未加锁的非修改数据库类指令。在该实施例中,对于目标事务中所有被加锁的非修改数据库类指令预测执行产生的预测执行数据都会被记录在本地。
例如,数据库操作装置可以在本地创建内存库,将所获取到的数据库 操作指令以及预测执行数据存入内存库中。进一步,若预测执行数据不包括预测执行结果,则也可以将预测执行结果存入内存库中。
为了在预测执行这一核心思想的基础上实现对加锁方案的模拟,本实施例针对被加锁的非修改数据库类指令的数据库操作指令,记录其预测执行产生的预测执行数据,却不记录其它数据库操作指令对应的预测执行数据。由此可见,在实现加锁方案的情况下,所记录的数据量相对较少,这样在后续基于本地记录的数据库操作指令和预测执行数据在数据库中真实执行目标事务的过程中,所需处理的数据量相对较少,有利于进一步提高执行效率和性能,增大事务吞吐量。
较优选的,在数据库操作指令属于被加锁的非修改数据库类指令时,可以仅记录该数据库操作指令所操作的数据的主键ID和版本号作为预测执行数据。这样在后续基于本地记录的数据库操作指令和预测执行数据在数据库中真实执行目标事务的过程中,所需处理的数据量会进一步较少,有利于进一步提高执行效率和性能,增大事务吞吐量。另外,有时数据在事务过程中可能会经过多次修改,但最终又回到初始值,但数据的主键ID和版本号不会发生变化。因此,若采用记录数据本身的方式,在预测执行与真实执行进行比较时数据可能不一样,就要发生回滚,而回滚的代价较大。但是,本实施例采用只记录主键ID和版本号的方式,在预测执行与真实执行进行比较时出现不一致的概率较低,回滚概率较低。
其中,数据库操作指令对数据库的操作主要是访问数据库中的数据,则可以模拟数据库操作指令的数据环境,基于所模拟的数据环境对数据库操作指令进行预测执行。进一步,考虑到属于非修改数据库类指令的数据库操作指令不会引起数据库的变化,因此可以直接在数据库中对该数据库操作指令进行预测执行,这样可以节约模拟数据环境的操作,实现相对简单,有利于节约资源,提高执行效率。但是,对于属于修改数据库类指令的数据库操作指令,由于其会引起数据库的变化(主要是指数据库中的数据被改变),因此需要模拟数据环境,在所模拟的数据环境中进行预测执行。
基于上述分析,一种对数据库操作指令进行预测执行的方式可以是:
对获取到的数据库操作指令的类别进行识别;
若数据库操作指令属于修改数据库类指令,则在本地创建的内存库中模拟数据库操作指令的数据环境,基于所模拟的数据环境对数据库操作指令进行预测执行;
若数据库操作指令属于非修改数据库类指令,在数据库中执行该数据库操作指令,以对该数据库操作指令进行预测执行。
进一步,一种在本地创建的内存库中模拟数据库操作指令的数据环境,基于所模拟的数据环境对数据库操作指令进行预测执行的实施方式包括:
将获取到的数据库操作指令拆分为一个读指令和一个写指令,将读指令运行于真正的数据库上,即在数据库中执行该读指令以获取读数据集(ReadSet),将读数据集存入本地内存库中,以模拟数据库操作指令所需的数据环境。然后,将写指令作用于内存库上,以实现对数据库操作指令的预测执行,即在内存库中执行写指令以修改读数据集,例如对读数据集中的有关数据进行更新或查询处理等。其中,执行写指令以修改读数据集可以产生结果数据集(affectRowInMemdb),该结果数据集包括预测执行结果。
当数据库操作装置获取到目标事务中的事务提交指令(即应用服务器执行到事务提交指令)时,则可以根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务。
上述根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务的一种可选实施方式包括:
数据库操作装置向数据库下发本地记录的数据库操作指令,以指示数据库执行数据库操作指令,并接收数据库返回的数据库操作指令的实际执行结果;然后,将数据库操作指令的实际执行结果与预测执行结果进行比较,若实际执行结果与预测执行结果相同,向数据库下发事务提交指令,以供数据库提交该目标事务;若实际执行结果与预测执行结果不相同,向数据库下发事务回滚指令,以供数据库回滚该目标事务。
在上述实施方式中,考虑到事务的原子性,通过将实际执行结果与预 测执行结果进行比较,可以避免事务执行过程出错,有利于提高事务执行的成功概率。
进一步,在现有技术中,由于无法预先知道事务需要执行的全部数据库操作指令,所以只能按照事务的执行逻辑依次执行数据库操作指令,这会导致应用服务器与数据库之间的频繁交互,这在远程应用场景中将会消耗大量网络资源。但在本实施例中,通过预测执行过程已经预先获得目标事务需要执行的全部数据库操作指令,即本地记录的数据库操作指令,因此在向数据库下发本地记录的数据库操作指令,以指示数据库执行数据库操作指令的过程中,可以将本地记录的数据库操作指令同时(或者一并)下发到数据库,有利于节约网络资源。另外,对于一些并行的数据库操作指令,数据库还可以并行操作,有利于进一步提高事务执行效率,增大事务吞吐量。
进一步,还可以将本地记录的所有数据库操作指令连同本地记录的预测执行数据一并下发给数据库。
进一步,在一种根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务的可选实施方式中,数据库操作装置可以根据本地记录的数据库操作指令,判断目标事务是否为单机事务;若判断结果为是,则根据本地记录的数据库操作指令以及预测执行数据,以单机事务处理逻辑控制数据库实际执行目标事务;若判断结果为否,则根据本地记录的数据库操作指令以及预测执行数据,以分布式事务处理逻辑控制数据库实际执行目标事务。
其中,基于预测执行过程中获得的数据库操作指令可以识别出目标事务是单机事务还是分布式事务。例如,可以判断本地记录的数据库操作指令的操作对象是否作用于同一物理设备上,若判断结果为是,则可以确定该目标事务为单机事务;若判断结果为否,则可以确定该目标事务为分布式事务。
由于分布式事务的处理逻辑和单机事务的处理逻辑有所不同,单机事务的处理逻辑相对简单,例如不涉及读写加锁等问题,所以所消耗的资源也相对较少。基于此,本实施例通过识别目标事务是否为单机事务,在识 别为单机事务时采用单机事务的处理逻辑进行处理,而不是像现有技术那样统一采用分布式事务处理逻辑进行处理,有利于提高处理效率,节约处理成本。
在一可选实施方式中,若数据库操作装置获取到目标事务中的事务回滚指令(即应用服务器执行到事务回滚指令)时,可以删除本地记录的数据库操作指令以及预测执行数据,例如可以直接清空本地内存库,实现回滚操作。在该情况下,由于目标事务并未在数据库中真正执行,所以数据库无需执行回滚操作,可见,在事务回滚这种情况下,采用本实施例方法也可以提高事务执行效率。
由上述可见,在本实施例提供的方法中,数据库操作装置与应用服务器相互配合,在应用服务器执行目标事务的过程加入预测执行过程,在预测执行过程中,可以提前获得目标事务的执行路径,即真正需要执行的数据库操作指令,并仅针对属于被加锁的非修改数据库类指令的数据库操作指令记录预测执行产生的预测执行数据,以适应于加锁方案,为真实执行事务提供了条件,之后在根据记录的数据库操作指令以及预测执行数据实际执行该目标事务时,例如基于预测执行数据可以提前获取有关数据信息并且可以减少指令之间的跳转等,因此可以提高执行效率,增大事务吞吐量。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。
图5为本申请又一实施例提供的数据库操作装置的结构示意图。如图5所示,该装置包括:获取模块51、预测执行模块52和控制执行模块53。
获取模块51,用于在应用服务器执行目标事务的过程中,依次获取应 用服务器执行到的目标事务中的数据库操作指令。
预测执行模块52,用于对数据库操作指令进行预测执行,将预测执行结果返回给应用服务器以供应用服务器确定下一个需要执行的数据库操作指令,并在本地记录数据库操作指令以及在数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录预测执行产生的预测执行数据。
控制执行模块53,用于当获取到目标事务中的事务提交指令时,根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务。
在一可选实施方式中,预测执行模块52在数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录预测执行产生的预测执行数据的过程中,具体可用于:
在数据库操作指令属于被加锁的非修改数据库类指令时,仅记录该数据库操作指令所操作的数据的主键ID和数据版本号作为预测执行数据。
在一可选实施方式中,该装置还包括:配置模块,用于在应用服务器执行目标事务之前,配置数据库为读已提交隔离级别。
在一可选实施方式中,预测执行模块52具体用于:
若数据库操作指令属于修改数据库类指令,在本地创建的内存库中模拟数据库操作指令的数据环境,基于模拟的数据环境对数据库操作指令进行预测执行;
若数据库操作指令属于非修改数据库类指令,在数据库中执行数据库操作指令,以对数据库操作指令进行预测执行。
进一步,预测执行模块52在数据库操作指令属于修改数据库类指令的情况下,在本地创建的内存库中模拟数据库操作指令的数据环境,基于模拟的数据环境对数据库操作指令进行预测执行时,具体用于:
将数据库操作指令拆分为读指令和写指令;
在数据库中执行读指令以获取读数据集,将读数据集存入内存库中以模拟数据库操作指令的数据环境;
在内存库中执行写指令以修改读数据集。
在一可选实施方式中,控制执行模块53具体可用于:
向数据库下发本地记录的数据库操作指令,以指示数据库执行数据库操作指令,并接收数据库返回的数据库操作指令的实际执行结果;
若实际执行结果与预测执行结果相同,向数据库下发事务提交指令,以供数据库提交目标事务;
若实际执行结果与预测执行结果不相同,向数据库下发事务回滚指令,以供数据库回滚目标事务。
本实施例提供的数据库操作装置,与应用服务器相互配合,在应用服务器执行目标事务的过程加入预测执行过程,预先获得并记录目标事务需要执行的全部数据库操作指令,并仅针对属于修改数据库类指令和被加锁的非修改数据库类指令的数据库操作指令,或者仅针对属于被加锁的非修改数据库类指令的数据库操作指令记录预测执行产生的预测执行数据,以适应于读已提交隔离级别下的加锁方案,为真实执行事务提供了条件,之后根据记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行该目标事务,有利于提高执行效率,进而增大事务吞吐量。
图6为本申请又一实施例提供的数据库操作装置的结构示意图。如图6所示,该装置包括:获取模块61、预测执行模块62和控制执行模块63。
获取模块61,用于在应用服务器执行目标事务的过程中,依次获取应用服务器执行到的目标事务中的数据库操作指令。
预测执行模块62,用于对数据库操作指令进行预测执行,将预测执行结果返回给应用服务器以供应用服务器确定下一个需要执行的数据库操作指令,并在本地记录数据库操作指令以及在数据库操作指令属于被加锁的非修改数据库类指令时记录预测执行产生的预测执行数据。
控制执行模块63,用于当获取到目标事务中的事务提交指令时,根据本地记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行目标事务。
在一可选实施方式中,预测执行模块62具体可用于:
在数据库操作指令属于被加锁的非修改数据库类指令时,仅记录该数据库操作指令所操作的数据的主键ID和版本号作为预测执行数据。
在一可选实施方式中,该装置还包括:配置模块,用于在应用服务器执行目标事务之前,配置数据库为读已提交隔离级别。
在一可选实施方式中,预测执行模块62具体用于:
若数据库操作指令属于修改数据库类指令,在本地创建的内存库中模拟数据库操作指令的数据环境,基于模拟的数据环境对数据库操作指令进行预测执行;
若数据库操作指令属于非修改数据库类指令,在数据库中执行数据库操作指令,以对数据库操作指令进行预测执行。
进一步,预测执行模块62在数据库操作指令属于修改数据库类指令的情况下,在本地创建的内存库中模拟数据库操作指令的数据环境,基于模拟的数据环境对数据库操作指令进行预测执行时,具体用于:
将数据库操作指令拆分为读指令和写指令;
在数据库中执行读指令以获取读数据集,将读数据集存入内存库中以模拟数据库操作指令的数据环境;
在内存库中执行写指令以修改读数据集。
在一可选实施方式中,控制执行模块63具体可用于:
向数据库下发本地记录的数据库操作指令,以指示数据库执行数据库操作指令,并接收数据库返回的数据库操作指令的实际执行结果;
若实际执行结果与预测执行结果相同,向数据库下发事务提交指令,以供数据库提交目标事务;
若实际执行结果与预测执行结果不相同,向数据库下发事务回滚指令,以供数据库回滚目标事务。
本实施例提供的数据库操作装置,与应用服务器相互配合,在应用服务器执行目标事务的过程加入预测执行过程,预先获得并记录目标事务需要执行的全部数据库操作指令,并仅针对属于被加锁的非修改数据库类指 令的数据库操作指令记录预测执行产生的预测执行数据,以适应于加锁方案,为真实执行事务提供了条件,之后根据记录的数据库操作指令以及预测执行数据,控制应用服务器对应的数据库实际执行该目标事务,有利于提高执行效率,进而增大事务吞吐量。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用硬件加软件功能单元的形式实现。
上述以软件功能单元的形式实现的集成的单元,可以存储在一个计算机可读取存储介质中。上述软件功能单元存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (14)

  1. 一种数据库操作方法,其特征在于,包括:
    在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
    对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录所述预测执行产生的预测执行数据;
    当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
  2. 根据权利要求1所述的方法,其特征在于,所述在所述数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录所述预测执行产生的预测执行数据,包括:
    在所述数据库操作指令属于被加锁的非修改数据库类指令时,仅记录所述数据库操作指令所操作的数据的主键ID和版本号作为所述预测执行数据。
  3. 根据权利要求1所述的方法,其特征在于,还包括:
    在所述应用服务器执行所述目标事务之前,配置所述数据库为读已提交隔离级别。
  4. 根据权利要求1所述的方法,其特征在于,所述对所述数据库操作指令进行预测执行,包括:
    若所述数据库操作指令属于修改数据库类指令,在本地创建的内存库中模拟所述数据库操作指令的数据环境,基于所述模拟的数据环境对所述数据库操作指令进行预测执行;
    若所述数据库操作指令属于非修改数据库类指令,在所述数据库中执行所述数据库操作指令,以对所述数据库操作指令进行预测执行。
  5. 根据权利要求4所述的方法,其特征在于,所述在本地创建的内存库中模拟所述数据库操作指令所需的数据环境,基于所述模拟的数据环境对所述数据库操作指令进行预测执行,包括:
    将所述数据库操作指令拆分为读指令和写指令;
    在所述数据库中执行所述读指令以获取读数据集,将所述读数据集存入所述内存库中以模拟所述数据库操作指令的数据环境;
    在所述内存库中执行所述写指令以修改所述读数据集。
  6. 根据权利要求1-5任一项所述的方法,其特征在于,所述根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务,包括:
    向所述数据库下发本地记录的所述数据库操作指令,以指示所述数据库执行所述数据库操作指令,并接收所述数据库返回的所述数据库操作指令的实际执行结果;
    若所述实际执行结果与所述预测执行结果相同,向所述数据库下发所述事务提交指令,以供所述数据库提交所述目标事务;
    若所述实际执行结果与所述预测执行结果不相同,向所述数据库下发事务回滚指令,以供所述数据库回滚所述目标事务。
  7. 一种数据库操作方法,其特征在于,包括:
    在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
    对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于被加锁的非修改数据库类指令时记录所述预测执行产生的预测执行数据;
    当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
  8. 一种数据库操作装置,其特征在于,包括:
    获取模块,用于在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
    预测执行模块,用于对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于修改数据库类指令和被加锁的非修改数据库类指令其中之一时记录所述预测执行产生的预测执行数据;
    控制执行模块,用于当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
  9. 根据权利要求8所述的装置,其特征在于,所述预测执行模块具体用于:
    在所述数据库操作指令属于被加锁的非修改数据库类指令时,仅记录所述数据库操作指令所操作的数据的主键ID和版本号作为所述预测执行数据。
  10. 根据权利要求8所述的装置,其特征在于,还包括:
    配置模块,用于在所述应用服务器执行所述目标事务之前,配置所述数据库为读已提交隔离级别。
  11. 根据权利要求8所述的装置,其特征在于,所述预测执行模块具体用于:
    若所述数据库操作指令属于修改数据库类指令,在本地创建的内存库中模拟所述数据库操作指令的数据环境,基于所述模拟的数据环境对所述数据库操作指令进行预测执行;
    若所述数据库操作指令属于非修改数据库类指令,在所述数据库中执行所述数据库操作指令,以对所述数据库操作指令进行预测执行。
  12. 根据权利要求11所述的装置,其特征在于,所述预测执行模块具体用于:
    将所述数据库操作指令拆分为读指令和写指令;
    在所述数据库中执行所述读指令以获取读数据集,将所述读数据集存入所述内存库中以模拟所述数据库操作指令的数据环境;
    在所述内存库中执行所述写指令以修改所述读数据集。
  13. 根据权利要求8-12任一项所述的装置,其特征在于,所述控制执行模块具体用于:
    向所述数据库下发本地记录的所述数据库操作指令,以指示所述数据库执行所述数据库操作指令,并接收所述数据库返回的所述数据库操作指令的实际执行结果;
    若所述实际执行结果与所述预测执行结果相同,向所述数据库下发所述事务提交指令,以供所述数据库提交所述目标事务;
    若所述实际执行结果与所述预测执行结果不相同,向所述数据库下发事务回滚指令,以供所述数据库回滚所述目标事务。
  14. 一种数据库操作装置,其特征在于,包括:
    获取模块,用于在应用服务器执行目标事务的过程中,依次获取所述应用服务器执行到的所述目标事务中的数据库操作指令;
    预测执行模块,用于对所述数据库操作指令进行预测执行,将预测执行结果返回给所述应用服务器以供所述应用服务器确定下一个需要执行的数据库操作指令,并在本地记录所述数据库操作指令以及在所述数据库操作指令属于被加锁的非修改数据库类指令时记录所述预测执行产生的预测执行数据;
    控制执行模块,用于当获取到所述目标事务中的事务提交指令时,根据本地记录的所述数据库操作指令以及所述预测执行数据,控制所述应用服务器对应的数据库实际执行所述目标事务。
PCT/CN2016/109666 2015-12-21 2016-12-13 数据库操作方法及装置 WO2017107811A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP2018532425A JP6877435B2 (ja) 2015-12-21 2016-12-13 データベース動作方法及び装置
EP16877622.7A EP3396560B1 (en) 2015-12-21 2016-12-13 Database operating method and device
US16/013,851 US20180300147A1 (en) 2015-12-21 2018-06-20 Database Operating Method and Apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510960091.8 2015-12-21
CN201510960091.8A CN106897306B (zh) 2015-12-21 2015-12-21 数据库操作方法及装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/013,851 Continuation US20180300147A1 (en) 2015-12-21 2018-06-20 Database Operating Method and Apparatus

Publications (1)

Publication Number Publication Date
WO2017107811A1 true WO2017107811A1 (zh) 2017-06-29

Family

ID=59089098

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/109666 WO2017107811A1 (zh) 2015-12-21 2016-12-13 数据库操作方法及装置

Country Status (5)

Country Link
US (1) US20180300147A1 (zh)
EP (1) EP3396560B1 (zh)
JP (1) JP6877435B2 (zh)
CN (1) CN106897306B (zh)
WO (1) WO2017107811A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106503027B (zh) * 2015-09-08 2020-02-21 阿里巴巴集团控股有限公司 数据库操作方法及装置
CN109800062B (zh) * 2018-12-25 2020-02-07 星环信息科技(上海)有限公司 一种分布式数据库事务处理系统
CN112541006B (zh) * 2019-09-23 2023-01-06 拉扎斯网络科技(上海)有限公司 数据库命令请求处理方法、装置、电子设备及存储介质
CN111309740A (zh) * 2020-01-16 2020-06-19 中国建设银行股份有限公司 一种数据处理的方法、装置、设备及存储介质
CN113297320B (zh) * 2020-07-24 2024-05-14 阿里巴巴集团控股有限公司 分布式数据库系统及数据处理方法
CN112306995B (zh) * 2020-11-11 2023-06-27 北京奥星贝斯科技有限公司 一种数据库操作的实现方法及装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306092A (zh) * 2011-07-29 2012-01-04 北京北大众志微系统科技有限责任公司 超标量处理器实现指令缓存路选择的方法及装置
CN102662640A (zh) * 2012-04-12 2012-09-12 苏州睿云智芯微电子有限公司 双重分支目标缓冲器和分支目标处理系统及处理方法
CN104793988A (zh) * 2014-01-20 2015-07-22 阿里巴巴集团控股有限公司 跨数据库分布式事务的实现方法和装置
US20150339125A1 (en) * 2012-11-26 2015-11-26 Shanghai XinHao Micro Electronics Co. Ltd. Branch processing method and system

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6718349B2 (en) * 2000-12-14 2004-04-06 Borland Software Corporation Intelligent, optimistic concurrency database access scheme
US7529914B2 (en) * 2004-06-30 2009-05-05 Intel Corporation Method and apparatus for speculative execution of uncontended lock instructions
GB0504810D0 (en) * 2005-03-09 2005-04-13 Ibm Commitment chains for conflict resolution between disconnected data sharing applications
WO2007063945A1 (ja) * 2005-12-02 2007-06-07 International Business Machines Corporation データベースに対するアクセスを効率化するシステム、および、その方法
CN103186733B (zh) * 2011-12-30 2016-01-27 中国移动通信集团广东有限公司 数据库用户行为管理系统和数据库用户行为管理方法
CN105069703B (zh) * 2015-08-10 2018-08-28 国家电网公司 一种电网海量数据管理方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306092A (zh) * 2011-07-29 2012-01-04 北京北大众志微系统科技有限责任公司 超标量处理器实现指令缓存路选择的方法及装置
CN102662640A (zh) * 2012-04-12 2012-09-12 苏州睿云智芯微电子有限公司 双重分支目标缓冲器和分支目标处理系统及处理方法
US20150339125A1 (en) * 2012-11-26 2015-11-26 Shanghai XinHao Micro Electronics Co. Ltd. Branch processing method and system
CN104793988A (zh) * 2014-01-20 2015-07-22 阿里巴巴集团控股有限公司 跨数据库分布式事务的实现方法和装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3396560A4 *

Also Published As

Publication number Publication date
CN106897306A (zh) 2017-06-27
JP6877435B2 (ja) 2021-05-26
EP3396560A1 (en) 2018-10-31
US20180300147A1 (en) 2018-10-18
CN106897306B (zh) 2019-04-30
EP3396560B1 (en) 2024-01-31
EP3396560A4 (en) 2019-06-19
JP2018538634A (ja) 2018-12-27

Similar Documents

Publication Publication Date Title
WO2017107811A1 (zh) 数据库操作方法及装置
WO2017041639A1 (zh) 数据库操作方法及装置
EP3396542B1 (en) Database operating method and device
US20150269215A1 (en) Dependency-aware transaction batching for data replication
WO2020192063A1 (zh) 一种基于缓存化的销售锁定方法及系统
Pavlo et al. External vs. internal: an essay on machine learning agents for autonomous database management systems
EP4006740A1 (en) Method for indexing data in storage engines, and related device
TWI774643B (zh) 資料庫操作方法及裝置
WO2017041637A1 (zh) 数据库操作方法及装置
TWI725110B (zh) 資料庫操作方法及裝置
TWI805544B (zh) 資料庫操作方法及裝置
Osman et al. QuePED: Revisiting queueing networks for the performance evaluation of database designs
US10929395B2 (en) Data modification in hypothetical planning
TWI735512B (zh) 資料庫操作方法及裝置
CN112749156A (zh) 数据处理方法、数据库管理系统和数据处理设备
TWI790991B (zh) 資料庫操作方法及裝置
US20240086387A1 (en) Delta transition table for database triggers
US20240232159A9 (en) Flexible routing of database operations accessing remote tables
US20240134838A1 (en) Flexible routing of database operations accessing remote tables
CN116204508A (zh) 一种多版本并发控制方法、装置、设备及存储介质
CN118012849A (zh) 一种智能数据迁移方法及系统
KR20210036177A (ko) 데이터 가공을 통한 빅데이터 웨어하우스 데이터 마트 테이블 생성 방법
CN114610626A (zh) 面向关系型数据库的事务隔离性自动化测试方法及装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16877622

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2018532425

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

WWE Wipo information: entry into national phase

Ref document number: 2016877622

Country of ref document: EP