WO2019037617A1 - 数据事务处理方法、装置以及电子设备 - Google Patents

数据事务处理方法、装置以及电子设备 Download PDF

Info

Publication number
WO2019037617A1
WO2019037617A1 PCT/CN2018/100419 CN2018100419W WO2019037617A1 WO 2019037617 A1 WO2019037617 A1 WO 2019037617A1 CN 2018100419 W CN2018100419 W CN 2018100419W WO 2019037617 A1 WO2019037617 A1 WO 2019037617A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
data
database
client
partition
Prior art date
Application number
PCT/CN2018/100419
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 EP18847869.7A priority Critical patent/EP3674909A4/en
Publication of WO2019037617A1 publication Critical patent/WO2019037617A1/zh
Priority to US16/789,313 priority patent/US11709803B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • 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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/1865Transactional file systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/162Delete operations
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/16File or folder operations, e.g. details of user interfaces specifically adapted to file systems
    • G06F16/168Details of user interfaces specifically adapted to file systems, e.g. browsing and visualisation, 2d or 3d GUIs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/1734Details of monitoring file system events, e.g. by the use of hooks, filter drivers, logs
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • 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/22Indexing; Data structures therefor; Storage structures
    • G06F16/2282Tablespace storage structures; Management thereof
    • 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/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details
    • 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
    • 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
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • 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/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • 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/54Interprogram communication
    • G06F9/543User-generated data transfer, e.g. clipboards, dynamic data exchange [DDE], object linking and embedding [OLE]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/107License processing; Key processing

