WO2023216636A1 - Procédé et appareil de traitement de transaction et dispositif électronique - Google Patents

Procédé et appareil de traitement de transaction et dispositif électronique Download PDF

Info

Publication number
WO2023216636A1
WO2023216636A1 PCT/CN2022/144419 CN2022144419W WO2023216636A1 WO 2023216636 A1 WO2023216636 A1 WO 2023216636A1 CN 2022144419 W CN2022144419 W CN 2022144419W WO 2023216636 A1 WO2023216636 A1 WO 2023216636A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
target data
data
processing
operations
Prior art date
Application number
PCT/CN2022/144419
Other languages
English (en)
Chinese (zh)
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 北京大学
Publication of WO2023216636A1 publication Critical patent/WO2023216636A1/fr

Links

Images

Classifications

    • 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
    • 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

Definitions

  • the present application relates to the field of database technology, and in particular, to a transaction processing method, device and electronic equipment.
  • a transaction refers to a program execution unit that accesses the database and may update various data in the database.
  • a transaction includes at least one operation that processes at least one piece of data.
  • transaction processing methods that perform operations included in each transaction based on data in the database.
  • Embodiments of the present application provide a transaction processing method, device and electronic equipment to achieve efficient management of the transaction processing process.
  • a transaction processing management method which method includes:
  • the first transaction includes an operation of processing the target data
  • the second transaction is another transaction in parallel with the first transaction
  • executing the The first transaction includes operations to process the target data.
  • detecting whether the target data targeted by the first transaction is occupied by the second transaction includes:
  • the instruction information carried by the target data includes the transaction number of the transaction that occupies the target data; based on the fact that the transaction number included in the instruction information is the transaction number of the second transaction, determine that the The target data is occupied by the second transaction.
  • the target data in response to the target data being occupied by the second transaction, according to the occupation type of the target data by the second transaction and the first transaction.
  • the types of operations included in processing the target data, and performing the operations included in the first transaction to process the target data include:
  • reading the target data according to the occupation type of the target data by the second transaction and the operations included in the first transaction includes:
  • the operation included in the first transaction to process the target data is an update operation
  • the execution of the operation included in the first transaction to process the target data includes:
  • the instruction information includes the transaction number and the occupation type of the first transaction, the occupation type indicates that in the process of executing the operation included in the first transaction to update the target data , prohibiting execution of operations included in other transactions to read or update the target data; execution of operations included in the first transaction to update the target data.
  • the operation of processing the target data included in the first transaction is a read operation
  • the isolation level of the first transaction is serializable
  • the isolation level of performing the operations included in the first transaction to read the target data includes:
  • the instruction information of the target data includes the transaction number and the occupation type of the first transaction, the occupation type indicates performing the operation included in the first transaction to read the During the process of obtaining the target data, it is prohibited to execute operations included in other transactions to update the target data; execute operations included in the first transaction to read the target data.
  • the first transaction includes multiple operations, each operation is directed to corresponding target data, the first target data included in the multiple target data is occupied by the second transaction, and the multiple target data is occupied by the second transaction.
  • the operations are arranged in order of execution, and the operations included in executing the first transaction to process the target data include:
  • the isolation type of the first transaction is snapshot isolation
  • the operation included in the first transaction is to read the target version data corresponding to the target timestamp among the target data of multiple time versions
  • the operations included in executing the first transaction to process the target data include:
  • the multiple differential versions include the differential version corresponding to the target timestamp and the differential version formed before the time corresponding to the target timestamp.
  • the differential version refers to The update operation included in any transaction updates the content of the target data; merge the basic version of the target data and the data of the multiple differential versions to obtain the target data of the multiple data versions that is consistent with the target The target version data corresponding to the timestamp.
  • the method further includes:
  • the base version of the target data and the differential version of the target data are merged regularly to obtain merged data, and the merged data is used to update the base version of the target data.
  • a transaction processing device which device includes:
  • a detection module configured to detect whether the target data targeted by the first transaction is occupied by a second transaction, the first transaction includes an operation of processing the target data, and the second transaction is other parallel transactions with the first transaction. affairs;
  • Execution module configured to respond to the target data being occupied by the second transaction, and perform an operation based on the occupation type of the target data by the second transaction and the operation of processing the target data included in the first transaction.
  • Type perform operations included in the first transaction to process the target data.
  • the detection module is configured to read the indication information carried by the target data, the indication information including the transaction number of the transaction occupying the target data; based on the indication information included If the transaction number is the transaction number of the second transaction, it is determined that the target data is occupied by the second transaction.
  • the execution module is configured to respond to the target data being occupied by the second transaction, and the operation of processing the target data included in the first transaction is an update operation, Then after the processing result of the second transaction is submitted, the target data is updated according to the operations included in the first transaction; in response to the target data being occupied by the second transaction, and the first transaction If the included operation of processing the target data is a read operation, then the target data is read according to the occupation type of the target data by the second transaction and the operation included in the first transaction.
  • the execution module is configured to determine the occupation type of the target data by the second transaction; in response to the occupation type indication, the process of occupying the target data by the second transaction , operations included in other transactions except the second transaction are prohibited from updating and reading the target data, then after the processing result of the second transaction is submitted, execution is performed according to the isolation level of the first transaction
  • the first transaction includes an operation to read the target data, and the isolation level of the first transaction is used to indicate a read rule corresponding to the operation included in the first transaction to read the target data.
  • the operation of processing the target data included in the first transaction is an update operation
  • the execution module is configured to set instruction information of the target data, and the instruction information includes the The transaction number and occupancy type of the first transaction, the occupancy type indicates that in the process of executing the operations included in the first transaction to update the target data, it is prohibited to perform other transactions including reading or updating the target data.
  • Operation perform operations included in the first transaction to update the target data.
  • the operation of processing the target data included in the first transaction is a read operation
  • the isolation level of the first transaction is serializable
  • the execution module is used to set Instruction information of the target data
  • the instruction information includes the transaction number and occupation type of the first transaction
  • the occupation type indicates performing operations included in the first transaction to read the target
  • the first transaction includes multiple operations, each operation is directed to corresponding target data, the first target data included in the multiple target data is occupied by the second transaction, and the multiple target data is occupied by the second transaction.
  • the operations are arranged in execution order, and the execution module is configured to respond to completing the submission of the processing result of the second transaction within the first time interval, and after the processing result of the second transaction is submitted, execute the
  • the first transaction includes a first operation of processing the first target data, and the execution sequence of the first transaction includes operations after the first operation; in response to not completing all the operations within the first time interval.
  • the isolation type of the first transaction is snapshot isolation
  • the operation included in the first transaction is to read the target version data corresponding to the target timestamp among the target data of multiple time versions
  • the execution module is used to determine data of multiple differential versions of the target data.
  • the multiple differential versions include the differential version corresponding to the target timestamp and the differential formed before the time corresponding to the target timestamp.
  • Version the differential version refers to the content of the update operation of the target data included in any transaction; merge the basic version of the target data and the data of the multiple differential versions to obtain the multiple data versions The target version data corresponding to the target timestamp in the target data.
  • the device further includes:
  • a merging module configured to regularly merge the basic version of the target data and the differential version of the target data based on the merging time interval to obtain merged data, and the merged data is used to update the target The base version of the data.
  • an electronic device includes a processor and a memory. At least one program code or instruction is stored in the memory. The at least one program code or instruction is loaded and executed by the processor, so that the electronic device Implement any of the above transaction processing methods.
  • a computer-readable storage medium is provided. At least one program code or instruction is stored in the computer-readable storage medium. The program code is loaded and executed by the processor to enable the computer to implement any of the above transaction processes. method.
  • a computer program or computer program product is provided. At least one computer instruction is stored in the computer program or computer program product. The at least one computer instruction is loaded and executed by the processor to enable the computer to implement any of the above. Transaction processing methods.
  • the technical solution provided by the embodiment of the present application detects the occupation of the target data by a second transaction that is parallel to the first transaction, and processes the target data based on the occupation type of the target data by the second transaction and the operations included in the first transaction. This process realizes the processing of parallel transactions based on the detection of target data. There is no need for system calls to control the scenario where the parallel first transaction and the second transaction are processed for the same target data. This avoids frequent falling into the operating system kernel state and improves efficiency. Transaction processing efficiency improves system throughput.
  • Figure 1 is a schematic diagram of an implementation environment provided by an embodiment of the present application.
  • Figure 2 is a flow chart of transaction processing provided by an embodiment of the present application.
  • FIG. 3 is a schematic diagram of data storage provided by an embodiment of the present application.
  • Figure 4 is a schematic structural diagram of a server provided by an embodiment of the present application.
  • Figure 5 is a schematic diagram of an online transaction processing interface provided by an embodiment of the present application.
  • Figure 6 is a schematic diagram of a command line transaction processing interface provided by an embodiment of the present application.
  • Figure 7 is a schematic diagram of an interface transaction processing interface provided by an embodiment of the present application.
  • Figure 8 is a schematic diagram of a transaction processing device provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of an electronic device provided by an embodiment of the present application.
  • the implementation environment of the embodiment of the present application includes a terminal 11 and a server 12.
  • the terminal 11 and the server 12 can communicate and connect to realize interactive transmission of information.
  • the embodiment of the present application does not limit the connection method between the terminal 11 and the server 12 .
  • the terminal 11 submits a transaction startup request to the server 12.
  • the server 12 executes the operations included in the transaction to process the data targeted by the transaction, and then sends the processing results to the terminal 11.
  • the terminal 11 also sends instructions generated during the interaction to the server 12 .
  • the terminal 11 can be any electronic product that can perform human-computer interaction with the user through one or more methods such as keyboard, touch panel, touch screen, voice interaction, etc., such as PC (Personal Computer), mobile phone, PPC ( Pocket Personal Computer, tablet computer, car machine, etc.
  • the server 12 may be one server or a server cluster composed of multiple servers, or may provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, and domain names. Services, security services, CDN (Content Delivery Network, content distribution network), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms.
  • terminal 11 and server 12 are only examples. If other existing or possible terminals or servers that may appear in the future can be used in this application, they should also be included in the protection scope of this application. Incorporated herein by reference.
  • the embodiments of this application are applied in the field of database technology and are suitable for scenarios in which data is managed based on operations in each transaction.
  • the transaction processing method of this application can be applied in the Resource Description Framework (RDF) to perform transaction processing based on a large amount of RDF data included in the RDF database.
  • RDF Resource Description Framework
  • the current RDF database has weak transaction processing capabilities and few transaction processing functions.
  • the transaction processing method provided by this application can achieve efficient transaction processing.
  • a transaction refers to a program execution unit that accesses and possibly updates various data in the database.
  • a transaction includes at least one operation that processes at least one piece of data.
  • Atomicity A transaction is an indivisible whole. All operations included in a transaction can only be completed or not executed at all. Partial operations will not be executed. An exception occurs during the operation on the data, and the data is restored to the state before the transaction started. This process can be called rollback.
  • Consistency Before and after the transaction starts and ends, the integrity constraints of the database are not violated, and the integrity of the data in the database remains consistent. For example: User A's account balance is 1,000 yuan, User B's account balance is 2,900 yuan, and user A transfers 100 yuan to user B. After the transfer is completed, user A's account balance is 900, and user B's account balance is 3,000. Before and after the transfer, the sum of the balances of users A and B's accounts remains unchanged at 3,900 yuan.
  • Isolation means that only operations in one transaction are allowed to process the same data at the same time, and there is no interference between different transactions. For example, for the same data, users A and B start transaction 1 and transaction 2 respectively, and transaction 1 and transaction 2 are executed in parallel. Therefore, transaction 1 and transaction 2 should be isolated from each other. For transaction 1, the operations included in transaction 2 cannot interfere with the execution of transaction 1, and user A cannot feel that transaction 2 is executed in parallel with transaction 1.
  • an embodiment of the present application provides a flow chart of a transaction processing method. This method can be applied to the server. The method includes but is not limited to the following steps 201-202.
  • Step 201 Detect whether the target data targeted by the first transaction is occupied by a second transaction.
  • the first transaction includes an operation of processing the target data.
  • the second transaction is another transaction in parallel with the first transaction.
  • detecting whether the target data targeted by the first transaction is occupied by the second transaction includes: reading the indication information carried by the target data, where the indication information includes the transaction number of the transaction that occupies the target data; based on The transaction number included in the indication information is the transaction number of the second transaction, and it is determined that the target data is occupied by the second transaction.
  • each transaction corresponds to a corresponding transaction number, and the transaction number of each transaction is unique.
  • transaction numbers are randomly assigned by the server and are stored in a transaction list for management.
  • the server before executing step 201, the server receives a start request for the first transaction submitted by the terminal, the server starts the first transaction based on the start request of the first transaction, and allocates a corresponding response to the first transaction. transaction number.
  • the receipt of the start request and the assignment of the transaction number can be performed by a transaction scheduler in the server.
  • the allocation of transaction numbers is determined by a strictly incrementing atomic counter to ensure the uniqueness of the transaction number of each transaction, and the relative order in which multiple transactions are started can be determined based on the transaction numbers of multiple transactions.
  • the transaction number of each transaction may be a 64-bit code.
  • the first transaction is started.
  • the first transaction includes the operation of reading or updating the target data, accessing the target data, and reading the indication information carried by the target data. If the indication information is empty, then The target data has not been occupied by other transactions, and the operations included in the first transaction can process the target data; if the indication information is not empty, determine the transaction number included in the indication information, and the transaction number included in the indication information is The transaction number of the transaction currently occupying the target data. For example, when the current transaction occupies the target data, the update operation included in the current transaction that is occupying the target data is performed to update the target data.
  • the transaction number is the transaction number of the second transaction
  • the method of determining the target data targeted by the first transaction includes, but is not limited to: determining the target data targeted by the first transaction based on the information of the first transaction.
  • the server may determine the information of the first transaction by parsing the instructions of each operation included in the first transaction; or determine the information of the first transaction by parsing the start request of the first transaction.
  • the first transaction includes instructions for each operation that are determined and submitted by the user on the terminal.
  • the start request of the first transaction carries information about the target data to be processed by the operation in the transaction.
  • the information about the target data includes the storage location of the target data, the timestamp corresponding to the target data, or the version number of the target data, etc.
  • Step 202 in response to the target data being occupied by the second transaction, execute the operations included in the first transaction to process the target data according to the occupation type of the target data by the second transaction and the type of operations included in the first transaction to process the target data.
  • the fact that the target data is occupied by the second transaction means that during the process of processing the target data by the operations included in the second transaction, operations included in other transactions are restricted from processing the target data.
  • Different occupancy types have different restrictions on operations included in other transactions.
  • the restriction methods corresponding to the occupancy types include but are not limited to: The first occupancy type is used to indicate that update operations included in other transactions are prohibited while the target data is occupied by the second transaction. Process the target data; or, the second occupation type is used to indicate that when the target data is occupied by the second transaction, in addition to prohibiting update operations included in other transactions from processing the target data, it also prohibits read operations included in other transactions from processing the target data.
  • the target data is processed.
  • any transaction can include an operation to process target data.
  • the type of operation includes but is not limited to updating or reading data.
  • the read operation includes but is not limited to obtaining data and obtaining related data.
  • Information; update operations include but are not limited to adding, modifying, deleting, etc. data.
  • data can be stored in various forms such as numerical values, text, pictures, etc.; then the update operation can include addition and subtraction calculations for data in any numerical form.
  • Any transaction can include one or more operations.
  • a transaction includes one operation, a corresponding operation is performed on a piece of data; when a transaction includes multiple operations, the multiple operations included in the transaction can perform corresponding operations on the same data or different data, and the data includes multiple operations.
  • the operation of processing the target data included in the first transaction is an update operation
  • the processing result of the second transaction is submitted, according to the first A transaction consists of operations that update target data.
  • the operation of processing the target data included in the first transaction is an update operation
  • the process of executing the operation included in the first transaction to update the target data includes: setting instruction information of the target data, the instruction information includes The transaction number and occupancy type of the first transaction.
  • the occupancy type indicates that during the process of executing the operations included in the first transaction to update the target data, it is prohibited to perform the operations of reading or updating the target data included in other transactions; executing the operations included in the first transaction Operation to update target data.
  • the current transaction occupying any data does not allow operations included in other transactions to update any data, so as to avoid affecting the final result of the current transaction. Therefore, during the process of the second transaction occupying the target data, if the first transaction includes an operation to update the target data, and the target data is occupied by a parallel second transaction, regardless of the operation included in the second transaction, the target data is read. Or the update operation cannot perform the operation on the target data included in the first transaction, but it is necessary to perform the update operation on the target data included in the first transaction after the processing result of the second transaction is submitted. After the processing result of the second transaction is submitted, the second transaction ends, the second transaction no longer occupies the target data, and the indication information of the target data returns to empty.
  • the operation of processing the target data included in the first transaction is a read operation, then according to the occupation type of the target data by the second transaction And the first transaction includes the operation of reading the target data.
  • the occupation types of the target data by the second transaction have various forms. Different occupation types correspond to different restrictions, and different restrictions have different regulations on the operations of processing the target data included in other transactions. Thus, the operations included in the first transaction are performed to read the target data according to the occupation type of the target data by the second transaction.
  • the occupation type of the target data by the second transaction is determined; in response to the occupation type indication, during the process of the second transaction occupying the target data, operation updates included in other transactions except the second transaction are prohibited. and reading the target data, after the processing result of the second transaction is submitted, the operations included in the first transaction are performed according to the isolation level of the first transaction to read the target data.
  • the first transaction is directly executed according to the isolation level of the first transaction.
  • a transaction consists of operations to read the target data.
  • the isolation level of the first transaction is used to indicate the read rule corresponding to the operation of reading the target data included in the first transaction.
  • the embodiments of this application include but are not limited to three isolation levels: read committed, snapshot isolation, and serializable.
  • read committed When a transaction corresponds to different isolation levels, the read operations included in the transaction are executed in different ways. The operations included in the transaction have different effects on the read operations.
  • the instruction information of the fetched data is updated in different ways.
  • a read operation included in a transaction running under the Read Committed isolation level can read the updated content of the transaction that has submitted the processing result and return the latest version corresponding to the data targeted by the read operation.
  • the update operation included in the transaction running under the read committed isolation level can update the indication information corresponding to the data targeted by the update operation, and can be used to set the indication information to include the transaction number of the transaction to indicate that the data is occupied by the transaction, and can also Used to set the transaction's occupation type of the data to the second occupation type to indicate that operations included in other transactions are prohibited from updating or reading the data while the transaction is occupying the data.
  • the process in which the transaction occupies the data indicated by the second occupancy type is the process of executing the update operation included in the transaction to update the data.
  • Transactions running under the isolation level of snapshot isolation include read operations that can read multiple versions of the data targeted by the read operation, the version corresponding to the timestamp.
  • the update operation included in the transaction running under snapshot isolation can update the indication information corresponding to the data targeted by the update operation, and can be used to set the indication information to include the transaction number of the transaction to indicate that the data is occupied by the transaction.
  • the update operation is also used to set the transaction's occupation type of the data to the second occupation type to indicate that during the process of the transaction occupying the data, operations included in other transactions are prohibited from updating or reading the data.
  • the process in which the transaction occupies the data indicated by the second occupancy type is the process of executing the update operation included in the transaction to update the data.
  • Transactions running under the serializable isolation level include read operations that can read the updated content of the transaction that has submitted the processing results and return the latest version corresponding to the data targeted by the read operation.
  • the read operation can update the indication information corresponding to the data targeted by the read operation, can be used to set the indication information including the transaction number of the transaction to indicate that the data is occupied by the transaction, and can also be used to set the occupation of the data by the transaction.
  • the type is the first occupation type to indicate that operations included in other transactions are prohibited from updating the data while the transaction is occupying the data.
  • the process in which the transaction occupies the data indicated by the first occupancy type is the process of executing the read operation included in the transaction to read the data.
  • the update operation included in the transaction running under the serializable isolation level can update the instruction information corresponding to the data targeted by the update operation, and can be used to set the instruction information to include the transaction number of the transaction to indicate that the data is occupied by the transaction. , is also used to set the occupation type of the data by the transaction to the second occupation type, to indicate that during the process of the transaction occupying the data, operations included in other transactions are prohibited from updating or reading the data.
  • the process in which the transaction occupies the data indicated by the second occupancy type is the process of executing the update operation included in the transaction to update the data.
  • the operation of processing the target data included in the first transaction is a read operation
  • the isolation level of the first transaction is serializable.
  • executing the first transaction according to the isolation level of the first transaction includes:
  • the operation to read the target data includes, but is not limited to: setting instruction information of the target data, the instruction information includes the instruction information including the transaction number and occupancy type of the first transaction, the occupancy type indicates performing the operation included in the first transaction to read During the process of obtaining the target data, it is prohibited to perform operations included in other transactions to update the target data; operations included in the first transaction are performed to read the target data.
  • step 201 before performing step 201, set a corresponding isolation level for the first transaction to be started, and then submit a startup request including the isolation level to the server.
  • the server starts the first transaction after receiving the startup request. , perform the operations included in the first transaction.
  • the corresponding isolation level is set for the transaction to be started based on the different processing requirements corresponding to different transactions.
  • the processing requirements can be requirements for the consistency of the database state. For example, if the processing requirement corresponding to the transaction to be started is to obtain a strongly consistent database state, then the isolation level corresponding to the transaction is set to serializable; or, the processing requirement corresponding to the transaction to be started is to obtain a consistent database state. If the isolation level is not strict, set the isolation level corresponding to the transaction to snapshot isolation or read committed. Among them, the consistency of the database state is not strict, indicating a weakly consistent database state.
  • the first transaction includes multiple operations, each operation is directed to the corresponding target data, the first target data included in the multiple target data is occupied by the second transaction, and the multiple operations are executed in order arranged, then the process of performing the operations included in the first transaction to process the target data in step 202 includes but is not limited to:
  • executing the first operation of processing the first target data included in the first transaction includes The execution sequence of the operation is after the first operation; in response to the submission of the processing result of the second transaction not being completed within the first time interval, then after the first time interval, re-executing the execution sequence of the first transaction including the first operation The operation before the operation; in response to the completion of execution of multiple operations included in the first transaction, the processing result of the first transaction is submitted.
  • the first transaction and the second transaction are processed in parallel, and the operations included in each transaction are executed sequentially in the order of execution.
  • the target data targeted by any operation in the first transaction is being occupied by the second transaction, in some cases, it is necessary to wait for the processing result of the second transaction to be submitted before executing the operations included in the first transaction, that is, the first transaction includes The operation is waiting.
  • the waiting time of the operations included in the first transaction is recorded from the time the operations included in the first transaction start waiting. If the submission of the processing result of the second transaction is completed within the first time interval from the start of waiting, and the waiting time does not exceed the first time interval, then after the processing result of the second transaction is submitted, the processing step included in the first transaction is executed. A first operation on target data, and then performing operations included in the first transaction in execution order after the first operation. If the submission of the processing result of the second transaction is not completed within the first time interval from the start of waiting, and the waiting time exceeds the first time interval, after the waiting time reaches the first time interval, the first transaction will be processed according to the multiple operations included in the first transaction.
  • the first-ordered operation In the order of execution, starting from the first-ordered operation, re-execute the multiple operations included in the first transaction; when re-executing to the first operation, if the first transaction waits for no longer than the first operation during re-execution, time, after the execution of the first operation is completed, the first transaction including other operations are executed sequentially according to the execution order.
  • the operations included in the first transaction are re-executed again according to the execution order. operate.
  • the number of re-executions exceeds the repetition threshold, a message that the first transaction fails to execute is fed back to the terminal.
  • the setting of the repetition threshold can be determined according to the nature of the first transaction, or can be set in advance. This application does not limit the setting of the value of the repetition threshold.
  • the first time interval increases as the number of repeated executions increases.
  • the time length corresponding to the first time interval in the current repeated execution process is twice the length corresponding to the first time interval in the previous execution process.
  • the increase in the first time interval continuously extends the waiting time in each execution, which can reduce the number of repeated executions, reduce computational complexity, and reduce resource consumption.
  • the first transaction and the second transaction are executed in parallel.
  • the first operation in the first transaction is executed, the data targeted by the first operation is occupied by the second transaction, and the execution of the first operation is suspended, waiting for the completion of the second transaction.
  • the second transaction does not submit the processing result, all operations included in the first transaction are re-executed.
  • the second transaction still occupies the corresponding data.
  • the first time interval is twice the first time interval in the previous execution, that is, 2t. If the processing data of the second transaction is submitted during the waiting time 2t, continue to execute the first operation and other operations included in the first transaction; if the second transaction has not been completed during the waiting time 2t, re-execute the first transaction including all operations. During the second re-execution, the first time interval is 4t. If the first operation still cannot be executed during the second re-execution, the loop will enter the third repeated execution process until the first operation is completed, and then continue to execute other operations included in the first transaction; or until the number of repeated executions exceeds Repeat the threshold and feedback a message that the first transaction failed to execute to the terminal.
  • the isolation type of the first transaction is snapshot isolation
  • the operation included in the first transaction is to read the target version data corresponding to the target timestamp among the target data of multiple time versions, then in step 202 Execute operations included in the first transaction to process the target data, including but not limited to:
  • the multiple differential versions include the differential version corresponding to the target timestamp and the differential version formed before the time corresponding to the target timestamp.
  • the differential version refers to the update operation included in any transaction that affects the target.
  • the content of the data update merge the basic data of the target data and the data of multiple differential versions to obtain the target version data corresponding to the target timestamp in the target data of multiple data versions.
  • merging the basic data of the target data and the data of multiple differential versions may include: after obtaining the basic version and multiple differential versions of the target data, sequentially merge the basic data with the differential versions in the time sequence corresponding to the differential versions. The data is updated to obtain the target version data.
  • merging the basic data of the target data and the data of multiple differential versions may include: after obtaining the basic version and multiple differential versions of the target data, deduplication and merging all obtained differential versions Process to obtain the merged result of the differential version; merge the merged result with the basic data to obtain the target version data.
  • the basic data and corresponding differential versions of each data are stored according to the differential versioning method.
  • Each differential version of each data corresponds to the update operation included in the transaction to update the data. .
  • the basic data M and the differential version "add N" generated based on the updated data content are stored.
  • this application can also directly store the updated target data, for example, "data M+N".
  • the method of determining the target version corresponding to the target timestamp II includes: obtaining the basic data M and the differential version "Add N” and “Add P”, and calculate "M+N” and "M+N+P” in sequence; or, first calculate the merged result "N+P" of the differential version and then merge it with the basic data to obtain "M+N+P".
  • Each differential version corresponds to a different timestamp.
  • the timestamp can represent the life cycle of the differential version and is used to indicate the start time and end time of the transaction to which the operation that generated the differential version belongs. For example, the timestamp may be expressed in the form of [start time, end time).
  • the timestamp is generated based on a combination of physical time and logical time. Among them, physical time refers to the time in the real world, indicating the real time when the transaction corresponding to the differential version occurs; logical time refers to the processing sequence of the transaction corresponding to the differential version determined by applying a logical counter. The count of this logical counter is incremented when each transaction is started. This method of determining timestamps can achieve a combination of logical order and physical order.
  • transaction 1 and transaction 2 are opened successively. Due to the influence of time value accuracy, the opening time of transaction 1 and transaction 2 is both recorded as 20 hours, 18 minutes and 30 seconds. Therefore, transaction 1 and transaction 1 cannot be determined based on physical time only. 2 sequence.
  • the logical time can record the order in which each transaction is opened based on the counter's count. Therefore, the method in the embodiment of the present application that combines physical time and logical time to determine the differential version of the timestamp can obtain a more accurate timestamp, and can more accurately obtain the data required to execute the operations included in each transaction, and has Conducive to improving transaction processing efficiency.
  • Figure 3 shows a schematic diagram of storing data according to the differential versioning method, which is in the form of an adjacency linked list.
  • These include base version and differential version 1-n.
  • differential version 1 corresponds to timestamp [0, TS 1 ), where 0 and TS 1 respectively correspond to the start time and end time of the transaction to which the operation forming the differential version belongs.
  • the version header is used to indicate the start of the differential version and does not indicate specific data.
  • the instruction of the read operation in the first transaction is to read the target version data of the target data at the target timestamp [TS 1 , TS 2 ), then obtain the basic version , differential version 1 and differential version 2, and then merge the basic version, differential version 1 and differential version 2 to update and merge based on the basic version to obtain the target version data corresponding to the target timestamp.
  • the method of merging the basic version, differential version 1 and differential version 2 can include the following two methods:
  • Method 1 Merge the basic version and the differential version 1 to obtain the merge result 1, and then merge the merge result 1 with the differential version 2 to obtain the target version data.
  • Method 2 Merge differential version 1 and differential version 2 to obtain the merged result of the differential versions, and then merge the basic data and differential versions to obtain the target version data.
  • the contents of differential version 1 and differential version 2 may be updated in opposite ways.
  • differential version 1 is to add data 1 and the differential version is to subtract data 1
  • the merge result of the differential versions is not Update basic data.
  • the basic data is the target version data.
  • the number of merge calculations is reduced, the calculation complexity is reduced, and the transaction processing efficiency can be improved.
  • the base version of the target data and the differential version of the target data are merged regularly to obtain the merged result, and the merged data is used to update the base version of the target data.
  • each data update generates a corresponding differential version, which makes it easy to store a large number of differential versions.
  • a large number of differential versions occupy a large amount of storage space, and junk data in the data needs to be recycled and cleaned regularly. Therefore, in a possible implementation, every time the merging time interval elapses, the base version of the target data and the cleared number of differential version data are merged to obtain the merged result, and the base version is updated with the merged result.
  • the number of clearings can be set based on experience or based on scene settings, and this is not limited in the embodiments of the present application.
  • the merge time interval can be expressed as physical time, or the number of committed transactions.
  • the merge time interval is expressed as physical time
  • the time interval from the last time the merge operation was performed to the current time is calculated.
  • the merge operation is performed. For example, if the merging interval is set to 30 minutes, a merging operation will be performed after 30 minutes.
  • the merge time interval is the number of submitted transactions, count the number of transactions that have completed processing results and submitted them from the last time the merge operation was performed to the current time.
  • the number of completed transactions and submitted transactions reaches the merge time interval, execute Merge operation. For example, if the merge time interval is set to 10,000, a merge operation will be performed every time 10,000 transactions are successfully completed.
  • the access or update operation to the data in the database is temporarily interrupted, and the data in the database that meets the cleaning conditions is cleaned.
  • step 202 in response to the completion of all operations included in the first transaction, the processing result of the first transaction is submitted based on the commit instruction, and a message that the first transaction is successfully executed is fed back to the terminal.
  • the submission instruction is triggered by the user on the terminal. After all operations included in the first transaction are executed, the server feeds back a confirmation message to the terminal, prompting the user to confirm again whether to execute the first transaction. In response to the user feedback confirmation instruction, a submission instruction is sent to the server, and the server submits the first transaction. processing results.
  • the server feeds back the confirmation message "Whether the transfer 100 is confirmed" to the terminal.
  • the user issues a "confirm completion” instruction and then sends a submission instruction to the server, instructing the server to submit the execution result of the first transaction. That is, the data of A's account reduced by 100 yuan and the data of B's account added 100 yuan are stored in the database.
  • the server feeds back the "transfer completed” message to the terminal, prompting the user that the first transaction was executed successfully.
  • the server may include a transaction scheduling processor, a query, an executor, and a garbage collection component to implement the above transaction processing method.
  • the transaction scheduling process receives instructions such as transaction startup requests, and also periodically instructs the garbage collection component to clean up useless data;
  • the query is used to parse the received startup requests and other statements;
  • the executor executes the storage layer based on the parsed statements. Perform corresponding operations on the data in the database, such as creating a new differential version or merging the data during the data acquisition process.
  • any one of the online transaction processing method, the command line transaction processing method, or the API (Application Programming Interface, Application Programming Interface) interface method can be used for implementation. See Figures 5, 6, and 7 respectively for schematic diagrams of operation interfaces obtained by implementing transaction processing in the above manner.
  • FIG. 5 is a schematic diagram of the online transaction processing interface. It includes the execution pages of two transactions.
  • the TID indicates the transaction number.
  • the transaction number is 1.
  • "insert data ⁇ v1> ⁇ value>"20" ⁇ ” is the instruction of the submitted transaction.
  • "The Result” is used to indicate the result of successful execution of the transaction.
  • Figure 6 is a schematic diagram of the command line transaction processing interface, which includes a start instruction for transaction number 4.
  • FIG. 7 is a schematic diagram of an interface for performing transaction processing through API calls.
  • FIG. 7 shows multiple transaction processing processes.
  • the transaction processing method provided by the embodiment of the present application determines the occupation type of the target data by the parallel second transaction based on the instruction information of the target data, and then executes the operations included in the first transaction based on the isolation level corresponding to the first transaction and the included operations. Operate on the target data to obtain the processing result of the first transaction.
  • This method does not require system calls to control parallel transactions to process the same data, avoids frequently falling into the operating system kernel state, improves transaction processing efficiency, and improves system throughput.
  • the application of differential version data in the embodiments of the present application reduces the storage space occupied by the data and improves the efficiency of updating the data.
  • An embodiment of the present application provides a transaction processing device, which is used to implement the transaction processing method shown in Figure 2.
  • the device includes but is not limited to:
  • the detection module 801 is used to detect whether the target data targeted by the first transaction is occupied by the second transaction.
  • the first transaction includes operations of processing the target data, and the second transaction is other transactions in parallel with the first transaction;
  • Execution module 802 configured to respond to the target data being occupied by the second transaction, and execute operations included in the first transaction to process the target data according to the occupation type of the target data by the second transaction and the type of operations included in the first transaction to process the target data. target data.
  • the detection module 801 is configured to read the indication information carried by the target data, where the indication information includes the transaction number of the transaction occupying the target data; based on the transaction number included in the indication information, it is the transaction number of the second transaction. , then it is determined that the target data is occupied by the second transaction.
  • the execution module 802 is configured to respond to the target data being occupied by the second transaction, and the operation of processing the target data included in the first transaction is an update operation, then when the processing result of the second transaction is After submission, the target data is updated according to the operations included in the first transaction; in response to the target data being occupied by the second transaction, and the operation included in the first transaction to process the target data is a read operation, the target data is updated according to the second transaction.
  • the occupation type and the first transaction include operations that read the target data.
  • the execution module 802 is configured to determine the occupation type of the target data by the second transaction; in response to the occupation type indication, during the process of the second transaction occupying the target data, prohibit other transactions except the second transaction.
  • the included operations update and read the target data.
  • the operations included in the first transaction are executed to read the target data according to the isolation level of the first transaction.
  • the isolation level of the first transaction is used A read rule corresponding to an operation of reading target data included in the first transaction.
  • the operation of processing the target data included in the first transaction is an update operation.
  • the execution module 802 is used to set instruction information of the target data.
  • the instruction information includes the transaction number and occupation type of the first transaction. The type indicates that during the process of executing the operations included in the first transaction to update the target data, it is prohibited to execute the operations of reading or updating the target data included in other transactions; the operations included in the first transaction are executed to update the target data.
  • the operation of processing the target data included in the first transaction is a read operation
  • the isolation level of the first transaction is serializable
  • the execution module 802 is used to set the instruction information of the target data, indicating
  • the information includes the indication information including the transaction number and occupancy type of the first transaction.
  • the occupancy type indicates that during the process of executing the operations included in the first transaction to read the target data, it is prohibited to perform the operations of updating the target data included in other transactions; executing the first A transaction includes operations to read target data.
  • the first transaction includes multiple operations, each operation is directed to the corresponding target data, the first target data included in the multiple target data is occupied by the second transaction, and the multiple operations are arranged in execution order.
  • the execution module 802 is configured to respond to completing the submission of the processing result of the second transaction within the first time interval, and after the processing result of the second transaction is submitted, execute the first step of processing the first target data included in the first transaction.
  • Operation execute the operations included in the first transaction whose execution sequence is after the first operation; in response to the submission of the processing result of the second transaction not being completed within the first time interval, re-execute the first transaction after the first time interval
  • the operations included in the execution order are before the first operation; in response to completion of execution of the first operation, the first transaction includes the operations in the execution order after the first operation.
  • the isolation type of the first transaction is snapshot isolation
  • the operation included in the first transaction is to read the target version data corresponding to the target timestamp among the target data of multiple time versions, and the execution module 802, Data used to determine multiple differential versions of the target data.
  • the multiple differential versions include the differential version corresponding to the target timestamp and the differential version formed before the time corresponding to the target timestamp.
  • the differential version refers to the update operation pair included in any transaction.
  • the updated content of the target data merge the basic version of the target data and the data of multiple differential versions to obtain the target version data corresponding to the target timestamp in the target data of multiple data versions.
  • the device further includes:
  • the merging module is used to regularly merge the basic version of the target data and the differential version of the target data based on the merging time interval to obtain merged data.
  • the merged data is used to update the basic version of the target data.
  • the transaction processing device is used to execute the above transaction processing method without requiring system calls to control parallel transactions to process the same data, and can frequently fall into the operating system kernel state, thereby improving transaction processing efficiency and system throughput.
  • the application of differential version data reduces the storage space occupied by data and improves the efficiency of data update.
  • Embodiments of the present application provide a computer-readable storage medium in which at least one program code or instruction is stored.
  • the program code or instruction is loaded and executed by a processor, so that the computer implements the steps as described in the method embodiments. any of the transaction processing methods described above.
  • the above computer-readable storage medium may be read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), read-only compact disc (Compact Disc Read-Only Memory, CD-ROM) ), tapes, floppy disks and optical data storage devices, etc.
  • a computer program or computer program product is also provided. At least one computer instruction is stored in the computer program or computer program product, and the at least one computer instruction is loaded and executed by the processor, so that the computer implements Any of the above transaction processing methods.
  • FIG. 9 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device 900 may vary greatly due to different configurations or performance, and may include one or more processors (Central Processing Units, CPUs) 901 and one or more memories 902, wherein at least one program instruction is stored in the one or more memories 902, and the at least one program instruction is loaded and executed by the one or more processors 901 to implement each of the above method embodiments.
  • the electronic device 900 may also have components such as wired or wireless network interfaces, keyboards, and input and output interfaces for input and output.
  • the electronic device 900 may also include other components for realizing device functions, which will not be described again here.
  • the information including but not limited to user equipment information, user personal information, etc.
  • data including but not limited to data used for analysis, stored data, displayed data, etc.
  • signals involved in this application are all It is authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions. For example, the acquisition of target data involved in this application was obtained with full authorization.
  • the size of the sequence number of each process does not mean the order of execution.
  • the execution order of each process should be determined by its function and internal logic, and should not be used in the implementation of the embodiments of the present application.
  • the process constitutes any limitation.
  • determining B based on A does not mean determining B only based on A, and B can also be determined based on A and/or other information.
  • references throughout this specification to "one embodiment,” “an embodiment,” and “a possible implementation” mean that specific features, structures, or characteristics related to the embodiment or implementation are included herein. In at least one embodiment of the application. Therefore, “in one embodiment” or “in an embodiment” or “a possible implementation” appearing in various places throughout this specification do not necessarily refer to the same embodiment. Furthermore, the particular features, structures or characteristics may be combined in any suitable manner in one or more embodiments.

