WO2023103990A1 - Database transaction snapshot generation method and apparatus, device, and storage medium - Google Patents

Database transaction snapshot generation method and apparatus, device, and storage medium Download PDF

Info

Publication number
WO2023103990A1
WO2023103990A1 PCT/CN2022/136680 CN2022136680W WO2023103990A1 WO 2023103990 A1 WO2023103990 A1 WO 2023103990A1 CN 2022136680 W CN2022136680 W CN 2022136680W WO 2023103990 A1 WO2023103990 A1 WO 2023103990A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
snapshot
management component
global
transaction management
Prior art date
Application number
PCT/CN2022/136680
Other languages
French (fr)
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 WO2023103990A1 publication Critical patent/WO2023103990A1/en

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/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
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/11File system administration, e.g. details of archiving or snapshots
    • G06F16/128Details of file system snapshots on the file-level, e.g. snapshot creation, administration, deletion
    • 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/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 embodiments of the present application relate to the field of databases, and in particular to a method, device, device, and storage medium for generating transaction snapshots of databases.
  • multiple global transaction managers are usually deployed to solve the problem of high concurrency pressure on each component or node in a load balancing manner.
  • multiple global transaction managers to share the concurrency pressure of the entire system, it also makes Multiple global transaction managers have difficulty producing globally consistent snapshots.
  • the main purpose of the embodiments of the present application is to provide a database transaction snapshot generation method, device, device and storage medium, so as to achieve accurate global consistent snapshot acquisition.
  • an embodiment of the present application provides a database transaction snapshot generation method, comprising: alternately obtaining the transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times; according to the The transaction number in the active state in the two adjacent transaction snapshots obtained by the first global transaction management component generates a transaction snapshot corresponding to the first global transaction management component; according to the transaction snapshot obtained from the second global transaction management component The transaction number in the active state in two adjacent transaction snapshots generates a transaction snapshot corresponding to the second global transaction management component; according to the transaction snapshot corresponding to the first global transaction management component and the second global transaction The transaction snapshot corresponding to the management component generates a global transaction snapshot.
  • a database transaction snapshot generation device including:
  • An acquisition module configured to alternately acquire transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times;
  • a first generating module configured to generate a transaction snapshot corresponding to the first global transaction management component according to the transaction number in an active state in two consecutive transaction snapshots obtained from the first global transaction management component;
  • the second generation module is configured to generate a transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the second global transaction management component;
  • the third generating module is configured to generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
  • an embodiment of the present application also provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, the memory stores information that can be used by the at least one processor An instruction executed by a processor, the instruction is executed by the at least one processor, so that the at least one processor can execute the above-mentioned method for generating a database transaction snapshot.
  • the embodiment of the present application also proposes a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above-mentioned method for generating a database transaction snapshot is realized.
  • a transaction snapshot generation method, device, device and storage medium of a database proposed by the present application obtain transaction snapshots of multiple global transaction management components at different times alternately, and generate a global transaction snapshot according to multiple transaction snapshots, so that the final The obtained global transaction snapshot can correct the transaction status that has changed within the generation time difference of multiple transaction snapshots.
  • the whole process can quickly and accurately obtain globally consistent snapshots.
  • Fig. 1a is a schematic diagram of the transaction state in the distributed database system provided by the embodiment of the present application.
  • Fig. 1b is a schematic diagram of a transaction snapshot in a distributed database system provided by an embodiment of the present application
  • Fig. 2 is the flow chart of the transaction snapshot generation method of the database that the embodiment of the present application provides;
  • FIG. 3 is a schematic structural diagram of a database transaction snapshot generation device provided by an embodiment of the present application.
  • FIG. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
  • the database transaction snapshot generation method of the present application is aimed at distributed databases.
  • a distributed database is logically a unified whole, and physically stored on different physical nodes.
  • An application can access databases distributed in different geographical locations through a network connection.
  • Distributed databases usually expand multiple computing nodes and storage nodes to handle massive data tasks.
  • multiple nodes or components processing tasks are prone to high concurrency pressure problems, and multiple global transaction managers are usually deployed. And use load balancing to reduce the concurrency pressure of each node or component. Deploying multiple global transaction managers brings the problem of difficulty in generating globally consistent snapshots.
  • the meaning of a global snapshot is the global state at a certain moment, and consistency means that for any event saved in the global snapshot, the events that occurred before this event should be saved in this snapshot. Simply put, the combination of the states of all transactions at the same time is a globally consistent snapshot.
  • the current global snapshot generation method has the following problems: as shown in Figure 1a, if two global transaction managers gtm1 and gtm2 are deployed in a distributed database system, the first global transaction manager (i.e. the first global transaction management component ) gtm1 is responsible for managing transaction 8, transaction 9, transaction 10 and transaction 11, the second global transaction manager gtm2 is responsible for managing transaction 91, transaction 92, transaction 93 and transaction 94, before T0 time, transaction 8, transaction 10 and transaction 91 Transaction 9, Transaction 11, Transaction 92, Transaction 93, and Transaction 94 are active transactions that have not been completed. If gtm1 receives a snapshot generation request at time T0, the snapshot obtained by gtm1 is shown in Figure 1b.
  • atomicity means that a transaction is an indivisible unit of work, and all operations included in the transaction are either executed or not executed.
  • Consistency means that the transaction must change the database from one consistent state to another consistent state.
  • the data inconsistency problem on the data fragmentation makes the corresponding transaction not meet the transaction attribute requirements.
  • this application alternately obtains the transaction snapshots of multiple global transaction management components at different times, and generates a global transaction snapshot according to the multiple transaction snapshots, so that the finally obtained global transaction snapshot can correct the changes that occur within the generation time difference of multiple transaction snapshots. transaction status.
  • the embodiment of the present application relates to a transaction snapshot generation method of a database, as shown in Figure 2, comprising:
  • Step 201 alternately acquire transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times.
  • step 201 specifically includes: sending a first snapshot generation request to the first global transaction management component, receiving the first transaction snapshot generated at the first moment fed back by the first global transaction management component;
  • the management component sends a second snapshot generation request, receives the second transaction snapshot generated at the second moment fed back by the second global transaction management component; sends the third snapshot generation request to the first global transaction management component, and receives the first global transaction management component Feedback of the third transaction snapshot generated at the third moment; sending a fourth snapshot generation request to the second global transaction management component, and receiving the fourth transaction snapshot generated at the fourth moment fed back by the second global transaction management component.
  • gtm1 generates a transaction snapshot at time T0
  • gtm2 generates a transaction snapshot at time T1
  • gtm1 generates another snapshot at time T2
  • gtm2 generates another snapshot at time T3.
  • alternate Get snapshots of transactions at different times are not limited to two global transaction management components, but can also target multiple global transaction management components.
  • the sending interval between the third snapshot generation request and the second snapshot generation request is greater than or equal to the time required for the second snapshot generation request to be sent to the second global transaction management component; the sending interval between the fourth snapshot generation request and the third snapshot generation request The time is greater than or equal to the time required for the third snapshot generation request to be sent to the first global transaction management component. In this way, it is guaranteed that the global transaction manager receives the next transaction snapshot generation request after obtaining the previous snapshot generation request.
  • the sending interval between the third snapshot generation request and the second snapshot generation request is the same as that between the fourth snapshot generation request and the third snapshot generation request. Snapshot generation requests are sent at equal intervals. In this way, while ensuring accurate acquisition of transaction snapshots, the acquisition efficiency is improved.
  • Step 202 Generate a transaction snapshot corresponding to the first global transaction management component according to an active transaction number in two consecutive transaction snapshots obtained from the first global transaction management component.
  • step 202 specifically includes: performing a logical AND operation on the transaction numbers in the active state in two consecutive transaction snapshots obtained from the first global transaction management component to obtain the transaction number corresponding to the first global transaction management component Transactional snapshots. That is to say, only when the same transaction is in the active state that has not ended in the two snapshots, is it confirmed that the transaction is in the active state that has not ended.
  • Step 203 Generate a transaction snapshot corresponding to the second global transaction management component according to an active transaction number in two consecutive transaction snapshots obtained from the second global transaction management component.
  • step 203 specifically includes: performing a logical AND operation on the transaction numbers in the active state in two consecutive transaction snapshots obtained from the second global transaction management component to obtain the transaction number corresponding to the second global transaction management component Transactional snapshots.
  • Step 204 Generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
  • step 204 specifically includes: numbering the transaction number in the active state in the transaction snapshot corresponding to the first global transaction management component, and the transaction number in the active state in the transaction snapshot corresponding to the second global transaction management component Merge to get a global transaction snapshot.
  • step 204 it also includes: backing up the data in each data fragment according to the global transaction snapshot.
  • the data in each data fragment can be backed up according to the status of each transaction in the global transaction snapshot.
  • a database transaction snapshot generation method proposed by this application by alternately obtaining transaction snapshots of multiple global transaction management components at different times, generating a global transaction snapshot according to multiple transaction snapshots, so that the final obtained global transaction snapshot can be corrected Transaction states that have changed within the time difference between multiple transaction snapshots.
  • the whole process can quickly and accurately obtain globally consistent snapshots.
  • the embodiment of the present application relates to a database transaction snapshot generation device, as shown in Figure 3, comprising:
  • An acquisition module 301 configured to alternately acquire transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times;
  • the first generation module 302 is configured to generate the transaction snapshot corresponding to the first global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the first global transaction management component;
  • the second generation module 303 is configured to generate a transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two consecutive transaction snapshots obtained from the second global transaction management component;
  • the third generating module 304 is configured to generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
  • This device embodiment is mainly aimed at the description of the database transaction snapshot generation method provided by the method embodiment at the software implementation level, and its implementation also needs to rely on hardware support.
  • the functions of related modules can be deployed on the processor, so that The processor runs to implement corresponding functions, especially, the data generated by the running can be stored in the memory for subsequent inspection and use.
  • modules involved in this embodiment are logical modules, and a logical unit may be a physical unit, or a part of a physical unit, or may be realized by a combination of multiple physical units.
  • a logical unit may be a physical unit, or a part of a physical unit, or may be realized by a combination of multiple physical units.
  • units that are not closely related to solving the technical problem proposed in the present application are not introduced in this embodiment, but this does not mean that there are no other units in this embodiment.
  • This embodiment is a device embodiment corresponding to the embodiment of the database transaction snapshot generation method, and this embodiment can be implemented in cooperation with the above-mentioned embodiments.
  • the relevant technical details mentioned in the foregoing embodiments are still valid in this embodiment, and will not be repeated here in order to reduce repetition.
  • the relevant technical details mentioned in this embodiment can also be applied to the above method embodiments.
  • the embodiment of the present application relates to an electronic device, as shown in FIG. 4 , including: at least one processor 401; Instructions executed by the at least one processor 401, the instructions are executed by the at least one processor 401, so that the at least one processor 401 can execute the data packet capture method in the foregoing implementation manner.
  • the memory and the processor are connected by a bus
  • the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory together.
  • the bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein.
  • the bus interface provides an interface between the bus and the transceivers.
  • a transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium.
  • the data processed by the processor is transmitted on the wireless medium through the antenna, further, the antenna also receives the data and transmits the data to the processor.
  • the processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory can be used to store data that the processor uses when performing operations.
  • Embodiments of the present application relate to a computer-readable storage medium storing a computer program.
  • the computer program is executed by the processor, the above-mentioned database transaction snapshot generation method is realized.
  • a storage medium includes several instructions to make a device ( It may be a single-chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .

Abstract

The present application relates to the field of databases, and provides a database transaction snapshot generation method and apparatus, a device, and a storage medium. The database transaction snapshot generation method comprises: alternately acquiring transaction snapshots generated by a first global transaction management component and a second global transaction management component at different moments, respectively; according to a transaction number in an active state in two adjacent transaction snapshots acquired from the first global transaction management component, generating a transaction snapshot corresponding to the first global transaction management component; according to a transaction number in the active state in two adjacent transaction snapshots acquired from the second global transaction management component, generating a transaction snapshot corresponding to the second global transaction management component; and generating a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.

Description

数据库的事务快照生成方法、装置、设备及存储介质Database transaction snapshot generation method, device, equipment and storage medium
相关申请related application
本申请要求于2021年12月10号申请的、申请号为202111509135.7的中国专利申请的优先权。This application claims the priority of the Chinese patent application with application number 202111509135.7 filed on December 10, 2021.
技术领域technical field
本申请实施例涉及数据库领域,特别涉及一种数据库的事务快照生成方法、装置、设备及存储介质。The embodiments of the present application relate to the field of databases, and in particular to a method, device, device, and storage medium for generating transaction snapshots of databases.
背景技术Background technique
在分布式数据库中,通常会部署多个全局事务管理器采用负载均衡的方式解决每个组件或节点并发压力大的问题,但是部署多个全局事务管理器分担整个系统并发压力的同时,也使得多个全局事务管理器难以生成全局一致性快照。In a distributed database, multiple global transaction managers are usually deployed to solve the problem of high concurrency pressure on each component or node in a load balancing manner. However, while deploying multiple global transaction managers to share the concurrency pressure of the entire system, it also makes Multiple global transaction managers have difficulty producing globally consistent snapshots.
发明内容Contents of the invention
本申请实施例的主要目的在于提出一种数据库的事务快照生成方法、装置、设备及存储介质,实现准确地获取全局一致性快照。The main purpose of the embodiments of the present application is to provide a database transaction snapshot generation method, device, device and storage medium, so as to achieve accurate global consistent snapshot acquisition.
为实现上述目的,本申请实施例提供了一种数据库的事务快照生成方法,包括:交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照;根据从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第一全局事务管理组件对应的事务快照;根据从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第二全局事务管理组件对应的事务快照;根据所述第一全局事务管理组件对应的事务快照和所述第二全局事务管理组件对应的事务快照,生成全局事务快照。In order to achieve the above purpose, an embodiment of the present application provides a database transaction snapshot generation method, comprising: alternately obtaining the transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times; according to the The transaction number in the active state in the two adjacent transaction snapshots obtained by the first global transaction management component generates a transaction snapshot corresponding to the first global transaction management component; according to the transaction snapshot obtained from the second global transaction management component The transaction number in the active state in two adjacent transaction snapshots generates a transaction snapshot corresponding to the second global transaction management component; according to the transaction snapshot corresponding to the first global transaction management component and the second global transaction The transaction snapshot corresponding to the management component generates a global transaction snapshot.
为实现上述目的,本申请实施例还提出了一种数据库的事务快照生成装置,包括:In order to achieve the above purpose, the embodiment of the present application also proposes a database transaction snapshot generation device, including:
获取模块,用于交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照;An acquisition module, configured to alternately acquire transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times;
第一生成模块,用于根据从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第一全局事务管理组件对应的事务快照;A first generating module, configured to generate a transaction snapshot corresponding to the first global transaction management component according to the transaction number in an active state in two consecutive transaction snapshots obtained from the first global transaction management component;
第二生成模块,用于根据从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第二全局事务管理组件对应的事务快照;The second generation module is configured to generate a transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the second global transaction management component;
第三生成模块,用于根据所述第一全局事务管理组件对应的事务快照和所述第二全局事务管理组件对应的事务快照,生成全局事务快照。The third generating module is configured to generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
为实现上述目的,本申请实施例还提出了一种电子设备,包括:至少一个处理器;以及,与所述至少一个处理器通信连接的存储器;其中,所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执 行以上所述的数据库的事务快照生成方法。To achieve the above purpose, an embodiment of the present application also provides an electronic device, including: at least one processor; and a memory connected to the at least one processor in communication; wherein, the memory stores information that can be used by the at least one processor An instruction executed by a processor, the instruction is executed by the at least one processor, so that the at least one processor can execute the above-mentioned method for generating a database transaction snapshot.
为实现上述目的,本申请实施例还提出了一种计算机可读存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现以上所述的数据库的事务快照生成方法。In order to achieve the above purpose, the embodiment of the present application also proposes a computer-readable storage medium storing a computer program, and when the computer program is executed by a processor, the above-mentioned method for generating a database transaction snapshot is realized.
本申请提出的一种数据库的事务快照生成方法、装置、设备及存储介质,通过交替获取多个全局事务管理组件分别在不同时刻的事务快照,根据多个事务快照生成一个全局事务快照,使得最终获取的全局事务快照能修正多个事务快照生成时间差内发生变更的事务状态。整个过程能够快速、准确地获取全局一致性快照。A transaction snapshot generation method, device, device and storage medium of a database proposed by the present application obtain transaction snapshots of multiple global transaction management components at different times alternately, and generate a global transaction snapshot according to multiple transaction snapshots, so that the final The obtained global transaction snapshot can correct the transaction status that has changed within the generation time difference of multiple transaction snapshots. The whole process can quickly and accurately obtain globally consistent snapshots.
附图说明Description of drawings
图1a是本申请的实施例提供的分布式数据库系统中事务状态示意图;Fig. 1a is a schematic diagram of the transaction state in the distributed database system provided by the embodiment of the present application;
图1b是本申请的实施例提供的分布式数据库系统中事务快照示意图;Fig. 1b is a schematic diagram of a transaction snapshot in a distributed database system provided by an embodiment of the present application;
图2是本申请的实施例提供的数据库的事务快照生成方法的流程图;Fig. 2 is the flow chart of the transaction snapshot generation method of the database that the embodiment of the present application provides;
图3是本申请的实施例提供的数据库的事务快照生成装置的结构示意图;FIG. 3 is a schematic structural diagram of a database transaction snapshot generation device provided by an embodiment of the present application;
图4是本申请的实施方式提供的电子设备的结构示意图。FIG. 4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application.
具体实施方式Detailed ways
为使本申请实施例的目的、技术方案和优点更加清楚,下面将结合附图对本申请的各实施例进行详细的阐述。然而,本领域的普通技术人员可以理解,在本申请各实施例中,为了使读者更好地理解本申请而提出了许多技术细节。但是,即使没有这些技术细节和基于以下各实施例的种种变化和修改,也可以实现本申请所要求保护的技术方案。以下各个实施例的划分是为了描述方便,不应对本申请的具体实现方式构成任何限定,各个实施例在不矛盾的前提下可以相互结合相互引用。In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the embodiments of the present application will be described in detail below with reference to the accompanying drawings. However, those of ordinary skill in the art can understand that in each embodiment of the application, many technical details are provided for readers to better understand the application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical solutions claimed in this application can also be realized. The division of the following embodiments is for the convenience of description, and should not constitute any limitation to the specific implementation of the present application, and the embodiments can be combined and referred to each other on the premise of no contradiction.
本申请的数据库的事务快照生成方法针对分布式数据库,一个分布式数据库在逻辑上是一个统一的整体,在物理上则是分别存储在不同的物理节点上。一个应用程序通过网络的连接可以访问分布在不同地理位置的数据库。分布式数据库通常会扩展多个计算节点和存储节点以便处理海量数据任务,在数据处理过程中多个节点或处理任务的组件很容易出现并发压力大的问题,通常会部署多个全局事务管理器并采用负载均衡的方式来降低每个节点或组件的并发压力。而部署多个全局事务管理器又带了难以生成全局一致性快照的问题。The database transaction snapshot generation method of the present application is aimed at distributed databases. A distributed database is logically a unified whole, and physically stored on different physical nodes. An application can access databases distributed in different geographical locations through a network connection. Distributed databases usually expand multiple computing nodes and storage nodes to handle massive data tasks. During data processing, multiple nodes or components processing tasks are prone to high concurrency pressure problems, and multiple global transaction managers are usually deployed. And use load balancing to reduce the concurrency pressure of each node or component. Deploying multiple global transaction managers brings the problem of difficulty in generating globally consistent snapshots.
全局快照的含义是某一时刻的全局状态,而一致性则指的是对于全局快照中保存的任何一个事件,在这个事件之前发生的事件应该保存在这次的快照中。简单地说,所有事务的状态在同一时刻的组合就是一个全局一致性快照。The meaning of a global snapshot is the global state at a certain moment, and consistency means that for any event saved in the global snapshot, the events that occurred before this event should be saved in this snapshot. Simply put, the combination of the states of all transactions at the same time is a globally consistent snapshot.
而目前的全局快照生成方法存在以下问题:如图1a所示,若一个分布式数据库系统中部署了两个全局事务管理器gtm1和gtm2,第一全局事务管理器(即第一全局事务管理组件)gtm1负责管理事务8、事务9、事务10和事务11,第二全局事务管理器gtm2负责管理事务91、事务92、事务93和事务94,在T0时刻之前,事务8、事务10和事务91为已经结束的非活跃事务,事务9、事务11、事务92、事务93和事务94为未结束的活跃事务。若T0时刻gtm1收到快照生成请求,那么gtm1获取的快照如图1b所示,类似地,T1时刻gtm2收到快照生成请求,那么gtm2获取的快照如图1b所示。将这两个快照合并则为整个系统的全局事务快照。但是结合图1a可以看到,由于gtm1和gtm2生成快照存在时间差,在T0到T1 的时间段内,gtm1的管理的事务状态已经发生了变化,即事务9已经从未结束的活跃事务变为了已经结束的非活跃事务。如此,导致最终获取的全局事务快照不符合一致性要求。However, the current global snapshot generation method has the following problems: as shown in Figure 1a, if two global transaction managers gtm1 and gtm2 are deployed in a distributed database system, the first global transaction manager (i.e. the first global transaction management component ) gtm1 is responsible for managing transaction 8, transaction 9, transaction 10 and transaction 11, the second global transaction manager gtm2 is responsible for managing transaction 91, transaction 92, transaction 93 and transaction 94, before T0 time, transaction 8, transaction 10 and transaction 91 Transaction 9, Transaction 11, Transaction 92, Transaction 93, and Transaction 94 are active transactions that have not been completed. If gtm1 receives a snapshot generation request at time T0, the snapshot obtained by gtm1 is shown in Figure 1b. Similarly, when gtm2 receives a snapshot generation request at T1, the snapshot obtained by gtm2 is shown in Figure 1b. Merge these two snapshots into a global transactional snapshot of the entire system. However, combined with Figure 1a, it can be seen that due to the time difference between gtm1 and gtm2 to generate snapshots, during the time period from T0 to T1, the transaction status managed by gtm1 has changed, that is, transaction 9 has changed from an active transaction that has never ended to a completed transaction. Ended inactive transaction. In this way, the final obtained global transaction snapshot does not meet the consistency requirements.
在一实施例中,若使用不符合一致性要求的全局事务快照进行数据备份时,很容易导致数据分片上的数据出现不一致问题。需要说明的是,在分布式数据库系统中,一个事务包含的多个操作通常分布在多个数据分片上进行,而事务应该具有四个属性:原子性、一致性、隔离性和持久性。其中,原子性是指一个事务是一个不可分割的工作单位,事务中包括的所有操作要么都执行、要么都不执行。一致性是指事务必须是使数据库从一个一致性状态变到另一个一致性状态。而数据分片上的数据不一致问题使得对应的事务不满足事务属性要求。In one embodiment, if the global transaction snapshot that does not meet the consistency requirements is used for data backup, it is easy to cause data inconsistency on the data shards. It should be noted that in a distributed database system, multiple operations contained in a transaction are usually distributed across multiple data shards, and a transaction should have four attributes: atomicity, consistency, isolation, and durability. Among them, atomicity means that a transaction is an indivisible unit of work, and all operations included in the transaction are either executed or not executed. Consistency means that the transaction must change the database from one consistent state to another consistent state. However, the data inconsistency problem on the data fragmentation makes the corresponding transaction not meet the transaction attribute requirements.
另外,通过全局一致性快照还可以对系统中的故障进行检查恢复,还可以检查当前应用是否存在死锁问题。这些都需要在能获取到准确的全局一致性快照基础上实现。In addition, through globally consistent snapshots, it is also possible to check and recover from faults in the system, and it is also possible to check whether there is a deadlock problem in the current application. All of these need to be realized on the basis of obtaining accurate global consistent snapshots.
而本申请通过交替获取多个全局事务管理组件分别在不同时刻的事务快照,根据多个事务快照生成一个全局事务快照,使得最终获取的全局事务快照能修正多个事务快照生成时间差内发生变更的事务状态。However, this application alternately obtains the transaction snapshots of multiple global transaction management components at different times, and generates a global transaction snapshot according to the multiple transaction snapshots, so that the finally obtained global transaction snapshot can correct the changes that occur within the generation time difference of multiple transaction snapshots. transaction status.
本申请的实施例涉及一种数据库的事务快照生成方法,如图2所示,包括:The embodiment of the present application relates to a transaction snapshot generation method of a database, as shown in Figure 2, comprising:
步骤201,交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照。 Step 201, alternately acquire transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times.
在本实施例中,步骤201具体包括:向第一全局事务管理组件发送第一快照生成请求,接收第一全局事务管理组件反馈的在第一时刻生成的第一事务快照;向第二全局事务管理组件发送第二快照生成请求,接收第二全局事务管理组件反馈的在第二时刻生成的第二事务快照;向第一全局事务管理组件发送第三快照生成请求,接收第一全局事务管理组件反馈的在第三时刻生成的第三事务快照;向第二全局事务管理组件发送第四快照生成请求,接收第二全局事务管理组件反馈的在第四时刻生成的第四事务快照。比如:以两个全局事务管理组件gtm1和gtm2为例,T0时刻gtm1生成事务快照,T1时刻gtm2生成事务快照,T2时刻gtm1再生成一份快照,T3时刻gtm2再生成一份快照,如此,可完成交替获取不同时刻的事务快照。当然,本申请的事务快照生成方法不仅限于两个全局事务管理组件,也可以针对多个全局事务管理组件。In this embodiment, step 201 specifically includes: sending a first snapshot generation request to the first global transaction management component, receiving the first transaction snapshot generated at the first moment fed back by the first global transaction management component; The management component sends a second snapshot generation request, receives the second transaction snapshot generated at the second moment fed back by the second global transaction management component; sends the third snapshot generation request to the first global transaction management component, and receives the first global transaction management component Feedback of the third transaction snapshot generated at the third moment; sending a fourth snapshot generation request to the second global transaction management component, and receiving the fourth transaction snapshot generated at the fourth moment fed back by the second global transaction management component. For example, taking two global transaction management components gtm1 and gtm2 as an example, gtm1 generates a transaction snapshot at time T0, gtm2 generates a transaction snapshot at time T1, gtm1 generates another snapshot at time T2, and gtm2 generates another snapshot at time T3. In this way, alternate Get snapshots of transactions at different times. Of course, the method for generating transaction snapshots in this application is not limited to two global transaction management components, but can also target multiple global transaction management components.
第三快照生成请求与第二快照生成请求的发送间隔时间大于或等于第二快照生成请求发送至第二全局事务管理组件所需的时间;第四快照生成请求与第三快照生成请求的发送间隔时间大于或等于第三快照生成请求发送至第一全局事务管理组件所需的时间。如此,保证全局事务管理器在获取到上一个快照生成请求后,在接收下一个事务快照生成请求。The sending interval between the third snapshot generation request and the second snapshot generation request is greater than or equal to the time required for the second snapshot generation request to be sent to the second global transaction management component; the sending interval between the fourth snapshot generation request and the third snapshot generation request The time is greater than or equal to the time required for the third snapshot generation request to be sent to the first global transaction management component. In this way, it is guaranteed that the global transaction manager receives the next transaction snapshot generation request after obtaining the previous snapshot generation request.
另外,第一全局事务管理组件和所述第二全局事务管理组件部署于同一物理设备的情况下,第三快照生成请求与第二快照生成请求的发送间隔时间与第四快照生成请求与第三快照生成请求的发送间隔时间相等。如此,在保证事务快照准确获取的同时,提高获取效率。In addition, when the first global transaction management component and the second global transaction management component are deployed on the same physical device, the sending interval between the third snapshot generation request and the second snapshot generation request is the same as that between the fourth snapshot generation request and the third snapshot generation request. Snapshot generation requests are sent at equal intervals. In this way, while ensuring accurate acquisition of transaction snapshots, the acquisition efficiency is improved.
步骤202,根据从第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成第一全局事务管理组件对应的事务快照。Step 202: Generate a transaction snapshot corresponding to the first global transaction management component according to an active transaction number in two consecutive transaction snapshots obtained from the first global transaction management component.
在本实施例中,步骤202具体包括:将从第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号进行逻辑与操作,得到第一全局事务管理组件对应的事务快照。也就是说,在两份快照中同一事务都处于未结束的活跃状态时,才确认该事务为未结束的活跃状态。In this embodiment, step 202 specifically includes: performing a logical AND operation on the transaction numbers in the active state in two consecutive transaction snapshots obtained from the first global transaction management component to obtain the transaction number corresponding to the first global transaction management component Transactional snapshots. That is to say, only when the same transaction is in the active state that has not ended in the two snapshots, is it confirmed that the transaction is in the active state that has not ended.
步骤203,根据从第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成第二全局事务管理组件对应的事务快照。Step 203: Generate a transaction snapshot corresponding to the second global transaction management component according to an active transaction number in two consecutive transaction snapshots obtained from the second global transaction management component.
在本实施例中,步骤203具体包括:将从第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号进行逻辑与操作,得到第二全局事务管理组件对应的事务快照。In this embodiment, step 203 specifically includes: performing a logical AND operation on the transaction numbers in the active state in two consecutive transaction snapshots obtained from the second global transaction management component to obtain the transaction number corresponding to the second global transaction management component Transactional snapshots.
步骤204,根据第一全局事务管理组件对应的事务快照和第二全局事务管理组件对应的事务快照,生成全局事务快照。Step 204: Generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
在本实施例中,步骤204具体包括:将第一全局事务管理组件对应的事务快照中的处于活跃状态的事务编号,与第二全局事务管理组件对应的事务快照中的处于活跃状态的事务编号进行合并,得到全局事务快照。In this embodiment, step 204 specifically includes: numbering the transaction number in the active state in the transaction snapshot corresponding to the first global transaction management component, and the transaction number in the active state in the transaction snapshot corresponding to the second global transaction management component Merge to get a global transaction snapshot.
另外,步骤204之后,还包括:根据全局事务快照对各数据分片中的数据进行备份。本实施例中,根据全局事务快照中每个事务的状态可以对各数据分片中的数据进行备份。本领域技术人员可以理解的是,一个事务包含的多个操作通常在多个数据分片上执行。In addition, after step 204, it also includes: backing up the data in each data fragment according to the global transaction snapshot. In this embodiment, the data in each data fragment can be backed up according to the status of each transaction in the global transaction snapshot. Those skilled in the art can understand that multiple operations included in a transaction are usually executed on multiple data shards.
本申请提出的一种数据库的事务快照生成方法,通过交替获取多个全局事务管理组件分别在不同时刻的事务快照,根据多个事务快照生成一个全局事务快照,使得最终获取的全局事务快照能修正多个事务快照生成时间差内发生变更的事务状态。整个过程能够快速、准确地获取全局一致性快照。A database transaction snapshot generation method proposed by this application, by alternately obtaining transaction snapshots of multiple global transaction management components at different times, generating a global transaction snapshot according to multiple transaction snapshots, so that the final obtained global transaction snapshot can be corrected Transaction states that have changed within the time difference between multiple transaction snapshots. The whole process can quickly and accurately obtain globally consistent snapshots.
此外,应当理解的是,上面各种方法的步骤划分,只是为了描述清楚,实现时可以合并为一个步骤或者对某些步骤进行拆分,分解为多个步骤,只要包括相同的逻辑关系,都在本申请的保护范围内;对流程中添加无关紧要的修改或者引入无关紧要的设计,但不改变其流程的核心设计都在该申请的保护范围内。In addition, it should be understood that the division of steps in the above methods is only for clarity of description, and may be combined into one step or split into multiple steps during implementation. As long as the same logical relationship is included, all Within the scope of protection of this application; adding insignificant modifications to the process or introducing insignificant designs without changing the core design of the process is within the scope of protection of this application.
本申请的实施例涉及一种数据库的事务快照生成装置,如图3所示,包括:The embodiment of the present application relates to a database transaction snapshot generation device, as shown in Figure 3, comprising:
获取模块301,用于交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照;An acquisition module 301, configured to alternately acquire transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times;
第一生成模块302,用于根据从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第一全局事务管理组件对应的事务快照;The first generation module 302 is configured to generate the transaction snapshot corresponding to the first global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the first global transaction management component;
第二生成模块303,用于根据从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第二全局事务管理组件对应的事务快照;The second generation module 303 is configured to generate a transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two consecutive transaction snapshots obtained from the second global transaction management component;
第三生成模块304,用于根据所述第一全局事务管理组件对应的事务快照和所述第二全局事务管理组件对应的事务快照,生成全局事务快照。The third generating module 304 is configured to generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
本装置实施例主要是针对方法实施例提供的数据库的事务快照生成方法在软件实现层面上的描述,其实现还需要依托于硬件的支持,如相关模块的功能可以被部署到处理器上,以便处理器运行实现相应的功能,特别地,运行产生的数据可以被存储到存储器中以便后续检查和使用。This device embodiment is mainly aimed at the description of the database transaction snapshot generation method provided by the method embodiment at the software implementation level, and its implementation also needs to rely on hardware support. For example, the functions of related modules can be deployed on the processor, so that The processor runs to implement corresponding functions, especially, the data generated by the running can be stored in the memory for subsequent inspection and use.
本实施例中所涉及到的各模块均为逻辑模块,一个逻辑单元可以是一个物理单元,也可以是一个物理单元的一部分,还可以以多个物理单元的组合实现。此外,为了突出本申请的创新部分,本实施例中并没有将与解决本申请所提出的技术问题关系不太密切的单元引入,但这并不表明本实施例中不存在其它的单元。All the modules involved in this embodiment are logical modules, and a logical unit may be a physical unit, or a part of a physical unit, or may be realized by a combination of multiple physical units. In addition, in order to highlight the innovative part of the present application, units that are not closely related to solving the technical problem proposed in the present application are not introduced in this embodiment, but this does not mean that there are no other units in this embodiment.
本实施例为与数据库的事务快照生成方法实施例相对应的装置实施例,本实施例可与上 述实施例互相配合实施。上述实施例中提到的相关技术细节在本实施例中依然有效,为了减少重复,这里不再赘述。相应地,本实施例中提到的相关技术细节也可应用在上述方法实施例中。This embodiment is a device embodiment corresponding to the embodiment of the database transaction snapshot generation method, and this embodiment can be implemented in cooperation with the above-mentioned embodiments. The relevant technical details mentioned in the foregoing embodiments are still valid in this embodiment, and will not be repeated here in order to reduce repetition. Correspondingly, the relevant technical details mentioned in this embodiment can also be applied to the above method embodiments.
本申请的实施方式涉及一种电子设备,如图4所示,包括:至少一个处理器401;以及,与所述至少一个处理器401通信连接的存储器402;其中,所述存储器402存储有可被所述至少一个处理器401执行的指令,所述指令被所述至少一个处理器401执行,以使所述至少一个处理器401能够执行上述实施方式的数据抓包方法。The embodiment of the present application relates to an electronic device, as shown in FIG. 4 , including: at least one processor 401; Instructions executed by the at least one processor 401, the instructions are executed by the at least one processor 401, so that the at least one processor 401 can execute the data packet capture method in the foregoing implementation manner.
其中,存储器和处理器采用总线方式连接,总线可以包括任意数量的互联的总线和桥,总线将一个或多个处理器和存储器的各种电路连接在一起。总线还可以将诸如外围设备、稳压器和功率管理电路等之类的各种其他电路连接在一起,这些都是本领域所公知的,因此,本文不再对其进行进一步描述。总线接口在总线和收发机之间提供接口。收发机可以是一个元件,也可以是多个元件,比如多个接收器和发送器,提供用于在传输介质上与各种其他装置通信的单元。经处理器处理的数据通过天线在无线介质上进行传输,进一步,天线还接收数据并将数据传送给处理器。Wherein, the memory and the processor are connected by a bus, and the bus may include any number of interconnected buses and bridges, and the bus connects one or more processors and various circuits of the memory together. The bus may also connect together various other circuits such as peripherals, voltage regulators, and power management circuits, all of which are well known in the art and therefore will not be further described herein. The bus interface provides an interface between the bus and the transceivers. A transceiver may be a single element or multiple elements, such as multiple receivers and transmitters, providing means for communicating with various other devices over a transmission medium. The data processed by the processor is transmitted on the wireless medium through the antenna, further, the antenna also receives the data and transmits the data to the processor.
处理器负责管理总线和通常的处理,还可以提供各种功能,包括定时,外围接口,电压调节、电源管理以及其他控制功能。而存储器可以被用于存储处理器在执行操作时所使用的数据。The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interface, voltage regulation, power management, and other control functions. Instead, memory can be used to store data that the processor uses when performing operations.
本申请的实施方式涉及一种计算机可读存储介质,存储有计算机程序。计算机程序被处理器执行时实现上述数据库的事务快照生成方法。Embodiments of the present application relate to a computer-readable storage medium storing a computer program. When the computer program is executed by the processor, the above-mentioned database transaction snapshot generation method is realized.
即,本领域技术人员可以理解,实现上述实施方式方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施方式所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。That is, those skilled in the art can understand that all or part of the steps in the method of the above-mentioned embodiments can be completed by instructing related hardware through a program, the program is stored in a storage medium, and includes several instructions to make a device ( It may be a single-chip microcomputer, a chip, etc.) or a processor (processor) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disc, etc., which can store program codes. .
本领域的普通技术人员可以理解,上述各实施例是实现本申请的具体实施例,而在实际应用中,可以在形式上和细节上对其作各种改变,而不偏离本申请的精神和范围。Those of ordinary skill in the art can understand that the above-mentioned embodiments are specific embodiments for realizing the present application, and in practical applications, various changes can be made to it in form and details without departing from the spirit and spirit of the present application. scope.

Claims (10)

  1. 一种数据库的事务快照生成方法,包括:A database transaction snapshot generation method, comprising:
    交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照;Alternately acquiring transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times;
    根据从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第一全局事务管理组件对应的事务快照;Generate a transaction snapshot corresponding to the first global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the first global transaction management component;
    根据从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第二全局事务管理组件对应的事务快照;Generate a transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the second global transaction management component;
    根据所述第一全局事务管理组件对应的事务快照和所述第二全局事务管理组件对应的事务快照,生成全局事务快照。A global transaction snapshot is generated according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
  2. 根据权利要求1所述的数据库的事务快照生成方法,其中,所述根据从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第一全局事务管理组件对应的事务快照,包括:The method for generating a transaction snapshot of a database according to claim 1, wherein said first transaction number is generated in an active state in two consecutive transaction snapshots obtained from said first global transaction management component. A transaction snapshot corresponding to a global transaction management component, including:
    将从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号进行逻辑与操作,得到所述第一全局事务管理组件对应的事务快照;performing a logical AND operation on the transaction numbers in the active state in the two adjacent transaction snapshots obtained from the first global transaction management component to obtain the transaction snapshot corresponding to the first global transaction management component;
    所述根据从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第二全局事务管理组件对应的事务快照,包括:The generating the transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the second global transaction management component includes:
    将从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号进行逻辑与操作,得到所述第二全局事务管理组件对应的事务快照。A logical AND operation is performed on transaction numbers in an active state in two adjacent transaction snapshots obtained from the second global transaction management component to obtain a transaction snapshot corresponding to the second global transaction management component.
  3. 根据权利要求2所述的数据库的事务快照生成方法,其中,所述根据所述第一全局事务管理组件对应的事务快照和所述第二全局事务管理组件对应的事务快照,生成全局事务快照,包括:The method for generating a transaction snapshot of a database according to claim 2, wherein the global transaction snapshot is generated according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component, include:
    将所述第一全局事务管理组件对应的事务快照中的处于活跃状态的事务编号,与所述第二全局事务管理组件对应的事务快照中的处于活跃状态的事务编号进行合并,得到所述全局事务快照。Merging the transaction number in the active state in the transaction snapshot corresponding to the first global transaction management component with the transaction number in the active state in the transaction snapshot corresponding to the second global transaction management component to obtain the global Transactional snapshots.
  4. 根据权利要求1至3中任一项所述的数据库的事务快照生成方法,其中,所述交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照,包括:The method for generating a transaction snapshot of a database according to any one of claims 1 to 3, wherein said alternately obtaining the transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times respectively comprises:
    向所述第一全局事务管理组件发送第一快照生成请求,接收所述第一全局事务管理组件反馈的在第一时刻生成的第一事务快照;Sending a first snapshot generation request to the first global transaction management component, and receiving the first transaction snapshot generated at the first moment fed back by the first global transaction management component;
    向所述第二全局事务管理组件发送第二快照生成请求,接收所述第二全局事务管理组件反馈的在第二时刻生成的第二事务快照;Send a second snapshot generation request to the second global transaction management component, and receive a second transaction snapshot generated at a second moment fed back by the second global transaction management component;
    向所述第一全局事务管理组件发送第三快照生成请求,接收所述第一全局事务管理组件反馈的在第三时刻生成的第三事务快照;Send a third snapshot generation request to the first global transaction management component, and receive a third transaction snapshot generated at a third moment fed back by the first global transaction management component;
    向所述第二全局事务管理组件发送第四快照生成请求,接收所述第二全局事务管理组件反馈的在第四时刻生成的第四事务快照。Sending a fourth snapshot generation request to the second global transaction management component, and receiving a fourth transaction snapshot generated at a fourth moment fed back by the second global transaction management component.
  5. 根据权利要求4所述的数据库的事务快照生成方法,其中,所述第三快照生成请求与所述第二快照生成请求的发送间隔时间大于或等于所述第二快照生成请求发送至所述第二全局事务管理组件所需的时间;The transaction snapshot generation method for a database according to claim 4, wherein the interval between sending the third snapshot generation request and the second snapshot generation request is greater than or equal to the second snapshot generation request sent to the second snapshot generation request 2. The time required by the global transaction management component;
    所述第四快照生成请求与所述第三快照生成请求的发送间隔时间大于或等于所述第三快照生成请求发送至所述第一全局事务管理组件所需的时间。The interval between sending the fourth snapshot generation request and the third snapshot generation request is greater than or equal to the time required for the third snapshot generation request to be sent to the first global transaction management component.
  6. 根据权利要求5所述的数据库的事务快照生成方法,其中,在所述第一全局事务管理组件和所述第二全局事务管理组件部署于同一物理设备的情况下,所述第三快照生成请求与所述第二快照生成请求的发送间隔时间与所述第四快照生成请求与所述第三快照生成请求的发送间隔时间相等。The transaction snapshot generation method of a database according to claim 5, wherein, when the first global transaction management component and the second global transaction management component are deployed on the same physical device, the third snapshot generation request An interval between sending the second snapshot generation request and an interval between sending the fourth snapshot generation request and the third snapshot generation request is equal.
  7. 根据权利要求1至3中任一项所述的数据库的事务快照生成方法,其中,在所述生成全局事务快照后,还包括:The method for generating a transactional snapshot of a database according to any one of claims 1 to 3, wherein, after said generating the global transactional snapshot, further comprising:
    根据所述全局事务快照对各数据分片中的数据进行备份。The data in each data fragment is backed up according to the global transaction snapshot.
  8. 一种数据库的事务快照生成装置,包括:A database transaction snapshot generating device, comprising:
    获取模块,设置为交替获取第一全局事务管理组件和第二全局事务管理组件分别在不同时刻生成的事务快照;The obtaining module is configured to alternately obtain transaction snapshots generated by the first global transaction management component and the second global transaction management component at different times;
    第一生成模块,设置为根据从所述第一全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第一全局事务管理组件对应的事务快照;The first generation module is configured to generate the transaction snapshot corresponding to the first global transaction management component according to the transaction number in the active state in two consecutive transaction snapshots obtained from the first global transaction management component;
    第二生成模块,设置为根据从所述第二全局事务管理组件获取的相邻两次的事务快照中的处于活跃状态的事务编号,生成所述第二全局事务管理组件对应的事务快照;The second generation module is configured to generate the transaction snapshot corresponding to the second global transaction management component according to the transaction number in the active state in two adjacent transaction snapshots obtained from the second global transaction management component;
    第三生成模块,设置为根据所述第一全局事务管理组件对应的事务快照和所述第二全局事务管理组件对应的事务快照,生成全局事务快照。The third generation module is configured to generate a global transaction snapshot according to the transaction snapshot corresponding to the first global transaction management component and the transaction snapshot corresponding to the second global transaction management component.
  9. 一种电子设备,包括:An electronic device comprising:
    至少一个处理器;以及,at least one processor; and,
    与所述至少一个处理器通信连接的存储器;其中,a memory communicatively coupled to the at least one processor; wherein,
    所述存储器存储有可被所述至少一个处理器执行的指令,所述指令被所述至少一个处理器执行,以使所述至少一个处理器能够执行如权利要求1至7中任一项所述的数据库的事务快照生成方法。The memory stores instructions executable by the at least one processor, the instructions are executed by the at least one processor, so that the at least one processor can perform the operation described in any one of claims 1 to 7 The transaction snapshot generation method of the database described above.
  10. 一种计算机可读存储介质,存储有计算机程序,其中,所述计算机程序被处理器执行时实现权利要求1至7中任一项所述的数据库的事务快照生成方法。A computer-readable storage medium storing a computer program, wherein, when the computer program is executed by a processor, the method for generating a database transaction snapshot according to any one of claims 1 to 7 is implemented.
PCT/CN2022/136680 2021-12-10 2022-12-05 Database transaction snapshot generation method and apparatus, device, and storage medium WO2023103990A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111509135.7A CN116303754A (en) 2021-12-10 2021-12-10 Transaction snapshot generation method, device and equipment of database and storage medium
CN202111509135.7 2021-12-10

Publications (1)

Publication Number Publication Date
WO2023103990A1 true WO2023103990A1 (en) 2023-06-15

Family

ID=86729618

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/136680 WO2023103990A1 (en) 2021-12-10 2022-12-05 Database transaction snapshot generation method and apparatus, device, and storage medium

Country Status (2)

Country Link
CN (1) CN116303754A (en)
WO (1) WO2023103990A1 (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130124475A1 (en) * 2011-11-16 2013-05-16 Sap Ag System and Method of Performing Snapshot Isolation in Distributed Databases
CN104885054A (en) * 2013-03-13 2015-09-02 华为技术有限公司 System and method for performing a transaction in a massively parallel processing database
CN105684377A (en) * 2013-10-31 2016-06-15 华为技术有限公司 System and method for creating a distributed transaction manager supporting repeatable read isolation level in a mpp database
CN107045454A (en) * 2016-02-06 2017-08-15 华为技术有限公司 Striding course distributed transaction control method and related system
CN112069258A (en) * 2020-09-08 2020-12-11 北京金山云网络技术有限公司 Management method and device of transaction progress and distributed database
CN113495872A (en) * 2020-04-08 2021-10-12 北京万里开源软件有限公司 Transaction processing method and system in distributed database

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130124475A1 (en) * 2011-11-16 2013-05-16 Sap Ag System and Method of Performing Snapshot Isolation in Distributed Databases
CN104885054A (en) * 2013-03-13 2015-09-02 华为技术有限公司 System and method for performing a transaction in a massively parallel processing database
CN105684377A (en) * 2013-10-31 2016-06-15 华为技术有限公司 System and method for creating a distributed transaction manager supporting repeatable read isolation level in a mpp database
CN107045454A (en) * 2016-02-06 2017-08-15 华为技术有限公司 Striding course distributed transaction control method and related system
CN113495872A (en) * 2020-04-08 2021-10-12 北京万里开源软件有限公司 Transaction processing method and system in distributed database
CN112069258A (en) * 2020-09-08 2020-12-11 北京金山云网络技术有限公司 Management method and device of transaction progress and distributed database

Also Published As

Publication number Publication date
CN116303754A (en) 2023-06-23

Similar Documents

Publication Publication Date Title
EP2932370B1 (en) System and method for performing a transaction in a massively parallel processing database
EP2928160B1 (en) Idempotence for database transactions
Sciascia et al. Scalable deferred update replication
US8924346B2 (en) Idempotence for database transactions
EP2738698B1 (en) Locking protocol for partitioned and distributed tables
US11726984B2 (en) Data redistribution method and apparatus, and database cluster
CN113396407A (en) System and method for augmenting database applications using blockchain techniques
WO2017219857A1 (en) Data processing method and device
EP3958126A1 (en) Micro-service component-based database system and related method
CN104793988A (en) Cross-database distributed transaction implementation method and device
EP2954424B1 (en) Method, device, and system for peer-to-peer data replication and method, device, and system for master node switching
AU9782798A (en) Highly-available cluster configuration database
CN111753013A (en) Distributed transaction processing method and device
CN108989391B (en) Consistency processing method and system
CN111522631A (en) Distributed transaction processing method, device, server and medium
US20210034605A1 (en) Transaction processing for a database distributed across availability zones
CN115562911B (en) Virtual machine data backup method, device, system, electronic equipment and storage medium
WO2012083697A1 (en) Method and device for transaction recovery
US20230110826A1 (en) Log execution method and apparatus, computer device and storage medium
CN110427427B (en) Method for realizing global transaction distributed processing through pin bridging
US7752225B2 (en) Replication and mapping mechanism for recreating memory durations
CN109408201B (en) Transaction management method based on distributed database
WO2023103990A1 (en) Database transaction snapshot generation method and apparatus, device, and storage medium
Pankowski Consistency and availability of Data in replicated NoSQL databases
WO2021143039A1 (en) Method for determining data rollback period in distributed storage system

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

Country of ref document: EP

Kind code of ref document: A1