Definitions

  • the present application relates to the field of computer technologies, and in particular, to a data transaction processing method.
  • the application relates to a data transaction processing device, another data transaction processing method and device, and two types of electronic devices.
  • Database transactions are the basic unit of work for a database, moving the database from a consistent state to another consistent state. Database transactions allow simultaneous writing of different data items in the database, either successfully or not all Even if the system fails, the database transactions that have not been completed can still be restored correctly, and the database transactions can be isolated to different degrees to ensure the correctness of the data.
  • the business will also create a different index of the original data, each time write a raw data and multiple index data, these write
  • the input operation needs to be completed in one transaction, but in the scenario where the database does not support multi-line transactions, the service is required to implement various characteristics of the transaction.
  • the schematic diagram of the business layer write logic shown in FIG. 1 according to the readout The data updates the original data, and each data is written successfully before writing a data until all the data is successfully written.
  • the present application provides a data transaction processing method to solve the problems existing in the prior art.
  • the application relates to a data transaction processing device, another data transaction processing method and device, and two types of electronic devices.
  • the application provides a data transaction processing method, including:
  • the target data partition includes: a partition key in a data table included in the database;
  • the data transaction includes: a database transaction.
  • the primary key of the data table is composed of at least one primary key column in the data table
  • the partitioning key includes: a single partitioning key composed of a first primary key column of the data table.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • the processing the data transaction according to the transaction instruction sent by the client is implemented as follows:
  • the database transaction is read from the transaction queue, the transaction log corresponding to the database transaction is created, and the data operation of the database transaction is recorded in the transaction log.
  • the following sub-step is executed. step:
  • the transaction log is stored in a preset data storage space.
  • the processing the data transaction according to the transaction instruction sent by the client is implemented as follows:
  • the performing according to the data operation carrying the transaction identifier submitted by the client, performing the data operation step based on the target data partition, and the processing according to the transaction instruction sent by the client Before the data transaction step is performed, the following steps are performed:
  • the state of the partitioning key includes at least one of the following: a locked state and an unlocked state;
  • the state of the partition key is updated to a locked state.
  • the receiving client sends a corresponding data transaction according to the application request, and performs a transaction identifier step for the data transaction.
  • the database comprises: a logically unified distributed database comprising a plurality of physically dispersed plurality of data storage units connected through a network.
  • the data transaction processing method is implemented based on a distributed database platform deployed in a cloud computing environment, where the distributed database platform provides a data access interface for accessing the distributed database, and is received by the data access interface.
  • the application request sent by the client for data operation of the partition key of the distributed database, and/or receiving, by the data access interface, the processing sent by the client for processing the database transaction Transaction instructions.
  • the application also provides a data transaction processing apparatus, including:
  • the application receiving unit is configured to receive an application request sent by the client for performing data operations in the target data partition
  • a data transaction creation unit configured to create a corresponding data transaction according to the application request, and allocate a transaction identifier for the data transaction;
  • a transaction identifier returning unit configured to return a transaction identifier assigned to the data transaction to the client
  • a data operation submission execution unit configured to perform the data operation based on the target data partition according to the data operation submitted by the client and carrying the transaction identifier
  • a data transaction processing unit configured to process the data transaction according to a transaction instruction sent by the client.
  • the application further provides a data transaction processing method, including:
  • Transaction instructions for processing the data transaction are sent to the server based on the transaction identifier.
  • the target data partition includes: a partition key in a data table included in the database;
  • the data transaction includes: a database transaction.
  • the primary key of the data table is composed of at least one primary key column in the data table
  • the partitioning key includes: a single partitioning key composed of a first primary key column of the data table.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • the data transaction processing method includes:
  • the present application further provides a data transaction processing apparatus, including:
  • An application sending unit configured to send, to the server, an application request for performing data operations in the target data partition
  • a transaction identifier receiving unit configured to receive a transaction identifier of a data transaction corresponding to the application request returned by the server
  • a data operation submitting unit configured to submit, to the server, a data operation carrying the transaction identifier, where the data operation is performed for the target data partition;
  • a transaction instruction sending unit configured to send, to the server, a transaction instruction for processing the data transaction based on the transaction identifier.
  • the application also provides an electronic device, including:
  • Memory Memory, and processor
  • the memory is for storing computer executable instructions for executing the computer executable instructions:
  • the application further provides an electronic device, including:
  • Memory Memory, and processor
  • the memory is for storing computer executable instructions for executing the computer executable instructions:
  • Transaction instructions for processing the data transaction are sent to the server based on the transaction identifier.
  • the data transaction processing method provided by the present application receives an application request sent by a client for performing a data operation in a target data partition; creates a corresponding data transaction according to the application request, and allocates a transaction identifier for the data transaction; Returning the transaction identifier of the data transaction to the client; performing the data operation based on the target data partition according to the data operation submitted by the client carrying the transaction identifier; according to the client sending The transaction instruction processes the data transaction.
  • the data transaction processing method when the client processes a data transaction for performing data operations on the target data partition, assigning a transaction identifier to the created data transaction, and returning the transaction identifier to the client, Said client performs a data operation on said target data partition by submitting a data operation carrying said transaction identifier, and finally processing said data transaction according to a transaction instruction sent by said client, thereby enabling said data operation to implement a transaction
  • the attribute satisfies the transactionality of the data operation; at the same time, the data transaction processing method realizes the business logic of the data transaction is relatively simple, and ensures that the data service has good transactionality.
  • FIG. 1 is a schematic diagram of a service layer write logic provided by the prior art
  • FIG. 2 is a schematic diagram of a database transaction processing scenario provided by the present application.
  • FIG. 3 is a schematic diagram of an embodiment of a data transaction processing apparatus provided by the present application.
  • FIG. 4 is a process flow diagram of another embodiment of a data transaction processing method provided by the present application.
  • FIG. 5 is a schematic diagram of another embodiment of a data transaction processing apparatus provided by the present application.
  • FIG. 6 is a schematic diagram of an embodiment of an electronic device provided by the present application.
  • FIG. 7 is a schematic diagram of another embodiment of an electronic device provided by the present application.
  • the present application provides a data transaction processing method, and the present application further provides a data transaction processing apparatus, another data transaction processing method and apparatus, and two types of electronic devices.
  • a data transaction processing apparatus for a data transaction processing method
  • another data transaction processing method and apparatus for a data transaction processing method
  • two types of electronic devices for a data transaction processing method
  • the following is a detailed description of the embodiments of the embodiments provided herein, and the various steps of the method are explained.
  • a data transaction processing method provided by the present application is as follows:
  • FIG. 2 there is shown a schematic diagram of a database transaction scenario provided by the present application.
  • Step 1 Receive an application request sent by the client for data operation in the target data partition.
  • This step is the basis for subsequent data operations on the target data partition. It is possible to obtain the permission to operate the data operation of the target data partition by requesting the data operation of the target data partition sent by the client.
  • the embodiment of the present application is described by taking a database transaction as an example, such as a database transaction of a distributed database (such as a NoSQL database) built on a distributed system.
  • the distributed system refers to a logically unified database composed of a plurality of physically dispersed data storage units connected through a network, and based on the distributed database, based on data fragmentation and load balancing, the distributed system can enable the distributed
  • the database scales seamlessly on a scale.
  • the target data partition refers to a data set that the client desires to operate.
  • the target data partition refers to a partition key among partitions
  • the partition refers to a basic scheduling unit of load balancing in data storage. , horizontal expansion of data storage through partitioning to ensure performance and availability.
  • the primary key of the data table included in the database is composed of at least one primary key column in the data table
  • the partition key refers to a single partition key composed of the first primary key column of the data table, in one partition, There may be multiple partitioning keys, and there will be no overlap between these partitioning keys.
  • the target data partition may also be a primary key column or a plurality of primary key columns other than the partition key in the data table, for example, the target data partition may also be a single partition key composed of any other primary key column other than the first primary key column of the data table, or the target data partition may also be a joint partitioning key composed of multiple primary key columns of the data table, or The target data partition may also be a joint partitioning key composed of a plurality of partition keys, which is not limited in this embodiment.
  • the client embeds a partition key of the target data partition in the application request, and when receiving an application request from the client, obtains a partition key in the application request, thereby determining a data set that the client desires to operate.
  • the data operation refers to a specific operation on the data under the partition key, such as adding a row of data, deleting a row of data, modifying one or some values in a row or certain rows of data, reading a certain or some Some data, etc.
  • an application request for performing a data operation under the partition key sent by the client that is, a database transaction applying for a partition key is received.
  • a database transaction of the application partition key PK0 sent by the client corresponding to the service 1 is 0.
  • Step 2 Create a corresponding data transaction according to the application request, and allocate a transaction identifier for the data transaction.
  • Step 1 above receiving the request for data operation performed by the client under the partition key, that is, requesting a database transaction of the partition key, this step creates a corresponding database transaction according to the application request, and allocates a transaction for the database transaction.
  • logo
  • the transaction identifier is an identifier assigned to the database transaction, one database transaction has one and only one transaction identifier, and the transaction identifier of each database transaction is different. More specifically, the transaction identifier may be in the form of a string or a number.
  • the database transaction 3 is created, and the corresponding transaction ID is assigned to the currently newly created database transaction 3 ( Transaction ID).
  • the transaction identifier is allocated for the database transaction, which provides a basis for the subsequent client to modify the database transaction. Since the server simultaneously allocates different database transactions to the clients corresponding to the plurality of services, The transaction identifier determines the specific database transaction that the client wants to modify. At the same time, since the server simultaneously allocates different database transactions to the clients corresponding to the plurality of services, the partition key corresponding to the database transaction is locked, that is, not allowed, while the transaction identifier is allocated for the database transaction. Other database transactions other than the database transaction perform data operations on the data under the partition key. For example, as shown in FIG. 2, after the database transaction 3 of the application partition key PK0 sent by the client corresponding to the service 1 is locked, the client corresponding to the service 2 applies for the database transaction with the partition key PK0 being 0, failure.
  • a corresponding state may be set for the partition key, including a locked state and an unlocked state.
  • the step before the step is to create a corresponding database transaction according to the application request, and before assigning the transaction identifier to the database transaction, it is necessary to determine whether the partition key applied by the client is locked, specifically by determining Whether the state of the partition key is an unlocked state to determine whether the partition key is locked, and if the partition key has been locked, performing data for the client sent in the step 1 above under the partition key
  • the application request of the operation, the response to the application failure is made, and the database transaction is no longer created and the transaction identifier is allocated; if the partition key is not locked, the step is executed, and the corresponding database transaction is created according to the application request, and
  • the database transaction allocates a transaction identifier.
  • Step 3 Return the transaction identifier assigned to the data transaction to the client.
  • the foregoing step 2 creates a corresponding database transaction according to the request, and allocates a transaction identifier for the database transaction.
  • the transaction identifier assigned to the database transaction in the above step 2 is returned to the client.
  • the transaction ID assigned to the database transaction 3 is returned to the client corresponding to the service 1, and the client corresponding to the service 1 receives the transaction ID of the database transaction 3, indicating that the application is successful.
  • the timeout detection mechanism may also be started.
  • the timeout detection mechanism specifically determines whether the client sends the response within a certain time threshold.
  • the action instruction that is, whether the action instruction for processing the data transaction sent by the client in step 4 is received within the time threshold range, if not, the timeout is triggered, the database transaction is destroyed, and the The transaction identifier, that is, the database transaction identifier is invalid, and the corresponding transaction identifier is also invalid.
  • the time threshold range can be flexibly set according to an actual application scenario.
  • Step 4 Perform the data operation based on the target data partition according to the data operation submitted by the client and carrying the transaction identifier.
  • the step performs the data operation based on the target data partition according to the data operation submitted by the client and carrying the transaction identifier.
  • multiple rows of data in the same target data partition can be simultaneously modified.
  • the service 1 can carry the transaction ID corresponding to the newly created database transaction 3 to modify the multi-line data with the partition key PK0 being 0. These modifications are placed in the memory and do not take effect immediately. Not visible to other database transactions, and if the machine on which the server is located is down, these modifications are lost.
  • Step 5 processing the data transaction according to a transaction instruction sent by the client.
  • the step of receiving the transaction instruction sent by the client for processing the database transaction is performed. Based on this, after receiving the transaction instruction for processing the database transaction, determining whether a database transaction corresponding to the transaction instruction exists, if yes, performing this step, according to the transaction sent by the client The instruction processes the data transaction; if not, returns, to the client, remind information that the database transaction corresponding to the transaction instruction does not exist.
  • the transaction instruction described in the embodiment of the present application includes a transaction commit instruction and a transaction cancel instruction, and the following describes the two transaction instructions separately:
  • the step of processing the data transaction according to the transaction instruction sent by the client is specifically implemented as follows:
  • the transaction log is stored in a preset data storage space.
  • the server may interact with several clients at the same time. Different clients may submit different database transactions in a short period of time. These database transactions cannot be executed at the same time. Therefore, the transaction queue is set.
  • the database transaction is submitted to the transaction queue, and the database transaction is executed in order.
  • the transaction queue may be a linear table composed of database transactions, the transaction queues are arranged according to a sequence of database transaction submissions, and the database transactions are sequentially read in an arrangement order.
  • the database transaction 3 is submitted to the transaction queue; thereafter, the database transaction in the transaction queue is processed.
  • the database transaction 3 is read from the transaction queue, the data operation of the database transaction 3 is recorded in the corresponding transaction log, and finally the transaction log is stored in the memory.
  • the database transaction is destroyed, and the transaction identifier corresponding to the database transaction is recovered, and the partition key corresponding to the database office is unlocked, that is, other databases are allowed.
  • the transaction performs data operations on the data under the partition key to ensure the isolation of the database transaction. Isolation is the security guarantee provided by database transactions for conflicts between concurrent transactions. Database transactions can provide different levels of separation between concurrently executed transactions by locking, thus avoiding the execution of multiple concurrent transactions that manipulate the same shared object. abnormal situation.
  • the transaction instruction sent by the client is the transaction cancellation instruction
  • the step of processing the data transaction according to the transaction instruction sent by the client is specifically implemented as follows:
  • the transaction instruction sent by the client for processing the database transaction further includes a transaction rollback instruction, and the database transaction is rolled back and discarded before the database transaction is submitted. Previous modifications to the database transaction and termination of processing of the database transaction.
  • the data transaction processing method provided by the present application may also be implemented based on a distributed database platform deployed in a cloud computing environment, where the distributed database platform is configured to access the distributed database (such as a NoSQL database).
  • a data access interface when the client corresponding to the service wants to use the NoSQL database for business data processing, by calling the data access interface, submitting a partition key application database transaction based on the NoSQL database to the server, the server The NoSQL database-based partition key application database transaction submitted by the client corresponding to the service is obtained by the data access interface, and the corresponding transaction is performed; and the client corresponding to the service also submits the target to the server through the data access interface.
  • a transaction instruction that is processed by the database transaction, the server obtains the transaction instruction through the data access interface, and processes the database transaction according to the transaction instruction.
  • the data transaction processing method provided by the present application allocates a transaction identifier for a created database transaction when the client performs a database transaction for performing data operations under the partition key, and Transaction identification is returned to the client, and the client performs a data operation under the partition key by submitting a data operation carrying the transaction identifier, and finally the database transaction according to the transaction instruction sent by the client Processing is performed to enable the data operation to implement a transaction attribute, which satisfies the transactionality of the data operation; at the same time, the data transaction processing method implements the business logic of the data transaction is relatively simple, and ensures that the data service has good transactionality.
  • a data transaction processing apparatus provided by the present application is implemented as follows:
  • a data transaction processing method is provided.
  • the present application further provides a data transaction processing apparatus, which will be described below with reference to the accompanying drawings.
  • FIG. 3 there is shown a schematic diagram of an embodiment of a data transaction device provided by the present application.
  • the application provides a data transaction processing apparatus, including:
  • the application receiving unit 301 is configured to receive an application request sent by the client for performing data operations on the target data partition;
  • a data transaction creation unit 302 configured to create a corresponding data transaction according to the application request, and allocate a transaction identifier for the data transaction;
  • a transaction identifier returning unit 303 configured to return a transaction identifier assigned to the data transaction to the client;
  • the data operation submitting execution unit 304 is configured to perform the data operation based on the target data partition according to the data operation submitted by the client and carrying the transaction identifier;
  • the data transaction processing unit 305 is configured to process the data transaction according to a transaction instruction sent by the client.
  • the target data partition includes: a partition key in a data table included in the database;
  • the data transaction includes: a database transaction.
  • the primary key of the data table is composed of at least one primary key column in the data table
  • the partitioning key includes: a single partitioning key composed of a first primary key column of the data table.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • the data transaction processing unit 305 includes:
  • a transaction log record subunit configured to read a database transaction from the transaction queue, create a transaction log corresponding to the database transaction, and record a data operation of the database transaction in a transaction log.
  • the data transaction processing unit 305 includes:
  • a transaction log storage subunit for storing the transaction log in a preset data storage space.
  • the data transaction processing unit 305 includes:
  • the first transaction recycling subunit is configured to delete the database transaction and reclaim the transaction identifier corresponding to the database transaction.
  • the data transaction processing unit 305 includes:
  • the second transaction recycling subunit is configured to delete the database transaction and reclaim the transaction identifier of the database transaction.
  • the data transaction processing device includes:
  • the transaction instruction receiving unit is configured to receive a transaction instruction sent by the client for processing the database transaction.
  • the data transaction processing device includes:
  • a database transaction determining unit configured to determine whether a database transaction corresponding to the transaction instruction exists, and if not, running a reminder information sending unit;
  • the reminding information sending unit is configured to return, to the client, remind information that the database transaction corresponding to the transaction instruction does not exist.
  • the state of the partitioning key includes at least one of the following: a locked state and an unlocked state;
  • the state of the partition key is updated to a locked state.
  • the data transaction processing device includes:
  • the partition key state determining unit is configured to determine whether the state of the partition key is an unlocked state, and if not, run the data transaction creating unit 302.
  • the database comprises: a logically unified distributed database comprising a plurality of physically dispersed plurality of data storage units connected through a network.
  • the data transaction processing device is operated based on a distributed database platform deployed in a cloud computing environment, where the distributed database platform provides a data access interface for accessing the distributed database, and receiving through the data access interface
  • Another data transaction processing method provided by the present application is as follows:
  • a data transaction processing method is provided.
  • the present application provides another data transaction processing method, which cooperates with the above data transaction processing method, and is described below with reference to the accompanying drawings.
  • FIG 4 there is shown a process flow diagram of another embodiment of a data transaction method provided by the present application.
  • FIG 2 there is shown a schematic diagram of a database transaction scenario provided by the present application.
  • This application provides another data transaction processing method, including:
  • Step S401 sending an application request for performing a data operation on the target data partition to the server.
  • the above data transaction processing method provided by the present application is based on the server implementation, and another data transaction processing method provided by the present application is implemented based on a client. Similar to the C/S structure, the above data transaction processing method provided by the present application may also be implemented based on a data sender or a data producer. Correspondingly, another data transaction processing method provided by the present application may also be based on data processing. Party or data consumer implementation.
  • the target data partition refers to a data set that the client desires to operate.
  • the target data partition refers to a partition key among partitions
  • the partition refers to a basic scheduling unit of load balancing in data storage. , horizontal expansion of data storage through partitioning to ensure performance and availability.
  • the primary key of the data table included in the database is composed of at least one primary key column in the data table
  • the partition key refers to a single partition key composed of the first primary key column of the data table, in one partition, There may be multiple partitioning keys, and there will be no overlap between these partitioning keys.
  • the target data partition may also be a primary key column or a plurality of primary key columns other than the partition key in the data table, for example, the target data partition may also be a single partition key composed of any other primary key column other than the first primary key column of the data table, or the target data partition may also be a joint partitioning key composed of multiple primary key columns of the data table, or The target data partition may also be a joint partitioning key composed of a plurality of partition keys, which is not limited in this embodiment.
  • the data operation refers to a specific operation on the data under the partition key, such as adding a row of data, deleting a row of data, modifying one or some values in a row or certain rows of data, reading a certain or some Some data, etc.
  • the client sends an application request for performing data operation under the partition key to the server, that is, a database transaction for performing data operation under the partition key.
  • Step S402 receiving a transaction identifier of a data transaction corresponding to the application request returned by the server.
  • the foregoing step S401 sends, to the server, an application request for performing a data operation under the partition key, that is, a database transaction for performing data operation under the partition key, after the server receives the application request, Forming a corresponding database transaction according to the request, and assigning a transaction identifier to the database transaction, and returning the transaction identifier to the client, and based on this, the step is to receive a database corresponding to the application request returned by the server.
  • the transaction ID of the transaction is to receive a database corresponding to the application request returned by the server.
  • Step S403 submit, to the server, a data operation carrying the transaction identifier, where the data operation is performed for the target data partition.
  • the step S402 receives the transaction identifier of the database transaction corresponding to the application request returned by the server, and after receiving the transaction identifier, the client indicates that the database transaction application is successful. On this basis, in this step, And submitting, to the server, a data operation carrying the transaction identifier, where the data operation is performed under the partition key.
  • Step S404 sending a transaction instruction for processing the data transaction to the server based on the transaction identifier.
  • the data operation carrying the transaction identifier is submitted to the server in the foregoing step S403, after performing the data operation execution under the partition key, in this step, based on the transaction identifier
  • the server sends a transaction instruction that processes the database transaction.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • the server determines whether a database transaction corresponding to the transaction instruction exists, and if not, returns the transaction instruction to the client. Reminder information for the corresponding database transaction does not exist. Therefore, after the transaction instruction for processing the database transaction is sent to the server, the method further includes receiving, by the server, remind information that the database transaction corresponding to the transaction instruction does not exist.
  • another data transaction processing method provided by the present application may also be implemented based on a distributed database platform deployed in a cloud computing environment, where the distributed database platform is configured to access the distributed database (such as NoSQL).
  • a data access interface of the database when the client corresponding to the service wants to use the NoSQL database for business data processing, by calling the data access interface, submitting a partition key application database transaction based on the NoSQL database to the server, the service The client obtains the partition key application database transaction based on the NoSQL database submitted by the client corresponding to the service through the data access interface, and performs corresponding processing; and the client corresponding to the service also submits the target to the server through the data access interface.
  • the transaction instruction processed by the database transaction the server obtains the transaction instruction through the data access interface, and processes the database transaction according to the transaction instruction.
  • Another data transaction processing device provided by the present application is implemented as follows:
  • FIG. 5 there is shown a schematic diagram of another embodiment of a data transaction device provided by the present application.
  • the present application provides another data transaction processing apparatus, including:
  • the application sending unit 501 is configured to send, to the server, an application request for performing data operations in the target data partition;
  • the transaction identifier receiving unit 502 is configured to receive a transaction identifier of a data transaction corresponding to the application request returned by the server;
  • a data operation submitting unit 503, configured to submit, to the server, a data operation carrying the transaction identifier, where the data operation is performed for the target data partition;
  • the transaction instruction sending unit 504 is configured to send, to the server, a transaction instruction for processing the data transaction based on the transaction identifier.
  • the target data partition includes: a partition key in a data table included in the database;
  • the data transaction includes: a database transaction.
  • the primary key of the data table is composed of at least one primary key column in the data table
  • the partitioning key includes: a single partitioning key composed of a first primary key column of the data table.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • the data transaction processing device includes:
  • the reminder information receiving unit is configured to receive reminder information that the database transaction corresponding to the transaction instruction returned by the server end does not exist.
  • An electronic device implementation provided by the present application is as follows:
  • a data transaction processing method is provided.
  • the present application further provides an electronic device for implementing the data transaction processing method, which will be described below with reference to the accompanying drawings.
  • FIG. 6 a schematic diagram of an electronic device provided by the embodiment is shown.
  • the application provides an electronic device, including:
  • the memory 601 is configured to store computer executable instructions, and the processor 602 is configured to execute the computer executable instructions:
  • the target data partition includes: a partition key in a data table included in the database;
  • the data transaction includes: a database transaction.
  • the primary key of the data table is composed of at least one primary key column in the data table
  • the partitioning key includes: a single partitioning key composed of a first primary key column of the data table.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • the processing the data transaction according to the transaction instruction sent by the client is implemented as follows:
  • the processor 602 is read from the transaction queue, the transaction log corresponding to the database transaction is created, and the data operation of the database transaction is recorded in the transaction log, and the processor 602 is executed. Also used to execute the following computer executable instructions:
  • the transaction log is stored in a preset data storage space.
  • the processor 602 is further configured to execute the following computer executable instructions:
  • the processing the data transaction according to the transaction instruction sent by the client is implemented as follows:
  • the processor 602 is further configured to execute the following computer executable instructions before the data transaction instruction is executed:
  • the processor 602 is further configured to execute the following computer executable instruction:
  • the state of the partitioning key includes at least one of the following: a locked state and an unlocked state;
  • the state of the partition key is updated to a locked state.
  • the processor 602 is further configured to execute the following computer executable instructions:
  • the database comprises: a logically unified distributed database comprising a plurality of physically dispersed plurality of data storage units connected through a network.
  • the processor 602 executes the computer executable instructions based on a distributed database platform deployed in a cloud computing environment, where the distributed database platform provides a data access interface for accessing the distributed database, Receiving, by the data access interface, the application request sent by the client for performing a data operation on a partition key of the distributed database, and/or receiving, by the data access interface, the database sent by the client The transaction instruction that the transaction is processing.
  • Another electronic device implementation provided by the present application is as follows:
  • the present application further provides an electronic device for implementing another data transaction processing method provided by the present application, which is described below with reference to the accompanying drawings. .
  • FIG. 7 there is shown a schematic diagram of another electronic device provided by this embodiment.
  • the electronic device embodiment provided by the present application is described in a relatively simple manner.
  • the embodiments described below are merely illustrative.
  • the application provides another electronic device, including:
  • the memory 701 is configured to store computer executable instructions, and the processor 702 is configured to execute the computer executable instructions:
  • Transaction instructions for processing the data transaction are sent to the server based on the transaction identifier.
  • the target data partition includes: a partition key in a data table included in the database;
  • the data transaction includes: a database transaction.
  • the primary key of the data table is composed of at least one primary key column in the data table
  • the partitioning key includes: a single partitioning key composed of a first primary key column of the data table.
  • the transaction instruction includes: a transaction commit instruction and a transaction cancellation instruction.
  • processor 702 is further configured to execute the following computer executable instructions:
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
  • RAM random access memory
  • ROM read only memory
  • Memory is an example of a computer readable medium.
  • Computer readable media includes both permanent and non-persistent, removable and non-removable media.
  • Information storage can be implemented by any method or technology.
  • the information can be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device.
  • computer readable media does not include non-transitory computer readable media, such as modulated data signals and carrier waves.
  • embodiments of the present application can be provided as a method, system, or computer program product.
  • the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment in combination of software and hardware.
  • the application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Business, Economics & Management (AREA)
  • Human Computer Interaction (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Computer Hardware Design (AREA)
  • Computer Security & Cryptography (AREA)
  • General Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请公开一种数据事务处理方法、装置以及电子设备,所述方法包括:接收客户端发送的在目标数据分区进行数据操作的申请请求;根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;将分配给所述数据事务的事务标识返回给所述客户端;根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;根据所述客户端发送的事务指令处理所述数据事务。所述数据事务处理方法使所述数据操作实现事务属性,满足了数据操作的事务性;同时,所述数据事务处理方法实现数据事务的业务逻辑较为简单,确保数据业务具有良好的事务性。

Description

数据事务处理方法、装置以及电子设备
本申请要求2017年08月25日递交的申请号为201710738319.8、发明名称为“数据事务处理方法、装置以及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及计算机技术领域,具体涉及一种数据事务处理方法。本申请同时涉及一种数据事务处理装置,另一种数据事务处理方法以及装置,以及两种电子设备。
背景技术
数据库事务是数据库的基本工作单元,让数据库从一个一致的状态转移到另一个一致的状态,数据库事务允许对数据库中不同的数据项同时进行写操作,这些操作要么全部成功执行,要么全部不执行,即使系统发生故障,未执行完成的数据库事务依然可以正确恢复,而数据库事务之间可以在不同程度上进行隔离,以保证数据的正确性。
目前,在分布式数据库中,数据分布在不同的机器上,一个数据库事务往往需要访问多台机器,为了保证事务的原子性,需要确保参与数据库事务的机器相互协作,这个过程非常复杂并且对系统的性能有很大的影响,所以大多数分布式数据库并不支持事务。以一个典型的业务场景邮箱业务为例,每封邮件有以下属性:发件人、时间、状态(已读/未读)等,当邮箱账号收到新邮件时,需要进行存储新邮件的内容、修改收件箱列表、未读邮件数等操作,为了满足不同查询条件排序的需求,业务还会对原始数据建立不同的索引,每次写入一份原始数据和多份索引数据,这些写入操作需要在一个事务中完成,但在数据库不支持多行事务的场景下,需要业务来实现事务的各项特性,参照附图1所示的业务层写入逻辑的示意图,根据读出来的数据对原有数据进行更新,并且每笔数据写入成功后再写下一笔数据,直到所有数据都成功写入。但这种方式需要考虑每次写入失败的回退处理,并且在回退删除已经写入的数据时需要进行无限重试,业务逻辑较为复杂;此外,如果业务程序发生宕机,写入数据无法进行回退,因此无法满足事务性需求。
发明内容
本申请提供一种数据事务处理方法,以解决现有技术存在的问题。
本申请同时涉及一种数据事务处理装置,另一种数据事务处理方法以及装置,以及两种电子设备。
本申请提供一种数据事务处理方法,包括:
接收客户端发送的在目标数据分区进行数据操作的申请请求;
根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
将分配给所述数据事务的事务标识返回给所述客户端;
根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
根据所述客户端发送的事务指令处理所述数据事务。
可选的,所述目标数据分区包括:数据库包含的数据表当中的分区键;
相应的,所述数据事务包括:数据库事务。
可选的,所述数据表的主键由数据表中的至少一个主键列组成;
所述分区键包括:所述数据表的第一个主键列组成的单分区键。
可选的,所述事务指令包括:事务提交指令和事务取消指令。
可选的,若所述客户端发送的事务指令为所述事务提交指令,所述根据所述客户端发送的事务指令处理所述数据事务,采用如下方式实现:
将所述数据库事务提交到事务队列;
从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中。
可选的,所述从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中子步骤执行后,执行下述子步骤:
将所述事务日志存储至预设数据存储空间中。
可选的,所述将所述事务日志存储至预设数据存储空间中子步骤执行后,执行下述子步骤:
删除所述数据库事务,并回收所述数据库事务对应的事务标识。
可选的,若所述客户端发送的事务指令为所述事务取消指令,所述根据所述客户端发送的事务指令处理所述数据事务,采用如下方式实现:
删除所述数据库事务,并回收所述数据库事务的事务标识。
可选的,所述根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标 数据分区执行所述数据操作步骤执行后,且所述根据所述客户端发送的事务指令处理所述数据事务步骤执行前,执行下述步骤:
接收所述客户端发送的针对所述数据库事务进行处理的事务指令。
可选的,所述接收所述客户端发送的针对所述数据库事务进行处理的动作指令步骤执行后,执行下述步骤:
判断所述事务指令对应的数据库事务是否存在,若不存在,向所述客户端返回所述事务指令对应的数据库事务不存在的提醒信息。
可选的,所述分区键的状态包括下述至少一项:锁定状态和未锁定状态;
若接收到的申请请求为在所述分区键下进行数据操作的申请请求,所述分区键的状态被更新为锁定状态。
可选的,所述接收客户端发送的在目标数据分区进行数据操作的申请请求步骤执行后,且所述根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识步骤执行前,执行下述步骤:
判断所述分区键的状态是否为未锁定状态,若否,执行所述根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识步骤。
可选的,所述数据库包括:通过网络将物理上分散的多个数据存储单元连接组成的逻辑统一的分布式数据库。
可选的,所述数据事务处理方法基于云计算环境中部署的分布式数据库平台实现,所述分布式数据库平台提供用于访问所述分布式数据库的数据访问接口,通过所述数据访问接口接收所述客户端发送的针对所述分布式数据库的分区键进行数据操作的所述申请请求,和/或,通过所述数据访问接口接收所述客户端发送的针对所述数据库事务进行处理的所述事务指令。
本申请还提供一种数据事务处理装置,包括:
申请接收单元,用于接收客户端发送的在目标数据分区进行数据操作的申请请求;
数据事务创建单元,用于根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
事务标识返回单元,用于将分配给所述数据事务的事务标识返回给所述客户端;
数据操作提交执行单元,用于根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
数据事务处理单元,用于根据所述客户端发送的事务指令处理所述数据事务。
本申请另外提供一种数据事务处理方法,包括:
向服务端发送在目标数据分区进行数据操作的申请请求;
接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
可选的,所述目标数据分区包括:数据库包含的数据表当中的分区键;
相应的,所述数据事务包括:数据库事务。
可选的,所述数据表的主键由数据表中的至少一个主键列组成;
所述分区键包括:所述数据表的第一个主键列组成的单分区键。
可选的,所述事务指令包括:事务提交指令和事务取消指令。
可选的,所述数据事务处理方法,包括:
接收所述服务端返回的所述事务指令对应的数据库事务不存在的提醒信息。
本申请另外提供一种数据事务处理装置,包括:
申请发送单元,用于向服务端发送在目标数据分区进行数据操作的申请请求;
事务标识接收单元,用于接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
数据操作提交单元,用于向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
事务指令发送单元,用于基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
本申请还提供一种电子设备,包括:
存储器,以及处理器;
所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:
接收客户端发送的在目标数据分区进行数据操作的申请请求;
根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
将分配给所述数据事务的事务标识返回给所述客户端;
根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
根据所述客户端发送的事务指令处理所述数据事务。
本申请另外提供一种电子设备,包括:
存储器,以及处理器;
所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:
向服务端发送在目标数据分区进行数据操作的申请请求;
接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
本申请提供的所述数据事务处理方法,接收客户端发送的在目标数据分区进行数据操作的申请请求;根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;将分配给所述数据事务的事务标识返回给所述客户端;根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;根据所述客户端发送的事务指令处理所述数据事务。
所述数据事务处理方法,对所述客户端针对目标数据分区进行数据操作的数据事务进行处理时,为创建的数据事务分配事务标识,并将所述事务标识返回给所述客户端,由所述客户端通过提交携带所述事务标识的数据操作针对所述目标数据分区执行数据操作,并最终根据所述客户端发送的事务指令对所述数据事务进行处理,从而使所述数据操作实现事务属性,满足了数据操作的事务性;同时,所述数据事务处理方法实现数据事务的业务逻辑较为简单,确保数据业务具有良好的事务性。
附图说明
图1是现有技术提供的一种业务层写入逻辑的示意图;
图2是本申请提供的一种数据库事务处理场景的示意图;
图3是本申请提供的一种数据事务处理装置实施例的示意图;
图4是本申请提供的另一种数据事务处理方法实施例的处理流程图;
图5是本申请提供的另一种数据事务处理装置实施例的示意图;
图6是本申请提供的一种电子设备实施例的示意图;
图7是本申请提供的另一种电子设备实施例的示意图。
具体实施方式
在下面的描述中阐述了很多具体细节以便于充分理解本申请。但是本申请能够以很多不同于在此描述的其他方式来实施,本领域技术人员可以在不违背本申请内涵的情况下做类似推广,因此本申请不受下面公开的具体实施的限制。
本申请提供一种数据事务处理方法,本申请还提供一种数据事务处理装置,另一种数据事务处理方法以及装置,以及两种电子设备。以下分别结合本申请提供的实施例的附图逐一进行详细说明,并且对方法的各个步骤进行说明。
本申请提供的一种数据事务处理方法实施例如下:
参照附图2,其示出了本申请提供的一种数据库事务处理场景的示意图。
步骤1,接收客户端发送的在目标数据分区进行数据操作的申请请求。
本步骤是后续对目标数据分区进行数据操作的基础,通过所述客户端发送的在目标数据分区进行数据操作的申请请求,才可能获得操作所述目标数据分区的数据操作的权限。本申请实施例以数据库事务为例进行说明,比如构建在分布式系统之上的分布式数据库(如NoSQL数据库)的数据库事务。所述分布式系统是指通过网络将物理上分散的多个数据存储单元连接组成的逻辑统一的数据库,在所述分布式数据库的基础上基于数据分片和负载均衡,能够使所述分布式数据库在规模上实现无缝扩展。
所述目标数据分区,是指所述客户端期望操作的数据集合,本实施例中,所述目标数据分区是指分区当中的分区键,所述分区是指数据存储中负载均衡的基本调度单位,通过分区实现数据存储的水平扩展,保证性能和可用性。具体而言,数据库中包含的数据表的主键由数据表中的至少一个主键列组成,所述分区键是指所述数据表的第一个主键列组成的单分区键,在一个分区当中,可能包含多个分区键,并且这些分区键之间不会有重合。除此之外,在具体实施时,所述目标数据分区还可以是所述数据表中所述分区键之外的主键列或者多个主键列的集合,比如所述目标数据分区还可以是所述数据表的第一个主键列之外的其他任意一个主键列组成的单分区键,或者,所述目标数据分区还可以是所述数据表的多个主键列组成的联合分区键,或者所述目标数据分区还可以是多个分区键组成的联合分区键,本实施例对此不作限定。所述客户端在申请请求中嵌入目标数据分区的分区键,当接收到来自所述客户端的申请请求,获得所述申请请求中的分区键,进而确定所述客户端期望操作的数据集合。所述数据操作,是指对所述分区键下数据的具体操作,例如增加一行数据、删除一行数据、修改某行或某些行数据中的某个或某些值、读取某个或某些数据等。
本步骤中,接收所述客户端发送的在分区键下进行数据操作的申请请求,即申请分区键的数据库事务。例如,如附图2所示,接收业务1对应的客户端发送的申请分区键PK0为0的数据库事务。
步骤2,根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识。
上述步骤1接收所述客户端发送的在分区键下进行数据操作的申请请求,即申请分区键的数据库事务,本步骤根据所述申请请求创建对应的数据库事务,并为所述数据库事务分配事务标识。
所述事务标识是为数据库事务分配的识别码,一个数据库事务有且仅有一个事务标识,并且每个数据库事务的事务标识都不相同。更具体地说,所述事务标识可以采用字符串的形式,也可以采用数字的形式。
例如,如附图2所示,接收到业务1对应的客户端发送的申请分区键PK0为0的数据库事务之后,创建数据库事务3,并为当前新创建的数据库事务3分配对应的事务ID(事务标识)。
本步骤中为所述数据库事务分配事务标识,为后续所述客户端修改所述数据库事务提供基础,由于服务端同时分配不同的数据库事务给若干个业务对应的客户端,因此,需要根据所述事务标识确定所述客户端所要修改的具体的数据库事务。同时,由于服务端同时分配不同的数据库事务给若干个业务对应的客户端,因此,在为所述数据库事务分配事务标识的同时,将所述数据库事务对应的所述分区键锁定,即不允许所述数据库事务之外的其他数据库事务对所述分区键下的数据进行数据操作。例如,如附图2所示,当业务1对应的客户端发送的申请分区键PK0为0的数据库事务3被锁定之后,业务2对应的客户端申请分区键PK0为0的数据库事务时,申请失败。
在实际应用中,可针对所述分区键设置相应的状态,包括锁定状态和未锁定状态,一旦接收到的所述申请请求为在当前分区键下进行数据操作的申请请求,当前分区键的状态被更新为锁定状态;若尚未接收到在当前分区键下进行数据操作的申请请求,则当前分区键的状态保持为未锁定状态。
基于此,在具体实施时,在本步骤据所述申请请求创建对应的数据库事务,并为所述数据库事务分配事务标识之前,需要判断所述客户端申请的分区键是否被锁定,具体通过判断所述分区键的状态是否为未锁定状态来判断所述分区键是否被锁定,如果所述分区键已经被锁定,则针对上述步骤1中所述客户端发送的在所述分区键下进行数据操作的申请请求,做出申请失败的回应,并且不再创建数据库事务以及分配事务标识;如 果所述分区键未被锁定,则执行本步骤,根据所述申请请求创建对应的数据库事务,并为所述数据库事务分配事务标识。
步骤3,将分配给所述数据事务的事务标识返回给所述客户端。
上述步骤2根据所述申请请求创建对应的数据库事务,并为所述数据库事务分配事务标识,本步骤中,将上述步骤2为所述数据库事务分配的事务标识返回给所述客户端。例如,如附图2所示,将分配给数据库事务3的事务ID返回给业务1对应的客户端,业务1对应的客户端接收到数据库事务3的事务ID,表示申请成功。
此外,将所述数据库事务分配的事务标识返回给所述客户端之后,还可以启动超时检测机制,所述超时检测机制具体通过判断在一定的时间阈值范围内是否接收到所述客户端发送的动作指令,即所述时间阈值范围内是否接收到下述步骤4中所述客户端发送的针对所述数据事务进行处理的动作指令,如果没有,则触发超时,销毁所述数据库事务,回收所述事务标识,也就是说,所述数据库事务标识失效,其所对应的事务标识亦失效。在具体实施时,所述时间阈值范围可根据实际应用场景灵活设定。
步骤4,根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作。
本步骤根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作。具体的,本实施例中,可实现对处于同一目标数据分区的多行数据同时进行修改。例如,如附图2所示,业务1可以携带新创建的数据库事务3对应的事务ID对分区键PK0为0下的多行数据进行修改,这些修改放在内存中,并不会立即生效,对其他数据库事务不可见,并且如果服务端所在的机器发生宕机,这些修改会被丢失。
步骤5,根据所述客户端发送的事务指令处理所述数据事务。
本步骤根据所述客户端发送的事务指令处理所述数据事务之前,需执行接收所述客户端发送的针对所述数据库事务进行处理的所述事务指令步骤。基于此,还可以在接收到针对所述数据库事务进行处理的所述事务指令之后,判断所述事务指令对应的数据库事务是否存在,如果存在,则执行本步骤,根据所述客户端发送的事务指令处理所述数据事务;如果不存在,则向所述客户端返回所述事务指令对应的数据库事务不存在的提醒信息。
本申请实施例所述事务指令,包括事务提交指令和事务取消指令,以下针对这两种事务指令分别进行说明:
1)所述客户端发送的事务指令为所述事务提交指令;
本步骤根据所述客户端发送的事务指令处理所述数据事务,具体采用如下方式实现:
将所述数据库事务提交到事务队列;
从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中;
将所述事务日志存储至预设数据存储空间中。
在实际应用场景中,服务端可能是同时与若干个客户端进行交互,不同的客户端可能在较短的时间内提交不同的数据库事务,这些数据库事务不能同时执行,因此设置事务队列,将所述数据库事务提交到事务队列,按照顺序依次执行数据库事务。具体的,所述事务队列可以是由数据库事务组成的一种线性表,该事务队列根据数据库事务提交的先后顺序将所述数据库事务进行排列,并且按照排列顺序依次读取所述数据库事务。
例如,如附图2所示,当接收到业务1对应的客户端针对数据库事务3发送的事务提交指令之后,将数据库事务3提交至事务队列当中;此后,对事务队列当中的数据库事务进行处理时,从事务队列当中读取数据库事务3,并将数据库事务3的数据操作记录在对应的事务日志中,并最终将事务日志存储在内存当中。
此外,上述针对所述数据库事务的提交操作完成之后,所述数据库事务被销毁,并回收所述数据库事务对应的事务标识,同时,所述数据库事务所对应的分区键实现解锁,即允许其他数据库事务对所述分区键下的数据进行数据操作,保证了数据库事务的隔离性。隔离性是数据库事务针对并发事务间的冲突提供的安全保证,数据库事务可以通过加锁在并发执行的事务间提供不同级别的分离,从而避免操纵相同的共享对象的多个并发事务的执行可能引起异常情况。
2)所述客户端发送的事务指令为所述事务取消指令;
本步骤根据所述客户端发送的事务指令处理所述数据事务,具体采用如下方式实现:
删除所述数据库事务,并回收所述数据库事务对应的事务标识。由于所述数据库事务并未真正执行,所述数据库事务作废,确保数据库事务的原子性。
除此之外,在具体实施时,所述客户端发送的针对所述数据库事务进行处理的事务指令还包括事务回滚指令,在所述数据库事务提交之前对所述数据库事务进行回滚,放弃之前针对所述数据库事务的修改,并终止处理所述数据库事务。
在具体实施时,本申请提供的所述数据事务处理方法,还可以基于云计算环境中部署的分布式数据库平台实现,所述分布式数据库平台设置有用于访问所述分布式数据库 (如NoSQL数据库)的数据访问接口,业务对应的客户端想要使用NoSQL数据库进行业务数据处理时,通过调用所述数据访问接口,向所述服务端提交基于NoSQL数据库的分区键申请数据库事务,所述服务端通过所述数据访问接口获取业务对应的客户端提交的基于NoSQL数据库的分区键申请数据库事务并进行相应处理;同时,业务对应的客户端还通过所述数据访问接口向所述服务端提交针对所述数据库事务进行处理的事务指令,所述服务端通过所述数据访问接口获取到所述事务指令,根据所述事务指令对所述数据库事务进行处理。
综上所述,本申请提供的所述数据事务处理方法,对所述客户端在所述分区键下进行数据操作的数据库事务进行处理时,为创建的数据库事务分配事务标识,并将所述事务标识返回给所述客户端,由所述客户端通过提交携带所述事务标识的数据操作在所述分区键下执行数据操作,并最终根据所述客户端发送的事务指令对所述数据库事务进行处理,从而使所述数据操作实现事务属性,满足了数据操作的事务性;同时,所述数据事务处理方法实现数据事务的业务逻辑较为简单,确保数据业务具有良好的事务性。
本申请提供的一种数据事务处理装置实施例如下:
在上述的实施例中,提供了一种数据事务处理方法,与之相对应的,本申请还提供了一种数据事务处理装置,下面结合附图进行说明。
参照附图3,其示出了本申请提供的一种数据事务处理装置实施例的示意图。
由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关的部分请参见上述提供的方法实施例的对应说明即可。下述描述的装置实施例仅仅是示意性的。
本申请提供一种数据事务处理装置,包括:
申请接收单元301,用于接收客户端发送的在目标数据分区进行数据操作的申请请求;
数据事务创建单元302,用于根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
事务标识返回单元303,用于将分配给所述数据事务的事务标识返回给所述客户端;
数据操作提交执行单元304,用于根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
数据事务处理单元305,用于根据所述客户端发送的事务指令处理所述数据事务。
可选的,所述目标数据分区包括:数据库包含的数据表当中的分区键;
相应的,所述数据事务包括:数据库事务。
可选的,所述数据表的主键由数据表中的至少一个主键列组成;
所述分区键包括:所述数据表的第一个主键列组成的单分区键。
可选的,所述事务指令包括:事务提交指令和事务取消指令。
可选的,若所述客户端发送的事务指令为所述事务提交指令,所述数据事务处理单元305,包括:
提交子单元,用于将所述数据库事务提交到事务队列;
事务日志记录子单元,用于从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中。
可选的,所述数据事务处理单元305,包括:
事务日志存储子单元,用于将所述事务日志存储至预设数据存储空间中。
可选的,所述数据事务处理单元305,包括:
第一事务回收子单元,用于删除所述数据库事务,并回收所述数据库事务对应的事务标识。
可选的,若所述客户端发送的事务指令为所述事务取消指令,所述数据事务处理单元305,包括:
第二事务回收子单元,用于删除所述数据库事务,并回收所述数据库事务的事务标识。
可选的,所述数据事务处理装置,包括:
事务指令接收单元,用于接收所述客户端发送的针对所述数据库事务进行处理的事务指令。
可选的,所述数据事务处理装置,包括:
数据库事务判断单元,用于判断所述事务指令对应的数据库事务是否存在,若不存在,运行提醒信息发送单元;
其中,所述提醒信息发送单元,用于向所述客户端返回所述事务指令对应的数据库事务不存在的提醒信息。
可选的,所述分区键的状态包括下述至少一项:锁定状态和未锁定状态;
若接收到的申请请求为在所述分区键下进行数据操作的申请请求,所述分区键的状态被更新为锁定状态。
可选的,所述数据事务处理装置,包括:
分区键状态判断单元,用于判断所述分区键的状态是否为未锁定状态,若否,运行 所述数据事务创建单元302。
可选的,所述数据库包括:通过网络将物理上分散的多个数据存储单元连接组成的逻辑统一的分布式数据库。
可选的,所述数据事务处理装置基于云计算环境中部署的分布式数据库平台运行,所述分布式数据库平台提供用于访问所述分布式数据库的数据访问接口,通过所述数据访问接口接收所述客户端发送的针对所述分布式数据库的分区键进行数据操作的所述申请请求,和/或,通过所述数据访问接口接收所述客户端发送的针对所述数据库事务进行处理的所述事务指令。
本申请提供的另一种数据事务处理方法实施例如下:
在上述的实施例中,提供了一种数据事务处理方法,除此之外,本申请提供另一种数据事务处理方法,与上述数据事务处理方法相互配合,下面结合附图进行说明。
参照附图4,其示出了本申请提供的另一种数据事务处理方法实施例的处理流程图,参照附图2,其示出了本申请提供的一种数据库事务处理场景的示意图。
由于本申请提供的另一种数据事务处理方法与上述数据事务处理方法实施例相互配合,所以描述得比较简单,阅读本实施例请参见上述数据事务处理方法实施例的对应说明。
本申请提供另一种数据事务处理方法,包括:
步骤S401,向服务端发送在目标数据分区进行数据操作的申请请求。
以C/S结构为例,本申请提供的上述数据事务处理方法,基于所述服务端实现,本申请提供的另一种数据事务处理方法,基于客户端实现。与C/S结构相类似,本申请提供的上述数据事务处理方法,还可以基于数据发送方或者数据生产方实现,对应的,本申请提供的另一种数据事务处理方法,还可以基于数据处理方或者数据消费方实现。
所述目标数据分区,是指所述客户端期望操作的数据集合,本实施例中,所述目标数据分区是指分区当中的分区键,所述分区是指数据存储中负载均衡的基本调度单位,通过分区实现数据存储的水平扩展,保证性能和可用性。具体而言,数据库中包含的数据表的主键由数据表中的至少一个主键列组成,所述分区键是指所述数据表的第一个主键列组成的单分区键,在一个分区当中,可能包含多个分区键,并且这些分区键之间不会有重合。除此之外,在具体实施时,所述目标数据分区还可以是所述数据表中所述分区键之外的主键列或者多个主键列的集合,比如所述目标数据分区还可以是所述数据表的第一个主键列之外的其他任意一个主键列组成的单分区键,或者,所述目标数据分区 还可以是所述数据表的多个主键列组成的联合分区键,或者所述目标数据分区还可以是多个分区键组成的联合分区键,本实施例对此不作限定。所述数据操作,是指对所述分区键下数据的具体操作,例如增加一行数据、删除一行数据、修改某行或某些行数据中的某个或某些值、读取某个或某些数据等。
本步骤中,客户端向所述服务端发送在所述分区键下进行数据操作的申请请求,即:申请在所述分区键下进行数据操作的数据库事务。
步骤S402,接收所述服务端返回的所述申请请求对应的数据事务的事务标识。
上述步骤S401向所述服务端发送在所述分区键下进行数据操作的申请请求,即:申请在所述分区键下进行数据操作的数据库事务,所述服务端接收到所述申请请求之后,根据所述申请请求创建对应的数据库事务,并为所述数据库事务分配事务标识,并向客户端返回所述事务标识,基于此,本步骤接收所述服务端返回的所述申请请求对应的数据库事务的事务标识。
步骤S403,向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作。
上述步骤S402接收到所述服务端返回的所述申请请求对应的数据库事务的事务标识,客户端在接收到所述事务标识之后,表示所述数据库事务申请成功,在此基础上,本步骤中,向所述服务端提交携带所述事务标识的数据操作,用于在所述分区键下执行所述数据操作。
步骤S404,基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
在具体实施时,在上述步骤S403向所述服务端提交携带所述事务标识的数据操作,用于在所述分区键下执行所述数据操作执行之后,本步骤中,基于所述事务标识向所述服务端发送针对所述数据库事务进行处理的事务指令。其中,所述事务指令包括:事务提交指令和事务取消指令。如上所述,所述服务端在接收到针对所述数据库事务进行处理的所述事务指令之后,判断所述事务指令对应的数据库事务是否存在,如果不存在,则向客户端返回所述事务指令对应的数据库事务不存在的提醒信息。因此,在上述向所述服务端发送针对所述数据库事务进行处理的事务指令之后,还包括接收所述服务端返回的所述事务指令对应的数据库事务不存在的提醒信息。
在具体实施时,本申请提供的另一种数据事务处理方法,还可以基于云计算环境中部署的分布式数据库平台实现,所述分布式数据库平台设置有用于访问所述分布式数据 库(如NoSQL数据库)的数据访问接口,业务对应的客户端想要使用NoSQL数据库进行业务数据处理时,通过调用所述数据访问接口,向所述服务端提交基于NoSQL数据库的分区键申请数据库事务,所述服务端通过所述数据访问接口获取业务对应的客户端提交的基于NoSQL数据库的分区键申请数据库事务并进行相应处理;同时,业务对应的客户端还通过所述数据访问接口向所述服务端提交针对所述数据库事务进行处理的事务指令,所述服务端通过所述数据访问接口获取到所述事务指令,根据所述事务指令对所述数据库事务进行处理。
本申请提供的另一种数据事务处理装置实施例如下:
在上述的实施例中,提供了另一种数据事务处理方法,与之相对应的,本申请还提供了另一种数据事务处理装置,下面结合附图进行说明。
参照附图5,其示出了本申请提供的另一种数据事务处理装置实施例的示意图。
由于装置实施例基本相似于方法实施例,所以描述得比较简单,相关的部分请参见上述提供的方法实施例的对应说明即可。下述描述的装置实施例仅仅是示意性的。
本申请提供另一种数据事务处理装置,包括:
申请发送单元501,用于向服务端发送在目标数据分区进行数据操作的申请请求;
事务标识接收单元502,用于接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
数据操作提交单元503,用于向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
事务指令发送单元504,用于基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
可选的,所述目标数据分区包括:数据库包含的数据表当中的分区键;
相应的,所述数据事务包括:数据库事务。
可选的,所述数据表的主键由数据表中的至少一个主键列组成;
所述分区键包括:所述数据表的第一个主键列组成的单分区键。
可选的,所述事务指令包括:事务提交指令和事务取消指令。
可选的,所述数据事务处理装置,包括:
提醒信息接收单元,用于接收所述服务端返回的所述事务指令对应的数据库事务不存在的提醒信息。
本申请提供的一种电子设备实施例如下:
在上述的实施例中,提供了一种数据事务处理方法,此外,本申请还提供了一种用于实现所述数据事务处理方法的电子设备,下面结合附图进行说明。
参照附图6,其示出了本实施例提供的一种电子设备的示意图。
本申请提供的所述电子设备实施例描述得比较简单,相关的部分请参见上述提供的所述数据事务处理方法实施例的对应说明即可。下述描述的实施例仅仅是示意性的。
本申请提供一种电子设备,包括:
存储器601,以及处理器602;
所述存储器601用于存储计算机可执行指令,所述处理器602用于执行所述计算机可执行指令:
接收客户端发送的在目标数据分区进行数据操作的申请请求;
根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
将分配给所述数据事务的事务标识返回给所述客户端;
根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
根据所述客户端发送的事务指令处理所述数据事务。
可选的,所述目标数据分区包括:数据库包含的数据表当中的分区键;
相应的,所述数据事务包括:数据库事务。
可选的,所述数据表的主键由数据表中的至少一个主键列组成;
所述分区键包括:所述数据表的第一个主键列组成的单分区键。
可选的,所述事务指令包括:事务提交指令和事务取消指令。
可选的,若所述客户端发送的事务指令为所述事务提交指令,所述根据所述客户端发送的事务指令处理所述数据事务,采用如下方式实现:
将所述数据库事务提交到事务队列;
从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中。
可选的,所述从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中指令执行后,所述处理器602还用于执行下述计算机可执行指令:
将所述事务日志存储至预设数据存储空间中。
可选的,所述将所述事务日志存储至预设数据存储空间中指令执行后,所述处理器 602还用于执行下述计算机可执行指令:
删除所述数据库事务,并回收所述数据库事务对应的事务标识。
可选的,若所述客户端发送的事务指令为所述事务取消指令,所述根据所述客户端发送的事务指令处理所述数据事务,采用如下方式实现:
删除所述数据库事务,并回收所述数据库事务的事务标识。
可选的,所述根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作指令执行后,且所述根据所述客户端发送的事务指令处理所述数据事务指令执行前,所述处理器602还用于执行下述计算机可执行指令:
接收所述客户端发送的针对所述数据库事务进行处理的事务指令。
可选的,所述接收所述客户端发送的针对所述数据库事务进行处理的动作指令这一计算机可执行指令执行后,所述处理器602还用于执行下述计算机可执行指令:
判断所述事务指令对应的数据库事务是否存在,若不存在,向所述客户端返回所述事务指令对应的数据库事务不存在的提醒信息。
可选的,所述分区键的状态包括下述至少一项:锁定状态和未锁定状态;
若接收到的申请请求为在所述分区键下进行数据操作的申请请求,所述分区键的状态被更新为锁定状态。
可选的,所述接收客户端发送的在目标数据分区进行数据操作的申请请求指令执行后,且所述根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识指令执行前,所述处理器602还用于执行下述计算机可执行指令:
判断所述分区键的状态是否为未锁定状态,若否,执行所述根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识指令。
可选的,所述数据库包括:通过网络将物理上分散的多个数据存储单元连接组成的逻辑统一的分布式数据库。
可选的,所述处理器602基于云计算环境中部署的分布式数据库平台执行所述计算机可执行指令,所述分布式数据库平台提供用于访问所述分布式数据库的数据访问接口,通过所述数据访问接口接收所述客户端发送的针对所述分布式数据库的分区键进行数据操作的所述申请请求,和/或,通过所述数据访问接口接收所述客户端发送的针对所述数据库事务进行处理的所述事务指令。
本申请提供的另一种电子设备实施例如下:
在上述的实施例中,提供了另一种数据事务处理方法,此外,本申请还提供了一种 用于实现本申请提供的另一种数据事务处理方法的电子设备,下面结合附图进行说明。
参照附图7,其示出了本实施例提供的另一种电子设备的示意图。
本申请提供的所述电子设备实施例描述得比较简单,相关的部分请参见上述提供的另一种数据事务处理方法实施例的对应说明即可。下述描述的实施例仅仅是示意性的。
本申请提供另一种电子设备,包括:
存储器701,以及处理器702;
所述存储器701用于存储计算机可执行指令,所述处理器702用于执行所述计算机可执行指令:
向服务端发送在目标数据分区进行数据操作的申请请求;
接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
可选的,所述目标数据分区包括:数据库包含的数据表当中的分区键;
相应的,所述数据事务包括:数据库事务。
可选的,所述数据表的主键由数据表中的至少一个主键列组成;
所述分区键包括:所述数据表的第一个主键列组成的单分区键。
可选的,所述事务指令包括:事务提交指令和事务取消指令。
可选的,所述处理器702还用于执行下述计算机可执行指令:
接收所述服务端返回的所述事务指令对应的数据库事务不存在的提醒信息。
本申请虽然以较佳实施例公开如上,但其并不是用来限定本申请,任何本领域技术人员在不脱离本申请的精神和范围内,都可以做出可能的变动和修改,因此本申请的保护范围应当以本申请权利要求所界定的范围为准。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。 计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括非暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
本领域技术人员应明白,本申请的实施例可提供为方法、系统或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。