Landscapes

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

Abstract

Les modes de réalisation de la présente demande concernent un procédé et un appareil de traitement de transaction, ainsi qu'un dispositif électronique. Le procédé consiste : à détecter si des données cibles, ciblées par une première transaction, sont occupées par une seconde transaction, la première transaction comprenant une opération de traitement des données cibles et la seconde transaction étant une autre transaction qui est en parallèle à la première transaction ; et, en réponse au fait que les données cibles soient occupées par la seconde transaction et selon le type d'occupation des données cibles par la seconde transaction et le type de l'opération qui est comprise dans la première transaction et qui est utilisée pour traiter les données cibles, à exécuter l'opération comprise dans la première transaction de façon à traiter les données cibles. Au moyen des modes de réalisation de la présente demande, un appel de système n'est pas nécessaire pour commander des première et seconde transactions parallèles par rapport à un scénario où les mêmes données cibles sont traitées, ce qui permet d'éviter une implication fréquente dans un mode noyau d'un système d'exploitation, d'améliorer l'efficacité de traitement de transaction et d'augmenter le débit du système.
PCT/CN2022/144419 2022-05-07 2022-12-31 Procédé et appareil de traitement de transaction et dispositif électronique WO2023216636A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210495253.5A CN115292335A (zh) 2022-05-07 2022-05-07 事务处理方法、装置及电子设备
CN202210495253.5 2022-05-07