Claims (23)

  1. 一种数据事务处理方法,其特征在于,包括:
    接收客户端发送的在目标数据分区进行数据操作的申请请求;
    根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
    将分配给所述数据事务的事务标识返回给所述客户端;
    根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
    根据所述客户端发送的事务指令处理所述数据事务。
  2. 根据权利要求1所述的数据事务处理方法,其特征在于,所述目标数据分区包括:数据库包含的数据表当中的分区键;
    相应的,所述数据事务包括:数据库事务。
  3. 根据权利要求2所述的数据事务处理方法,其特征在于,所述数据表的主键由数据表中的至少一个主键列组成;
    所述分区键包括:所述数据表的第一个主键列组成的单分区键。
  4. 根据权利要求3所述的数据事务处理方法,其特征在于,所述事务指令包括:
    事务提交指令和事务取消指令。
  5. 根据权利要求4所述的数据事务处理方法,其特征在于,若所述客户端发送的事务指令为所述事务提交指令,所述根据所述客户端发送的事务指令处理所述数据事务,采用如下方式实现:
    将所述数据库事务提交到事务队列;
    从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中。
  6. 根据权利要求5所述的数据事务处理方法,其特征在于,所述从所述事务队列中读取数据库事务,创建所述数据库事务对应的事务日志,并将所述数据库事务的数据操作记录在事务日志中子步骤执行后,执行下述子步骤:
    将所述事务日志存储至预设数据存储空间中。
  7. 根据权利要求6所述的数据事务处理方法,其特征在于,所述将所述事务日志存储至预设数据存储空间中子步骤执行后,执行下述子步骤:
    删除所述数据库事务,并回收所述数据库事务对应的事务标识。
  8. 根据权利要求4所述的数据事务处理方法,其特征在于,若所述客户端发送的 事务指令为所述事务取消指令,所述根据所述客户端发送的事务指令处理所述数据事务,采用如下方式实现:
    删除所述数据库事务,并回收所述数据库事务的事务标识。
  9. 根据权利要求3所述的数据事务处理方法,其特征在于,所述根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作步骤执行后,且所述根据所述客户端发送的事务指令处理所述数据事务步骤执行前,执行下述步骤:
    接收所述客户端发送的针对所述数据库事务进行处理的事务指令。
  10. 根据权利要求9所述的数据事务处理方法,其特征在于,所述接收所述客户端发送的针对所述数据库事务进行处理的动作指令步骤执行后,执行下述步骤:
    判断所述事务指令对应的数据库事务是否存在,若不存在,向所述客户端返回所述事务指令对应的数据库事务不存在的提醒信息。
  11. 根据权利要求3所述的数据事务处理方法,其特征在于,所述分区键的状态包括下述至少一项:
    锁定状态和未锁定状态;
    若接收到的申请请求为在所述分区键下进行数据操作的申请请求,所述分区键的状态被更新为锁定状态。
  12. 根据权利要求11所述的数据事务处理方法,其特征在于,所述接收客户端发送的在目标数据分区进行数据操作的申请请求步骤执行后,且所述根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识步骤执行前,执行下述步骤:
    判断所述分区键的状态是否为未锁定状态,若否,执行所述根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识步骤。
  13. 根据权利要求3至12任意一项所述的数据事务处理方法,其特征在于,所述数据库包括:
    通过网络将物理上分散的多个数据存储单元连接组成的逻辑统一的分布式数据库。
  14. 根据权利要求13所述的数据事务处理方法,其特征在于,所述数据事务处理方法基于云计算环境中部署的分布式数据库平台实现,所述分布式数据库平台提供用于访问所述分布式数据库的数据访问接口,通过所述数据访问接口接收所述客户端发送的针对所述分布式数据库的分区键进行数据操作的所述申请请求,和/或,通过所述数据访问接口接收所述客户端发送的针对所述数据库事务进行处理的所述事务指令。
  15. 一种数据事务处理装置,其特征在于,包括:
    申请接收单元,用于接收客户端发送的在目标数据分区进行数据操作的申请请求;
    数据事务创建单元,用于根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
    事务标识返回单元,用于将分配给所述数据事务的事务标识返回给所述客户端;
    数据操作提交执行单元,用于根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
    数据事务处理单元,用于根据所述客户端发送的事务指令处理所述数据事务。
  16. 一种数据事务处理方法,其特征在于,包括:
    向服务端发送在目标数据分区进行数据操作的申请请求;
    接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
    向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
    基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
  17. 根据权利要求16所述的数据事务处理方法,其特征在于,所述目标数据分区包括:数据库包含的数据表当中的分区键;
    相应的,所述数据事务包括:数据库事务。
  18. 根据权利要求17所述的数据事务处理方法,其特征在于,所述数据表的主键由数据表中的至少一个主键列组成;
    所述分区键包括:所述数据表的第一个主键列组成的单分区键。
  19. 根据权利要求18所述的数据事务处理方法,其特征在于,所述事务指令包括:事务提交指令和事务取消指令。
  20. 根据权利要求19所述的数据事务处理方法,其特征在于,包括:
    接收所述服务端返回的所述事务指令对应的数据库事务不存在的提醒信息。
  21. 一种数据事务处理装置,其特征在于,包括:
    申请发送单元,用于向服务端发送在目标数据分区进行数据操作的申请请求;
    事务标识接收单元,用于接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
    数据操作提交单元,用于向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
    事务指令发送单元,用于基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
  22. 一种电子设备,其特征在于,包括:
    存储器,以及处理器;
    所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:
    接收客户端发送的在目标数据分区进行数据操作的申请请求;
    根据所述申请请求创建对应的数据事务,并为所述数据事务分配事务标识;
    将分配给所述数据事务的事务标识返回给所述客户端;
    根据所述客户端提交的携带所述事务标识的数据操作,基于所述目标数据分区执行所述数据操作;
    根据所述客户端发送的事务指令处理所述数据事务。
  23. 一种电子设备,其特征在于,包括:
    存储器,以及处理器;
    所述存储器用于存储计算机可执行指令,所述处理器用于执行所述计算机可执行指令:
    向服务端发送在目标数据分区进行数据操作的申请请求;
    接收所述服务端返回的所述申请请求对应的数据事务的事务标识;
    向所述服务端提交携带所述事务标识的数据操作,用于针对所述目标数据分区执行所述数据操作;
    基于所述事务标识向所述服务端发送针对所述数据事务进行处理的事务指令。
PCT/CN2018/100419 2017-08-25 2018-08-14 数据事务处理方法、装置以及电子设备 WO2019037617A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP18847869.7A EP3674909A4 (en) 2017-08-25 2018-08-14 DATA TRANSACTION PROCESSING METHOD, DEVICE AND ELECTRONIC DEVICE
US16/789,313 US11709803B2 (en) 2017-08-25 2020-02-12 Data transaction processing method, apparatus, and electronic device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710738319.8A CN110019112B (zh) 2017-08-25 2017-08-25 数据事务处理方法、装置以及电子设备
CN201710738319.8 2017-08-25

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/789,313 Continuation US11709803B2 (en) 2017-08-25 2020-02-12 Data transaction processing method, apparatus, and electronic device

Publications (1)

Publication Number Publication Date
WO2019037617A1 true WO2019037617A1 (zh) 2019-02-28

Family

ID=65438400

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/100419 WO2019037617A1 (zh) 2017-08-25 2018-08-14 数据事务处理方法、装置以及电子设备

Country Status (4)

Country Link
US (1) US11709803B2 (zh)
EP (1) EP3674909A4 (zh)
CN (1) CN110019112B (zh)
WO (1) WO2019037617A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10841851B2 (en) 2012-06-13 2020-11-17 All Purpose Networks, Inc. Methods and systems of an all purpose broadband network with publish subscribe broker network
CN113297320A (zh) * 2020-07-24 2021-08-24 阿里巴巴集团控股有限公司 分布式数据库系统及数据处理方法

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110019112B (zh) * 2017-08-25 2023-10-31 阿里巴巴集团控股有限公司 数据事务处理方法、装置以及电子设备
WO2019090344A1 (en) * 2017-11-06 2019-05-09 Velo Holdings Limited Limited scope blockchain system
CN110471746B (zh) * 2019-08-22 2022-04-19 中国工商银行股份有限公司 一种分布式事务回调方法、装置及系统
CN111402066B (zh) * 2020-02-22 2023-06-23 中国平安财产保险股份有限公司 数据处理方法、服务器及存储介质
US20210342317A1 (en) * 2020-04-29 2021-11-04 Oracle International Corporation Techniques for efficient migration of key-value data
CN113760465A (zh) * 2020-11-16 2021-12-07 北京沃东天骏信息技术有限公司 一种事务执行方法、装置、服务器、设备和存储介质
CN114579604B (zh) * 2022-03-15 2022-09-20 北京梦诚科技有限公司 一种应用层的数据库事务实现方法和系统
CN115729951B (zh) * 2022-11-28 2024-02-09 易保网络技术(上海)有限公司 数据查询方法、系统、设备及计算机可读存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101089857A (zh) * 2007-07-24 2007-12-19 中兴通讯股份有限公司 一种内存数据库事务管理方法及系统
US20080126346A1 (en) * 2006-11-29 2008-05-29 Siemens Medical Solutions Usa, Inc. Electronic Data Transaction Processing Test and Validation System
CN101639835A (zh) * 2008-07-30 2010-02-03 国际商业机器公司 多租户场景中应用数据库分区的方法和装置