Publications (1)

Publication Number Publication Date
WO2023216636A1 true WO2023216636A1 (fr) 2023-11-16

Family

ID=83820230

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/144419 WO2023216636A1 (fr) 2022-05-07 2022-12-31 Procédé et appareil de traitement de transaction et dispositif électronique

Country Status (2)

Country Link
CN (1) CN115292335A (fr)
WO (1) WO2023216636A1 (fr)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115292335A (zh) * 2022-05-07 2022-11-04 北京大学 事务处理方法、装置及电子设备

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7269588B1 (en) * 2003-09-24 2007-09-11 Oracle International Corporation Neighborhood locking technique for increasing concurrency among transactions
CN104679881A (zh) * 2015-03-13 2015-06-03 华为技术有限公司 一种并发控制方法及装置
CN110888717A (zh) * 2019-11-05 2020-03-17 中盈优创资讯科技有限公司 Hdfs的目录操作的事务控制方法及装置
CN111475262A (zh) * 2020-04-02 2020-07-31 百度国际科技(深圳)有限公司 区块链中事务请求处理方法、装置、设备和介质
CN111984379A (zh) * 2020-07-14 2020-11-24 上海金仕达软件科技有限公司 读写事务控制方法、系统、终端设备及存储介质
CN112463311A (zh) * 2021-01-28 2021-03-09 腾讯科技(深圳)有限公司 事务处理方法、装置、计算机设备及存储介质
CN115292335A (zh) * 2022-05-07 2022-11-04 北京大学 事务处理方法、装置及电子设备

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7269588B1 (en) * 2003-09-24 2007-09-11 Oracle International Corporation Neighborhood locking technique for increasing concurrency among transactions
CN104679881A (zh) * 2015-03-13 2015-06-03 华为技术有限公司 一种并发控制方法及装置
CN110888717A (zh) * 2019-11-05 2020-03-17 中盈优创资讯科技有限公司 Hdfs的目录操作的事务控制方法及装置
CN111475262A (zh) * 2020-04-02 2020-07-31 百度国际科技(深圳)有限公司 区块链中事务请求处理方法、装置、设备和介质
CN111984379A (zh) * 2020-07-14 2020-11-24 上海金仕达软件科技有限公司 读写事务控制方法、系统、终端设备及存储介质
CN112463311A (zh) * 2021-01-28 2021-03-09 腾讯科技(深圳)有限公司 事务处理方法、装置、计算机设备及存储介质
CN115292335A (zh) * 2022-05-07 2022-11-04 北京大学 事务处理方法、装置及电子设备