Family Cites Families (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6618851B1 (en) * 1999-08-31 2003-09-09 Autodesk, Inc. Method and apparatus for state-reversion
US6816873B2 (en) 2001-05-15 2004-11-09 International Business Machines Corporation Method for managing distributed savepoints across multiple DBMS's within a distributed transaction
US7904434B2 (en) 2007-09-14 2011-03-08 Oracle International Corporation Framework for handling business transactions
GB2472620B (en) * 2009-08-12 2016-05-18 Cloudtran Inc Distributed transaction processing
US20110161281A1 (en) 2009-12-30 2011-06-30 Sybase, Inc. Distributed Transaction Management in a Distributed Shared Disk Cluster Environment
US8352688B2 (en) * 2010-11-15 2013-01-08 Advanced Micro Devices, Inc. Preventing unintended loss of transactional data in hardware transactional memory systems
US8442962B2 (en) 2010-12-28 2013-05-14 Sap Ag Distributed transaction management using two-phase commit optimization
JP2013033345A (ja) 2011-08-01 2013-02-14 Internatl Business Mach Corp <Ibm> トランザクション処理システム、方法及びプログラム
US8898109B2 (en) * 2012-07-27 2014-11-25 Microsoft Corporation Automatic transaction retry after session failure
US9276959B2 (en) * 2013-11-11 2016-03-01 Amazon Technologies, Inc. Client-configurable security options for data streams
US9613122B2 (en) 2014-05-02 2017-04-04 Facebook, Inc. Providing eventual consistency for multi-shard transactions
CN105608086B (zh) 2014-11-17 2021-07-27 中兴通讯股份有限公司 分布式数据库系统的事务处理方法及装置
US9736243B2 (en) * 2014-12-12 2017-08-15 Microsoft Technology Licensing, Llc Multiple transaction logs in a distributed storage system
CN104731943B (zh) * 2015-03-31 2019-09-13 华为技术有限公司 一种服务器和数据处理方法
US10268743B2 (en) 2015-06-19 2019-04-23 Sap Se Distributed database transaction protocol
US10339127B2 (en) 2016-01-28 2019-07-02 Oracle International Corporation Guaranteed commit outcome in a distributed transaction processing system
CN107977376B (zh) 2016-10-24 2020-07-07 腾讯科技(深圳)有限公司 分布式数据库系统及事务处理方法
US11113624B2 (en) * 2017-07-12 2021-09-07 Sap Se Distributed machine learning on heterogeneous data platforms
CN110019112B (zh) * 2017-08-25 2023-10-31 阿里巴巴集团控股有限公司 数据事务处理方法、装置以及电子设备
CN110019994A (zh) * 2017-11-13 2019-07-16 阿里巴巴集团控股有限公司 数据加密、解密及查询方法、数据加密解密及查询装置
US11061735B2 (en) * 2019-01-02 2021-07-13 Alibaba Group Holding Limited System and method for offloading computation to storage nodes in distributed system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080126346A1 (en) * 2006-11-29 2008-05-29 Siemens Medical Solutions Usa, Inc. Electronic Data Transaction Processing Test and Validation System
CN101089857A (zh) * 2007-07-24 2007-12-19 中兴通讯股份有限公司 一种内存数据库事务管理方法及系统
CN101639835A (zh) * 2008-07-30 2010-02-03 国际商业机器公司 多租户场景中应用数据库分区的方法和装置

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10841851B2 (en) 2012-06-13 2020-11-17 All Purpose Networks, Inc. Methods and systems of an all purpose broadband network with publish subscribe broker network
CN113297320A (zh) * 2020-07-24 2021-08-24 阿里巴巴集团控股有限公司 分布式数据库系统及数据处理方法
CN113297320B (zh) * 2020-07-24 2024-05-14 阿里巴巴集团控股有限公司 分布式数据库系统及数据处理方法

Also Published As

Publication number Publication date
US11709803B2 (en) 2023-07-25
EP3674909A4 (en) 2021-04-21
CN110019112A (zh) 2019-07-16
US20200183892A1 (en) 2020-06-11
CN110019112B (zh) 2023-10-31
EP3674909A1 (en) 2020-07-01

Similar Documents

Publication Publication Date Title
WO2019037617A1 (zh) 数据事务处理方法、装置以及电子设备
US10503720B2 (en) Providing eventual consistency for multi-shard transactions
US9990224B2 (en) Relaxing transaction serializability with statement-based data replication
CN106462631B (zh) 在最终一致系统中分区数据的一致视图
US7792916B2 (en) Management of cluster-wide resources with shared variables
US10303652B2 (en) File system management
US10970311B2 (en) Scalable snapshot isolation on non-transactional NoSQL
US9189303B2 (en) Shadow queues for recovery of messages
US9946740B2 (en) Handling server and client operations uninterruptedly during pack and audit processes
CN107153644B (zh) 一种数据同步方法及装置
CN110968586A (zh) 分布式事务处理方法及装置
CN110008041B (zh) 一种消息处理方法及装置
JP2010506277A (ja) 要求処理のデータ処理システムおよび方法
US11972414B2 (en) Data recording methods and apparatuses, electronic devices, and storage media
CN114925084B (zh) 分布式事务处理方法、系统、设备及可读存储介质
US11080146B2 (en) System and method for storage unavailability tolerant backup
US11880290B2 (en) Scalable exactly-once data processing using transactional streaming writes
CN114780564A (zh) 数据处理方法、数据处理装置、电子设备和存储介质
US11157456B2 (en) Replication of data in a distributed file system using an arbiter
US20130138614A1 (en) Two-phase data locking transaction processing with distributed partitions and mirroring
US10942912B1 (en) Chain logging using key-value data storage
CN114281765A (zh) 分布式文件系统中的元数据处理方法及设备
CN111949441A (zh) 用于可扩展备份搜索的系统和方法
US11816088B2 (en) Method and system for managing cross data source data access requests
US11269736B2 (en) Method to manage database failure

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2018847869

Country of ref document: EP

Effective date: 20200325