Also Published As

Publication number Publication date
CN115292335A (zh) 2022-11-04

Similar Documents

Publication Publication Date Title
US11321303B2 (en) Conflict resolution for multi-master distributed databases
CN109739935B (zh) 数据读取方法、装置、电子设备以及存储介质
JP6346376B2 (ja) 拡張縮小可能なログベーストランザクション管理
CN111143389B (zh) 事务执行方法、装置、计算机设备及存储介质
WO2022161308A1 (fr) Procédé et appareil de traitement de transaction, dispositif informatique et support de stockage
EP3726365B1 (fr) Procédé et dispositif de traitement de données
US10250693B2 (en) Idempotence for database transactions
US9317372B1 (en) Dynamic membership management in a distributed system
US8364634B2 (en) System and method for processing fault tolerant transaction
US8924346B2 (en) Idempotence for database transactions
WO2022111188A1 (fr) Procédé de traitement de transaction, système, appareil, dispositif, support d'enregistrement et produit-programme
US6434710B1 (en) Commit controlling scheme for transaction processing in system utilizing check point/roll back scheme
WO2021036768A1 (fr) Procédé, appareil, dispositif informatique et support de stockage pour la lecture de données
CN110413687B (zh) 基于节点互证校验的分布式事务故障处理方法及相关设备
US20230110826A1 (en) Log execution method and apparatus, computer device and storage medium
CN109783578B (zh) 数据读取方法、装置、电子设备以及存储介质
CN113010549A (zh) 基于异地多活系统的数据处理方法、相关设备及存储介质
WO2023216636A1 (fr) Procédé et appareil de traitement de transaction et dispositif électronique
US11449241B2 (en) Customizable lock management for distributed resources
Zhou et al. GeoGauss: Strongly Consistent and Light-Coordinated OLTP for Geo-Replicated SQL Database
Yang et al. Natto: Providing distributed transaction prioritization for high-contention workloads
CN114846458A (zh) 分布式可串行化并发控制方案
Chhatrapati Towards Achieving Stronger Isolation in Serverless Computing
CN112084161A (zh) 基于数据库的数据处理方法、装置以及可读存储介质
JP2002297422A (ja) ネットワークシステム、主記憶常駐データの管理方法及び記憶媒体

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: 22941568

Country of ref document: EP

Kind code of ref document: A1