[go: up one dir, main page]

CN111488367A - Method, device and equipment for realizing data consistency and computer storage medium - Google Patents

Method, device and equipment for realizing data consistency and computer storage medium Download PDF

Info

Publication number
CN111488367A
CN111488367A CN202010303936.7A CN202010303936A CN111488367A CN 111488367 A CN111488367 A CN 111488367A CN 202010303936 A CN202010303936 A CN 202010303936A CN 111488367 A CN111488367 A CN 111488367A
Authority
CN
China
Prior art keywords
transaction
command
reverse
redis
context
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010303936.7A
Other languages
Chinese (zh)
Other versions
CN111488367B (en
Inventor
刘建波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202010303936.7A priority Critical patent/CN111488367B/en
Publication of CN111488367A publication Critical patent/CN111488367A/en
Application granted granted Critical
Publication of CN111488367B publication Critical patent/CN111488367B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06F16/2365Ensuring data consistency and integrity
    • 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/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating
    • 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
    • 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/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing

Landscapes

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

Abstract

The invention relates to the technical field of financial science and technology, and discloses a method, a device, equipment and a computer storage medium for realizing data consistency. The method comprises the following steps: when receiving an affair opening instruction, calling a preset API (application program interface) to generate an affair context; when a data write-in command is received, calling a preset API (application programming interface) to generate a corresponding forward transaction element and a corresponding reverse transaction element, and caching the forward transaction element and the reverse transaction element into a transaction context; when a transaction submitting instruction is received, packaging forward transaction elements cached in a transaction context into a Redis transaction, and submitting and executing the Redis transaction to a main node; when the execution is completed, calling a preset WAIT command to determine whether write-in data corresponding to the Redis transaction is successfully synchronized to the standby node; if the synchronization fails, a transaction rollback is performed based on the cached reverse transaction elements in the transaction context. The method and the device can ensure the consistency of the data in the Redis cluster when the information island occurs.

Description

数据一致性的实现方法、装置、设备及计算机存储介质Method, device, device and computer storage medium for realizing data consistency

技术领域technical field

本发明涉及金融科技(Fintech)技术领域,尤其涉及一种数据一致性的实现方法、装置、设备及计算机存储介质。The present invention relates to the technical field of financial technology (Fintech), and in particular, to a method, apparatus, device and computer storage medium for realizing data consistency.

背景技术Background technique

随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually transforming into financial technology (Fintech). requirements.

互联网银行的各种交易系统,都面临着大量的用户请求要处理。为了提升处理效率,通常会使用分布式的缓存技术来缓存产品、参数、用户等信息,而Redis(一种内存数据库)就是一种常用的分布式缓存技术。为保证Redis集群的高可用性,通常会采用Master/Slaves(主从式)的高可用集群部署模式,即:将1个Redis实例作为主节点Master,用于支持数据的写入和读取,进而将写入的数据同步到备节点中;将N个Redis实例作为备节点Slaves,当主节点因为软硬件异常而崩溃后,由Sentinels(哨兵,Redis的监控进程)选举1个备节点作为主节点继续服务。Various transaction systems of Internet banks are faced with a large number of user requests to be processed. In order to improve processing efficiency, distributed caching technology is usually used to cache products, parameters, users and other information, and Redis (an in-memory database) is a commonly used distributed caching technology. In order to ensure the high availability of the Redis cluster, the master/slaves (master-slave) high-availability cluster deployment mode is usually adopted, that is, one Redis instance is used as the master node Master to support data writing and reading, and then Synchronize the written data to the standby node; use N Redis instances as the standby node Slaves. When the master node crashes due to software and hardware exceptions, Sentinels (sentry, Redis monitoring process) elects a standby node as the master node to continue Serve.

但是,当主节点Master的网络因为某些事件中断时,备节点Slaves所对应的Sentinels会认为Master已经崩溃,进而选举其中一个Slave成为新的Master,并通知给应用实例。于是位于备节点上的应用实例将连接切换到新的Master上,继续读写;但位于旧Master上的应用实例是收不到通知的,于是旧的Master上的应用实例仍然连着旧的Master,继续读写。如此,Redis集群中便有了两个Master,分别由不同的应用实例对两个Master进行读写,集群中便出现了数据不一致的情况。当网络恢复之后,旧的Master回归到集群中,但只能是Slave身份,其所有数据都将会被新的Master数据覆盖,因此在断网后写入其中的数据,将全部丢失,从而出现交易虽然成功了、但是数据却丢失了的情况,因此,在主节点Master成为信息孤岛时,如何避免Redis集群中数据不一致的情况发生,是目前亟需解决的难题。However, when the network of the master node is interrupted due to some events, the Sentinels corresponding to the slave node slaves will think that the master has collapsed, and then elect one of the slaves to become the new master and notify the application instance. So the application instance on the standby node switches the connection to the new Master and continues to read and write; but the application instance on the old Master cannot receive the notification, so the application instance on the old Master is still connected to the old Master , continue reading and writing. In this way, there are two Masters in the Redis cluster, and different application instances read and write to the two Masters, and data inconsistency occurs in the cluster. When the network is restored, the old Master returns to the cluster, but it can only be the Slave identity, and all its data will be overwritten by the new Master data, so all the data written to it after the network is disconnected will be lost. Although the transaction is successful, the data is lost. Therefore, when the master node Master becomes an information island, how to avoid the occurrence of data inconsistency in the Redis cluster is a problem that needs to be solved urgently.

发明内容SUMMARY OF THE INVENTION

本发明的主要目的在于提供一种数据一致性的实现方法、装置、设备及计算机存储介质,旨在实现在出现信息孤岛的情况时,保证Redis集群中数据的一致性。The main purpose of the present invention is to provide a method, device, device and computer storage medium for realizing data consistency, aiming at ensuring the consistency of data in the Redis cluster when an isolated information island occurs.

为实现上述目的,本发明提供一种数据一致性的实现方法,所述数据一致性的实现方法包括:In order to achieve the above object, the present invention provides a method for realizing data consistency, which includes:

在接收到事务开启指令时,调用预设应用程序接口API生成事物上下文;When receiving the transaction opening instruction, call the preset application program interface API to generate the transaction context;

在接收到数据写入命令时,调用所述预设API生成与所述数据写入命令对应的正向事务元素和反向事务元素,并缓存至所述事务上下文中;When receiving a data write command, call the preset API to generate forward transaction elements and reverse transaction elements corresponding to the data write command, and cache them in the transaction context;

在接收到事务提交指令时,将所述事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行所述Redis事务;When receiving the transaction commit instruction, encapsulate the forward transaction element cached in the transaction context as a Redis transaction, and submit and execute the Redis transaction to the master node;

在执行完成时,调用预设等待WAIT命令,以确定所述Redis事务对应的写入数据是否成功同步至备节点上;When the execution is completed, the preset waiting WAIT command is called to determine whether the write data corresponding to the Redis transaction is successfully synchronized to the standby node;

若同步失败,则基于所述事务上下文中缓存的反向事务元素进行事务回滚。If synchronization fails, the transaction is rolled back based on the reverse transaction element cached in the transaction context.

可选地,所述在接收到事务提交指令时,将所述事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行所述Redis事务的步骤包括:Optionally, the step of encapsulating the forward transaction element cached in the transaction context into a Redis transaction when receiving a transaction commit instruction, and submitting and executing the Redis transaction to the master node includes:

在接收到事务提交指令时,通过WATCH命令对所述事务上下文中缓存的正向事务元素对应的第一键key进行监视,并通过MULTI命令开启第一命令队列;When receiving the transaction commit instruction, monitor the first key key corresponding to the forward transaction element cached in the transaction context through the WATCH command, and open the first command queue through the MULTI command;

将所述正向事务元素按照缓存顺序依次追加至所述第一命令队列中,封装得到Redis事务;The forward transaction elements are sequentially added to the first command queue according to the cache order, and the Redis transaction is obtained by encapsulation;

通过EXEC命令向主节点提交执行所述Redis事务。Submit and execute the Redis transaction to the master node through the EXEC command.

可选地,所述数据一致性的实现方法还包括:Optionally, the method for realizing data consistency further includes:

在接收到异常回滚指令时,调用所述预设API的回滚命令,清除所述第一命令队列中的命令并放弃执行。When an abnormal rollback command is received, the rollback command of the preset API is called, the commands in the first command queue are cleared, and execution is abandoned.

可选地,所述基于所述事务上下文中缓存的反向事务元素进行事务回滚的步骤包括:Optionally, the step of performing transaction rollback based on the reverse transaction element cached in the transaction context includes:

对所述事务上下文中缓存的反向事务元素对应的第二key施加锁,并通过MULTI命令开启第二命令队列;A lock is applied to the second key corresponding to the reverse transaction element cached in the transaction context, and the second command queue is opened by the MULTI command;

将所述反向事务元素按照缓存顺序倒序追加至所述第二命令队列中,封装得到回滚事务;appending the reverse transaction elements to the second command queue in reverse order according to the cache order, and encapsulating to obtain a rollback transaction;

通过EXEC命令向所述主节点提交执行所述回滚事务,以进行事务回滚。Submit and execute the rollback transaction to the master node through an EXEC command, so as to roll back the transaction.

可选地,所述对所述事务上下文中缓存的反向事务元素对应的第二key施加锁的步骤包括:Optionally, the step of applying a lock to the second key corresponding to the reverse transaction element cached in the transaction context includes:

通过SETNX命令对所述事务上下文中缓存的反向事务元素对应的第二key施加排他锁;或,Apply an exclusive lock to the second key corresponding to the reverse transaction element cached in the transaction context through the SETNX command; or,

通过WATCH命令对所述事务上下文中缓存的反向事务元素对应的第二key进行监视,以施加乐观锁。The second key corresponding to the reverse transaction element cached in the transaction context is monitored through the WATCH command to apply an optimistic lock.

可选地,所述事务上下文包括正向事务元素堆栈和反向事务元素堆栈,所述调用所述预设API生成与所述数据写入命令对应的正向事务元素和反向事务元素,并缓存至所述事务上下文中的步骤包括:Optionally, the transaction context includes a forward transaction element stack and a reverse transaction element stack, and the call to the preset API generates a forward transaction element and a reverse transaction element corresponding to the data write command, and The steps of caching into the transaction context include:

调用所述预设API生成与所述数据写入命令对应的正向事务元素,并根据预设映射关系生成与所述正向事务元素对应的反向事务元素;Calling the preset API to generate a forward transaction element corresponding to the data write command, and generating a reverse transaction element corresponding to the forward transaction element according to a preset mapping relationship;

将所述正向事务元素缓存至所述正向事务元素堆栈中,并将所述反向事务元素缓存至所述反向事务元素堆栈中。The forward transaction element is cached into the stack of forward transaction elements, and the reverse transaction element is cached into the stack of reverse transaction elements.

可选地,所述在执行完成时,调用预设等待WAIT命令,以确定所述Redis事务对应的写入数据是否成功同步至备节点上的步骤包括:Optionally, when the execution is completed, the step of invoking a preset waiting WAIT command to determine whether the write data corresponding to the Redis transaction is successfully synchronized to the standby node includes:

在执行完成时,调用预设等待WAIT命令,以获取预设时间内返回确认的备节点的数量;When the execution is completed, call the preset waiting WAIT command to obtain the number of standby nodes that return confirmation within the preset time;

判断所述数量是否大于或等于预设阈值;determine whether the number is greater than or equal to a preset threshold;

若所述数量小于预设阈值,则确定所述Redis事务对应的写入数据未成功同步至备节点上。If the number is less than the preset threshold, it is determined that the write data corresponding to the Redis transaction has not been successfully synchronized to the standby node.

此外,为实现上述目的,本发明还提供一种数据一致性的实现装置,所述数据一致性的实现装置包括:In addition, in order to achieve the above object, the present invention also provides a device for realizing data consistency, and the device for realizing data consistency includes:

生成模块,用于在接收到事务开启指令时,调用预设应用程序接口API生成事物上下文;The generation module is used to call the preset application program interface API to generate the transaction context when receiving the transaction opening instruction;

缓存模块,用于在接收到数据写入命令时,调用所述预设API生成与所述数据写入命令对应的正向事务元素和反向事务元素,并缓存至所述事务上下文中;a cache module, configured to call the preset API to generate forward transaction elements and reverse transaction elements corresponding to the data write command when receiving a data write command, and cache them in the transaction context;

封装模块,用于在接收到事务提交指令时,将所述事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行所述Redis事务;an encapsulation module, configured to encapsulate the forward transaction element cached in the transaction context into a Redis transaction when receiving a transaction commit instruction, and submit and execute the Redis transaction to the master node;

确定模块,用于在执行完成时,调用预设等待WAIT命令,以确定所述Redis事务对应的写入数据是否成功同步至备节点上;A determination module, configured to call a preset waiting WAIT command when the execution is completed, to determine whether the write data corresponding to the Redis transaction is successfully synchronized to the standby node;

回滚模块,用于若同步失败,则基于所述事务上下文中缓存的反向事务元素进行事务回滚。A rollback module, configured to roll back the transaction based on the reverse transaction element cached in the transaction context if the synchronization fails.

此外,为实现上述目的,本发明还提供一种数据一致性的实现设备,所述数据一致性的实现设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的数据一致性的实现程序,所述数据一致性的实现程序被所述处理器执行时实现如上所述的数据一致性的实现方法的步骤。In addition, in order to achieve the above object, the present invention also provides a device for realizing data consistency. The device for realizing data consistency includes: a memory, a processor, and a device that is stored on the memory and can run on the processor. A data consistency realization program, when the data consistency realization program is executed by the processor, realizes the steps of the above-mentioned data consistency realization method.

此外,为实现上述目的,本发明还提供一种计算机存储介质,所述计算机存储介质上存储有数据一致性的实现程序,所述数据一致性的实现程序被处理器执行时实现如上所述的数据一致性的实现方法的步骤。In addition, in order to achieve the above object, the present invention also provides a computer storage medium, on which a program for realizing data consistency is stored, and when the program for realizing data consistency is executed by a processor, the above-mentioned program is realized. The steps of the implementation method of data consistency.

本发明提供一种数据一致性的实现方法、装置、设备及计算机存储介质,通过在接收到事务开启指令时,调用预设API生成事物上下文;在接收到数据写入命令时,调用预设API生成对应的正向事务元素和反向事务元素,并缓存至事务上下文中;在接收到事务提交指令时,将事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行Redis事务;在执行完成时,调用预设WAIT命令,以确定Redis事务对应的写入数据是否成功同步至备节点上;若同步失败,则基于事务上下文中缓存的反向事务元素进行事务回滚。本发明中提供了一预设API,以供业务程序调用预设API执行Redis写入,具体的,预设API并未真正执行Redis写入,而是生成对应的正向事务元素和反向事务元素缓存起来,当业务程序提交事务时,则把缓存的正向事务元素封装为一个真正的Redis事务并提交执行,通过将写入命令一次性地提交到主节点执行,可大大降低事务的真实执行时间,也很大程度地避免了因Redis集群中主节点的网络中断而导致的数据不一致的问题。在执行完成时,通过调用WAIT命令确定写入数据是否同步成功,并在同步失败时,基于反向事务元素进行事务回滚,可避免出现“交易虽然成功了、但是数据却丢失了”的情况。因此,本发明可在主节点出现信息孤岛的情况时,保证Redis集群中数据的一致性。The present invention provides a method, device, device and computer storage medium for realizing data consistency. When a transaction opening instruction is received, a preset API is called to generate a transaction context; when a data write command is received, the preset API is called. Generate corresponding forward transaction elements and reverse transaction elements, and cache them in the transaction context; when receiving a transaction commit instruction, encapsulate the forward transaction elements cached in the transaction context as a Redis transaction, and submit the Redis transaction to the master node for execution Transaction; when the execution is completed, the preset WAIT command is called to determine whether the written data corresponding to the Redis transaction is successfully synchronized to the standby node; if the synchronization fails, the transaction is rolled back based on the reverse transaction element cached in the transaction context. The present invention provides a preset API for business programs to call the preset API to perform Redis writing. Specifically, the preset API does not actually execute Redis writing, but generates corresponding forward transaction elements and reverse transactions. The elements are cached. When the business program submits the transaction, the cached forward transaction element is encapsulated into a real Redis transaction and submitted for execution. By submitting the write command to the master node for execution at one time, the authenticity of the transaction can be greatly reduced. The execution time also largely avoids the problem of data inconsistency caused by the network interruption of the master node in the Redis cluster. When the execution is completed, the WAIT command is called to determine whether the written data is synchronized successfully, and when the synchronization fails, the transaction is rolled back based on the reverse transaction element, which can avoid the situation of "the transaction is successful, but the data is lost". . Therefore, the present invention can ensure the consistency of data in the Redis cluster when the information island occurs in the master node.

附图说明Description of drawings

图1为本发明实施例方案涉及的硬件运行环境的设备结构示意图;1 is a schematic diagram of a device structure of a hardware operating environment involved in an embodiment of the present invention;

图2为本发明数据一致性的实现方法第一实施例的流程示意图;FIG. 2 is a schematic flowchart of a first embodiment of a method for realizing data consistency according to the present invention;

图3为本发明数据一致性的实现方法涉及的数据写入流程示意图;3 is a schematic diagram of the data writing process involved in the implementation method of data consistency of the present invention;

图4为本发明数据一致性的实现装置第一实施例的功能模块示意图。FIG. 4 is a schematic diagram of functional modules of the first embodiment of the apparatus for realizing data consistency according to the present invention.

本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments.

具体实施方式Detailed ways

应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described herein are only used to explain the present invention, but not to limit the present invention.

参照图1,图1为本发明实施例方案涉及的硬件运行环境的设备结构示意图。Referring to FIG. 1 , FIG. 1 is a schematic diagram of a device structure of a hardware operating environment involved in an embodiment of the present invention.

本发明实施例数据一致性的实现设备可以是智能手机,也可以是PC(PersonalComputer,个人计算机)、平板电脑、便携计算机等终端设备。The device for realizing data consistency in the embodiment of the present invention may be a smart phone, and may also be a terminal device such as a PC (Personal Computer), a tablet computer, and a portable computer.

如图1所示,该数据一致性的实现设备可以包括:处理器1001,例如CPU,通信总线1002,用户接口1003,网络接口1004,存储器1005。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如Wi-Fi接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。As shown in FIG. 1 , the device for realizing data consistency may include: a processor 1001 , such as a CPU, a communication bus 1002 , a user interface 1003 , a network interface 1004 , and a memory 1005 . Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. Optionally, the network interface 1004 may include a standard wired interface and a wireless interface (eg, a Wi-Fi interface). The memory 1005 may be high-speed RAM memory, or may be non-volatile memory, such as disk memory. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001 .

本领域技术人员可以理解,图1中示出的数据一致性的实现设备结构并不构成对数据一致性的实现设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Those skilled in the art can understand that the device structure for implementing data consistency shown in FIG. 1 does not constitute a limitation on the device for implementing data consistency, and may include more or less components than those shown in the figure, or combine some components, or a different arrangement of components.

如图1所示,作为一种计算机存储介质的存储器1005中可以包括操作系统、网络通信模块以及数据一致性的实现程序。As shown in FIG. 1 , the memory 1005 as a computer storage medium may include an operating system, a network communication module, and a program for realizing data consistency.

在图1所示的终端中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端,与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的数据一致性的实现程序,并执行以下数据一致性的实现方法的各个步骤。In the terminal shown in FIG. 1 , the network interface 1004 is mainly used to connect to the background server and perform data communication with the background server; the user interface 1003 is mainly used to connect to the client and perform data communication with the client; and the processor 1001 can be used for The program for realizing data consistency stored in the memory 1005 is called, and each step of the following method for realizing data consistency is executed.

基于上述硬件结构,提出本发明数据一致性的实现方法的各实施例。Based on the above hardware structure, various embodiments of the method for realizing data consistency of the present invention are proposed.

本发明提供一种数据一致性的实现方法。The present invention provides a method for realizing data consistency.

参照图2,图2为本发明数据一致性的实现方法第一实施例的流程示意图。Referring to FIG. 2 , FIG. 2 is a schematic flowchart of a first embodiment of a method for realizing data consistency of the present invention.

在本实施例中,该数据一致性的实现方法包括:In this embodiment, the implementation method of the data consistency includes:

步骤S10,在接收到事务开启指令时,调用预设应用程序接口API生成事物上下文;Step S10, when receiving the transaction opening instruction, calling a preset application program interface API to generate a transaction context;

本实施例的数据一致性的实现方法是由数据一致性的实现设备实现的,该设备以服务器为例进行说明。数据一致性的实现设备包含了预设API(Application ProgrammingInterface,应用程序接口)。该预设API可把对Redis的写入操作,封装为一个事务。如图3所示,当业务程序调用本预设API执行Redis写入时,该预设API并未真正执行Redis写入,而是生成对应的正向事务元素缓存起来,即,将写入Redis的命令缓存起来。同时,即生成对应的反向事务元素,以将反向操作的命令缓存起来。当业务程序提交事务时,预设API则把缓存的命令封装为一个真正的Redis事务并提交执行。当事务执行后,预设API再调用WAIT命令确定写入数据是否同步成功。如果同步成功,则返回执行成功的信息给业务程序;如果同步失败,则先对反向事务元素对应的要操作的key加锁,再按倒序自动执行反向命令,并返回执行失败的信息给业务程序。The method for realizing data consistency in this embodiment is realized by a device for realizing data consistency, and the device is described by taking a server as an example. The implementation device of data consistency includes a preset API (Application Programming Interface). The preset API can encapsulate the write operation to Redis as a transaction. As shown in Figure 3, when a business program calls this preset API to perform Redis writing, the preset API does not actually execute Redis writing, but generates the corresponding forward transaction elements and caches them, that is, writes to Redis commands are cached. At the same time, a corresponding reverse transaction element is generated to cache the reverse operation command. When a business program submits a transaction, the preset API encapsulates the cached command as a real Redis transaction and submits it for execution. After the transaction is executed, the preset API calls the WAIT command to determine whether the written data is synchronized successfully. If the synchronization is successful, the information of the successful execution is returned to the business program; if the synchronization fails, the key to be operated corresponding to the reverse transaction element is locked first, and then the reverse command is automatically executed in reverse order, and the information of the execution failure is returned to business procedure.

在本实施例中,在接收到业务程序发送的事务开启指令时,即业务程序开始事务时,调用预设应用程序接口API生成事物上下文。具体的,事务上下文(Redis TransactionContext)可由该预设API中的事务管理器(Redis Transaction Manager)创建,事务上下文在业务程序开启事务时创建,在事务结束时自动清除。In this embodiment, when a transaction start instruction sent by a business program is received, that is, when a business program starts a transaction, a preset application program interface API is invoked to generate a transaction context. Specifically, a transaction context (Redis TransactionContext) can be created by a transaction manager (Redis Transaction Manager) in the preset API. The transaction context is created when a business program starts a transaction, and is automatically cleared when the transaction ends.

步骤S20,在接收到数据写入命令时,调用所述预设API生成与所述数据写入命令对应的正向事务元素和反向事务元素,并缓存至所述事务上下文中;Step S20, when receiving the data write command, call the preset API to generate forward transaction elements and reverse transaction elements corresponding to the data write command, and cache them in the transaction context;

在接收到业务程序发送的数据写入命令时,即业务程序想要对Redis进行写入操作时,调用预设API生成与数据写入命令对应的正向事务元素和反向事务元素,并缓存至事务上下文中。其中,正向事务元素和反向事务元素可以包含以下属性:1)Redis命令Command,2)要操作的Key(键),3)要写入的Value(值),4)其他,比如过期时间等。正向事务元素表示对Redis的写入操作,而反向事务元素与正向事务元素的操作是反向的,例如,若数据写入命令为覆盖式写入字符串set(k,v),对应的正向事务元素的命令command为set(写入),Key为k,Value为v,此时,反向事务元素的命令command为delete(删除),Key为k。When the data write command sent by the business program is received, that is, when the business program wants to write to Redis, the preset API is called to generate forward transaction elements and reverse transaction elements corresponding to the data write command, and cache them. into the transaction context. Among them, the forward transaction element and the reverse transaction element can contain the following attributes: 1) Redis command Command, 2) Key (key) to be operated, 3) Value (value) to be written, 4) Others, such as expiration time Wait. The forward transaction element represents the write operation to Redis, and the operation of the reverse transaction element and the forward transaction element is reversed. For example, if the data write command is an overwrite write string set(k,v), The command command of the corresponding forward transaction element is set (write), the key is k, and the value is v. At this time, the command command of the reverse transaction element is delete (delete), and the key is k.

可以理解,业务程序每次发送数据写入命令时,都会调用预设API生成与对应的正向事务元素和反向事务元素,并缓存至事务上下文中。It can be understood that each time a business program sends a data write command, it will call a preset API to generate corresponding forward transaction elements and reverse transaction elements, and cache them in the transaction context.

其中,所述事务上下文包括正向事务元素堆栈和反向事务元素堆栈,步骤S20包括:Wherein, the transaction context includes a forward transaction element stack and a reverse transaction element stack, and step S20 includes:

步骤a21,调用所述预设API生成与所述数据写入命令对应的正向事务元素,并根据预设映射关系生成与所述正向事务元素对应的反向事务元素;Step a21, calling the preset API to generate a forward transaction element corresponding to the data write command, and generating a reverse transaction element corresponding to the forward transaction element according to a preset mapping relationship;

步骤a22,将所述正向事务元素缓存至所述正向事务元素堆栈中,并将所述反向事务元素缓存至所述反向事务元素堆栈中。Step a22: Cache the forward transaction element in the forward transaction element stack, and cache the reverse transaction element in the reverse transaction element stack.

为便于对正向事务元素和反向事务元素进行缓存,事务上下文中可以包括正向事务元素堆栈和反向事务元素堆栈,其中,正向事务元素堆栈用于缓存正向事务元素,反向事务元素堆栈用于缓存反向事务元素。In order to facilitate caching of forward transaction elements and reverse transaction elements, the transaction context may include a forward transaction element stack and a reverse transaction element stack, where the forward transaction element stack is used to cache forward transaction elements, and reverse transaction elements. The element stack is used to cache reverse transaction elements.

在接收到数据写入命令时,调用预设API生成与数据写入命令对应的正向事务元素,并根据预设映射关系生成与正向事务元素对应的反向事务元素;具体的正向事务元素和反向事务元素的生成方式可参照下表的映射关系。When a data write command is received, the preset API is called to generate a forward transaction element corresponding to the data write command, and a reverse transaction element corresponding to the forward transaction element is generated according to the preset mapping relationship; the specific forward transaction The generation method of elements and reverse transaction elements can refer to the mapping relationship in the following table.

Figure BDA0002454364380000071
Figure BDA0002454364380000071

Figure BDA0002454364380000081
Figure BDA0002454364380000081

然后,将正向事务元素缓存至正向事务元素堆栈中,并将反向事务元素缓存至反向事务元素堆栈中。Then, the forward transaction elements are cached into the stack of forward transaction elements, and the reverse transaction elements are cached into the stack of reverse transaction elements.

也就是说,当业务程序每次发送数据写入命令,调用该预设API写入Redis时,可通过该预设API将该数据写入命令,作为一个正向事务元素追加到该正向事务元素堆栈中;而每个正向事务元素缓存至正向事务堆栈时,就必须有一个对应的反向事务元素缓存至反向事务元素堆栈。That is to say, every time a business program sends a data write command and calls the preset API to write to Redis, the data write command can be added to the forward transaction as a forward transaction element through the preset API. When each forward transaction element is cached in the forward transaction stack, there must be a corresponding reverse transaction element cached in the reverse transaction element stack.

步骤S30,在接收到事务提交指令时,将所述事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行所述Redis事务;Step S30, when receiving the transaction submission instruction, encapsulate the forward transaction element cached in the transaction context as a Redis transaction, and submit and execute the Redis transaction to the master node;

在接收到业务程序发送的事务提交指令时,可通过预设API中的事务管理器将事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行Redis事务。具体的,通过WATCH命令对事务上下文中缓存的正向事务元素对应的第一键key进行监视,并通过MULTI命令开启第一命令队列;然后,将正向事务元素按照缓存顺序依次追加至第一命令队列中,封装得到Redis事务;进而通过EXEC命令向主节点提交执行Redis事务。Redis事务的具体提交过程可参照下述第二实施例,此处不作赘述。When receiving the transaction commit instruction sent by the business program, the forward transaction element cached in the transaction context can be encapsulated as a Redis transaction through the transaction manager in the preset API, and the Redis transaction can be submitted to the master node for execution. Specifically, the first key key corresponding to the forward transaction element cached in the transaction context is monitored through the WATCH command, and the first command queue is opened through the MULTI command; then, the forward transaction elements are sequentially added to the first key in the cache order. In the command queue, the Redis transaction is encapsulated and obtained; then the Redis transaction is submitted to the master node through the EXEC command for execution. For the specific submission process of the Redis transaction, reference may be made to the following second embodiment, which will not be repeated here.

步骤S40,在执行完成时,调用预设等待WAIT命令,以确定所述Redis事务对应的写入数据是否成功同步至备节点上;Step S40, when the execution is completed, call the preset waiting WAIT command to determine whether the write data corresponding to the Redis transaction is successfully synchronized to the standby node;

在执行完成时,即数据写入到Redis集群中的主节点上时,调用预设等待WAIT命令,以确定Redis事务对应的写入数据是否成功同步至Redis集群的备节点上。When the execution is completed, that is, when the data is written to the master node in the Redis cluster, the preset wait WAIT command is called to determine whether the written data corresponding to the Redis transaction is successfully synchronized to the standby node of the Redis cluster.

具体的,步骤S40包括:Specifically, step S40 includes:

步骤a41,在执行完成时,调用预设等待WAIT命令,以获取预设时间内返回确认的备节点的数量;Step a41, when the execution is completed, call the preset waiting WAIT command to obtain the number of standby nodes that return confirmation within the preset time;

步骤a42,判断所述数量是否大于或等于预设阈值;Step a42, judging whether the quantity is greater than or equal to a preset threshold;

步骤a43,若所述数量小于预设阈值,则确定所述Redis事务对应的写入数据未成功同步至备节点上。Step a43, if the number is less than the preset threshold, it is determined that the write data corresponding to the Redis transaction has not been successfully synchronized to the standby node.

本实施例中,写入数据是否同步成功的判断过程为:在执行完成时,调用预设等待WAIT命令,以获取预设时间内返回确认的备节点的数量;其中,该预设WAIT命令包含了两个输入参数:numreplicas(number of replicas,数据备份数)和timeout(超时),其中numreplicas表示Slave(备节点)数量,timeout表示超时时间,其单位为毫秒。其中,预设时间即为该timeout参数。然后,判断返回确认的备节点的数量是否大于或等于预设阈值,其中,预设阈值即为该numreplicas参数。若该数量小于预设阈值,则确定Redis事务对应的写入数据未成功同步至备节点上,即同步失败;若该数量大于或等于预设阈值,则确定Redis事务对应的写入数据成功同步至备节点上,即同步成功。In this embodiment, the process of judging whether the written data is synchronized successfully is: when the execution is completed, calling a preset waiting WAIT command to obtain the number of standby nodes that return confirmation within a preset time; wherein, the preset WAIT command includes There are two input parameters: numreplicas (number of replicas, the number of data backups) and timeout (timeout), where numreplicas represents the number of slaves (standby nodes), and timeout represents the timeout time in milliseconds. The preset time is the timeout parameter. Then, it is judged whether the number of standby nodes returned for confirmation is greater than or equal to a preset threshold, where the preset threshold is the numreplicas parameter. If the number is less than the preset threshold, it is determined that the write data corresponding to the Redis transaction has not been successfully synchronized to the standby node, that is, the synchronization fails; if the number is greater than or equal to the preset threshold, it is determined that the write data corresponding to the Redis transaction has been successfully synchronized to the standby node, that is, the synchronization is successful.

例如,若预设WAIT命令为WAIT(1,2000),要求至少1个备节点在2秒(2000毫秒)的时间内,则确认数据已经同步。如果WAIT命令返回结果大于或等于1,则说明数据已经成功同步;如果WAIT命令返回结果为0,则说明数据同步失败。当然,可以理解,预设WAIT命令的两个参数,可以根据Redis集群的实际情况,事先配置在配置文件中。For example, if the preset WAIT command is WAIT(1,2000), it requires at least one standby node to confirm that the data has been synchronized within 2 seconds (2000 milliseconds). If the result returned by the WAIT command is greater than or equal to 1, the data has been successfully synchronized; if the result returned by the WAIT command is 0, the data synchronization has failed. Of course, it can be understood that the two parameters of the preset WAIT command can be configured in the configuration file in advance according to the actual situation of the Redis cluster.

若同步失败,则执行步骤S50,基于所述事务上下文中缓存的反向事务元素进行事务回滚。If the synchronization fails, step S50 is executed to perform transaction rollback based on the reverse transaction element cached in the transaction context.

若同步失败,则基于事务上下文中缓存的反向事务元素进行事务回滚。同时,还可以返回执行失败的信息给业务程序。对于事务回滚过程,可先对事务上下文中缓存的反向事务元素对应的第二key施加锁,并通过MULTI命令开启第二命令队列;然后,将反向事务元素按照缓存顺序倒序追加至第二命令队列中,封装得到回滚事务;最后通过EXEC命令向主节点提交执行回滚事务,以进行事务回滚。其具体过程可参照下述第三实施例,此处不作赘述。If synchronization fails, the transaction is rolled back based on the reverse transaction element cached in the transaction context. At the same time, the execution failure information can also be returned to the business program. For the transaction rollback process, first lock the second key corresponding to the reverse transaction element cached in the transaction context, and open the second command queue through the MULTI command; then, append the reverse transaction element to the In the second command queue, encapsulate the rollback transaction; finally submit the rollback transaction to the master node through the EXEC command for transaction rollback. For the specific process, reference may be made to the following third embodiment, which will not be repeated here.

进一步地,若同步成功,则返回执行成功的信息给业务程序。Further, if the synchronization is successful, the information of successful execution is returned to the business program.

需要说明的是,若在现有技术的基础上只是单纯地结合WAIT命令,在主节点Master因为网络原因出现信息孤岛的情况时,虽然可在确定同步失败时,可以通知备节点Slave终止交易,避免上述“交易虽然成功了、但是数据却丢失了”的情况发生,但是,由于主备节点之间偶尔会出现网络瞬间阻塞的情况,比如多个系统可能在某一时刻同时传输大型文件时,会导致网络阻塞。这种瞬间的阻塞,很有可能导致Master与Slave之间的数据同步时间超过WAIT命令中的预设时间,但是阻塞过后Master与Slave会同步成功,这种短暂的网络阻塞,也不会导致Master/Slave切换。于是会出现“交易虽然失败了、但是数据写入Redis却成功了”的情况,仍旧存在数据一致性的问题。然而Redis是不支持事务回滚的,本发明实施例中通过预设API实现了数据的自动回滚,避免了因网络瞬间阻塞导致的数据不一致的情况发生。It should be noted that if the WAIT command is simply combined on the basis of the existing technology, when the master node Master has an information island due to network reasons, although it can be determined that the synchronization fails, the standby node Slave can be notified to terminate the transaction. Avoid the above situation of "the transaction is successful, but the data is lost". However, due to the occasional momentary network congestion between the active and standby nodes, for example, when multiple systems may transmit large files at the same time, will cause network congestion. This momentary blockage is likely to cause the data synchronization time between the Master and the Slave to exceed the preset time in the WAIT command, but after the blockage, the Master and the Slave will synchronize successfully. This short-term network blockage will not cause the Master to /Slave switch. As a result, there will be a situation of "although the transaction fails, but the data is successfully written to Redis", and there is still a problem of data consistency. However, Redis does not support transaction rollback. In the embodiment of the present invention, automatic data rollback is implemented through a preset API, which avoids the occurrence of data inconsistency caused by instantaneous network congestion.

本发明实施例提供一种数据一致性的实现方法,通过在接收到事务开启指令时,调用预设API生成事物上下文;在接收到数据写入命令时,调用预设API生成对应的正向事务元素和反向事务元素,并缓存至事务上下文中;在接收到事务提交指令时,将事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行Redis事务;在执行完成时,调用预设WAIT命令,以确定Redis事务对应的写入数据是否成功同步至备节点上;若同步失败,则基于事务上下文中缓存的反向事务元素进行事务回滚。本发明实施例中提供了一预设API,以供业务程序调用预设API执行Redis写入,具体的,预设API并未真正执行Redis写入,而是生成对应的正向事务元素和反向事务元素缓存起来,当业务程序提交事务时,则把缓存的正向事务元素封装为一个真正的Redis事务并提交执行,通过将写入命令一次性地提交到主节点执行,可大大降低事务的真实执行时间,也很大程度地避免了因Redis集群中主节点的网络中断而导致的数据不一致的问题。在执行完成时,通过调用WAIT命令确定写入数据是否同步成功,并在同步失败时,基于反向事务元素进行事务回滚,可避免出现“交易虽然成功了、但是数据却丢失了”的情况。因此,本发明实施例可在主节点出现信息孤岛的情况时,保证Redis集群中数据的一致性。The embodiment of the present invention provides a method for realizing data consistency. When a transaction opening instruction is received, a preset API is called to generate a transaction context; when a data write command is received, a corresponding forward transaction is generated by calling the preset API. elements and reverse transaction elements, and cache them in the transaction context; when receiving the transaction commit instruction, encapsulate the forward transaction elements cached in the transaction context as a Redis transaction, and submit the Redis transaction to the master node for execution; when the execution is completed , call the preset WAIT command to determine whether the written data corresponding to the Redis transaction is successfully synchronized to the standby node; if the synchronization fails, the transaction is rolled back based on the reverse transaction element cached in the transaction context. In the embodiment of the present invention, a preset API is provided for business programs to call the preset API to perform Redis writing. Specifically, the preset API does not actually execute Redis writing, but generates corresponding forward transaction elements and reverse transaction elements. Cache the transaction element. When the business program submits the transaction, the cached forward transaction element is encapsulated into a real Redis transaction and submitted for execution. By submitting the write command to the master node for execution at one time, the transaction can be greatly reduced. It also largely avoids the problem of data inconsistency caused by the network interruption of the master node in the Redis cluster. When the execution is completed, the WAIT command is called to determine whether the written data is synchronized successfully, and when the synchronization fails, the transaction is rolled back based on the reverse transaction element, which can avoid the situation of "the transaction is successful, but the data is lost". . Therefore, the embodiment of the present invention can ensure the consistency of data in the Redis cluster when the information island occurs on the master node.

进一步的,基于上述第一实施例,提出本发明数据一致性的实现方法的第二实施例。Further, based on the above-mentioned first embodiment, a second embodiment of the method for realizing data consistency of the present invention is proposed.

在本实施例中,步骤S30包括:In this embodiment, step S30 includes:

步骤a31,在接收到事务提交指令时,通过WATCH命令对所述事务上下文中缓存的正向事务元素对应的第一键key进行监视,并通过MULTI命令开启第一命令队列;Step a31, when receiving the transaction submission instruction, monitor the first key key corresponding to the forward transaction element cached in the transaction context through the WATCH command, and open the first command queue through the MULTI command;

在本实施例中,在接收到事务提交指令时,通过WATCH命令对事务上下文中缓存的正向事务元素对应的第一key(键)进行监视,并通过MULTI命令开启第一命令队列。其中,WATCH命令是一个乐观锁(optimistic locking),用于在EXEC命令执行前,监视监视一个或多个key,并在EXEC命令执行时,检查监视的键是否至少有一个已经被其他命令修改过了,如果修改过了,服务器将拒绝执行事务,同时返回给业务程序Redis事务执行失败的结果即可。MULTI命令用于标记一个事务块的开始,可开启命令队列。In this embodiment, when the transaction commit instruction is received, the first key (key) corresponding to the forward transaction element cached in the transaction context is monitored through the WATCH command, and the first command queue is opened through the MULTI command. Among them, the WATCH command is an optimistic locking (optimistic locking), which is used to monitor one or more keys before the EXEC command is executed, and when the EXEC command is executed, check whether at least one of the monitored keys has been modified by other commands. If it has been modified, the server will refuse to execute the transaction and return the result of the business program Redis transaction execution failure. The MULTI command is used to mark the beginning of a transaction block, which can open the command queue.

步骤a32,将所述正向事务元素按照缓存顺序依次追加至所述第一命令队列中,封装得到Redis事务;Step a32, the forward transaction elements are sequentially added to the first command queue according to the cache order, and the Redis transaction is obtained by encapsulation;

然后,将正向事务元素按照缓存顺序依次(即正序)追加至第一命令队列中,封装得到Redis事务。Then, the forward transaction elements are sequentially added to the first command queue according to the cache order (ie, the forward order), and the Redis transaction is obtained by encapsulation.

步骤a33,通过EXEC命令向主节点提交执行所述Redis事务。Step a33, submit and execute the Redis transaction to the master node through an EXEC command.

进而,通过EXEC命令向主节点提交执行Redis事务,即将第一命令队列中的所有命令一次性提交到主节点Master执行。其中,EXEC命令用于执行所有事务块内(即Redis事务中)的命令。Further, submit and execute the Redis transaction to the master node through the EXEC command, that is, submit all commands in the first command queue to the master node Master for execution at one time. Among them, the EXEC command is used to execute commands within all transaction blocks (that is, in Redis transactions).

通过上述方式,可将事务上下文的正向事务元素堆栈中的正向事务元素(对应各Redis写入操作)打包后一次性地提交到Redis集群中的主节点执行,可大大降低事务的真实执行时间。也从侧面很大程度地避免了因为主节点Master的网络中断而导致的数据不一致的问题。Through the above method, the forward transaction elements (corresponding to each Redis write operation) in the forward transaction element stack of the transaction context can be packaged and submitted to the master node in the Redis cluster for execution at one time, which can greatly reduce the actual execution of the transaction. time. It also largely avoids the problem of data inconsistency caused by the network interruption of the master node Master.

进一步地,在步骤a33之后,该数据一致性的实现方法还包括:Further, after step a33, the realization method of this data consistency also includes:

在接收到异常回滚指令时,调用所述预设API的回滚命令,清除所述第一命令队列中的命令并放弃执行。When an abnormal rollback command is received, the rollback command of the preset API is called, the commands in the first command queue are cleared, and execution is abandoned.

本实施例中,业务程序在执行的过程中遇到异常时,可发送异常回滚指令,此时,服务器在接收到异常回滚指令时,调用预设API的回滚命令rollback()命令,清除第一命令队列中的命令并放弃执行。具体的,可通过DISCARD命令,将第一命令队列中的命令清除并放弃执行。其中,DISCARD命令用于取消事务,放弃执行事务块内(即Redis事务中)的所有命令。In this embodiment, when the business program encounters an exception during execution, it can send an exception rollback instruction. At this time, when the server receives the exception rollback instruction, it calls the rollback command rollback() command of the preset API, Clears the command in the first command queue and aborts execution. Specifically, the DISCARD command can be used to clear the commands in the first command queue and give up execution. Among them, the DISCARD command is used to cancel the transaction and abandon the execution of all commands in the transaction block (ie, in the Redis transaction).

进一步的,基于上述第一实施例,提出本发明数据一致性的实现方法的第三实施例。Further, based on the above-mentioned first embodiment, a third embodiment of the method for realizing data consistency of the present invention is proposed.

在本实施例中,步骤S50包括:In this embodiment, step S50 includes:

步骤a51,对所述事务上下文中缓存的反向事务元素对应的第二key施加锁,并通过MULTI命令开启第二命令队列;Step a51, applying a lock to the second key corresponding to the reverse transaction element cached in the transaction context, and opening the second command queue by the MULTI command;

在本实施例中,对事务上下文中缓存的反向事务元素对应的第二key施加锁,并通过MULTI命令开启第二命令队列。此处,需要说明的是,对第二key施加锁的目的在于,避免在事务回滚过程中有其他业务程序恰好需要修改相同的数据key时、导致数据不一致的情况发生。In this embodiment, a lock is applied to the second key corresponding to the reverse transaction element cached in the transaction context, and the second command queue is opened through the MULTI command. Here, it should be noted that the purpose of applying a lock to the second key is to avoid the occurrence of data inconsistency when other business programs just need to modify the same data key during the transaction rollback process.

进一步地,步骤“对所述事务上下文中缓存的反向事务元素对应的第二key施加锁”包括:Further, the step "locking the second key corresponding to the reverse transaction element cached in the transaction context" includes:

通过SETNX命令对所述事务上下文中缓存的反向事务元素对应的第二key施加排他锁;或,Apply an exclusive lock to the second key corresponding to the reverse transaction element cached in the transaction context through the SETNX command; or,

通过WATCH命令对所述事务上下文中缓存的反向事务元素对应的第二key进行监视,以施加乐观锁。The second key corresponding to the reverse transaction element cached in the transaction context is monitored through the WATCH command to apply an optimistic lock.

本实施例中,加锁方式可以包括2种:1)通过SETNX命令对事务上下文中缓存的反向事务元素对应的第二key施加排他锁;2)通过WATCH命令对事务上下文中缓存的反向事务元素对应的第二key进行监视,以施加乐观锁。其中,SETNX是“SET if Not eXists”的简写,SETNX命令可用于实现排他锁,加锁的代码如下:setnx(key,value),当一个事务执行setnx命令返回1,说明key原本不存在,该事务成功对key加上了排他锁;当一个事务执行setnx返回0,说明key已经存在,该事务未对该key抢锁失败。In this embodiment, the locking methods can include two types: 1) apply an exclusive lock to the second key corresponding to the reverse transaction element cached in the transaction context through the SETNX command; 2) use the WATCH command to reverse the cache in the transaction context The second key corresponding to the transaction element is monitored for optimistic locking. Among them, SETNX is the abbreviation of "SET if Not eXists". The SETNX command can be used to implement exclusive locks. The code for locking is as follows: setnx(key, value), when a transaction executes the setnx command and returns 1, it means that the key does not exist originally. The transaction successfully adds an exclusive lock to the key; when a transaction executes setnx and returns 0, it means that the key already exists, and the transaction fails to grab the lock for the key.

若本事务对key加上排他锁,则本事务可以对该key进行操作,而其他事务不能再对key加任何锁,直到该事务释放key上的锁,从而可以保证了其他事务在本事务释放key上的锁之前不能再该key进行操作。而乐观锁,则是在提交数据更新之前,每个事务会先检查在该事务对key进行操作后,有没有其他事务又对key进行了操作。如果其他事务有更新的话,正在提交的事务会进行回滚,此时,由于各种命令的回滚动作都不一样,会给各个开发人员造成了严重的负担,更容易出错,影响了系统的稳定性。因此,为避免上述情况的发生,以免以些特殊情况导致数据不一致,优选地,可通过施加排他锁的方式,对反向事务元素对应的第二key进行加锁。If the transaction adds an exclusive lock to the key, the transaction can operate on the key, and other transactions cannot add any locks to the key until the transaction releases the lock on the key, thereby ensuring that other transactions are released in this transaction. Before the lock on the key can no longer operate on the key. Optimistic locking means that before submitting data updates, each transaction will first check whether other transactions have operated on the key after the transaction has operated on the key. If other transactions are updated, the transaction that is being submitted will be rolled back. At this time, due to the different rollback operations of various commands, it will cause a serious burden on each developer, and it is more prone to errors and affects the system. stability. Therefore, in order to avoid the above situation and avoid data inconsistency caused by some special circumstances, preferably, the second key corresponding to the reverse transaction element can be locked by applying an exclusive lock.

步骤a52,将所述反向事务元素按照缓存顺序倒序追加至所述第二命令队列中,封装得到回滚事务;Step a52, appending the reverse transaction elements to the second command queue in reverse order according to the cache order, and encapsulating to obtain a rollback transaction;

步骤a53,通过EXEC命令向所述主节点提交执行所述回滚事务,以进行事务回滚。Step a53, submit and execute the rollback transaction to the master node through an EXEC command, so as to roll back the transaction.

然后,将反向事务元素按照缓存顺序倒序追加至第二命令队列中,封装得到回滚事务;通过EXEC命令向主节点提交执行回滚事务,以进行事务回滚。Then, the reverse transaction elements are added to the second command queue in reverse order according to the cache order, and the rollback transaction is obtained by encapsulation; the rollback transaction is submitted to the master node through the EXEC command to perform transaction rollback.

通过上述方式,可在需要事务回滚时,可通过预设API基于反向事务元素堆栈中的反向事务元素倒序自动执行反向命令,以实现事务回滚。In the above manner, when a transaction rollback is required, the reverse command can be automatically executed in reverse order based on the reverse transaction elements in the reverse transaction element stack through a preset API, so as to realize the transaction rollback.

进一步地,需要说明的是,在实际应用过程中,业务程序在写入数据时,通常会先写入关系数据库,再写入Redis集群,进而再写入关系数据库,写入Redis集群,依次循环,因此,为保证业务程序读写事务的一致性。可将该预设API的事务嵌入到关系数据库的事务过程中。具体的,如上所述和图3所示,该预设API为业务程序提供给了开启事务、提交事务和回滚事务的三个接口,可将这三个接口嵌入到关系数据库的事务过程中,具体如下:Further, it should be noted that in the actual application process, when the business program writes data, it usually writes to the relational database first, then writes to the Redis cluster, and then writes to the relational database, then writes to the Redis cluster, and loops in turn , therefore, in order to ensure the consistency of read and write transactions of business programs. The transaction of the preset API can be embedded in the transaction process of the relational database. Specifically, as described above and shown in FIG. 3 , the preset API provides business programs with three interfaces for opening a transaction, submitting a transaction and rolling back a transaction, and these three interfaces can be embedded in the transaction process of the relational database ,details as follows:

1)开启关系数据库事务后,再开启本预设API事务;1) After opening the relational database transaction, open the default API transaction;

2)提交关系数据库事务前,先提交本预设API事务;2) Before submitting a relational database transaction, submit this preset API transaction first;

3)回滚关系数据库事务前,先回滚本预设API事务;3) Before rolling back the relational database transaction, first roll back the default API transaction;

具体的,可通过Spring AOP(Aspect-OrientedProgramming,面向切面编程)的方式,或者Spring中预定义的事务拦截器Transaction Interceptor和事务同步适配器Transaction Synchronization Adpter,可以非常方便地完成上述整合,此处不再详述。Specifically, the above integration can be easily accomplished by means of Spring AOP (Aspect-Oriented Programming), or the predefined transaction interceptor Transaction Interceptor and Transaction Synchronization Adpter in Spring. detail.

通过上述方式,基于本发明的预设API可以实现Redis与关系数据库事务的整合,进而进一步保证业务程序读写事务的一致性。In the above manner, based on the preset API of the present invention, the integration of Redis and relational database transactions can be realized, thereby further ensuring the consistency of read and write transactions of business programs.

本发明还提供一种数据一致性的实现装置。The invention also provides a device for realizing data consistency.

参照图4,图4为本发明数据一致性的实现装置第一实施例的功能模块示意图。Referring to FIG. 4 , FIG. 4 is a schematic diagram of functional modules of the first embodiment of the apparatus for realizing data consistency of the present invention.

如图4所示,所述数据一致性的实现装置包括:As shown in FIG. 4 , the device for realizing data consistency includes:

生成模块10,用于在接收到事务开启指令时,调用预设应用程序接口API生成事物上下文;The generating module 10 is configured to call a preset application program interface API to generate a transaction context when receiving the transaction opening instruction;

缓存模块20,用于在接收到数据写入命令时,调用所述预设API生成与所述数据写入命令对应的正向事务元素和反向事务元素,并缓存至所述事务上下文中;The cache module 20 is configured to, when receiving a data write command, call the preset API to generate forward transaction elements and reverse transaction elements corresponding to the data write command, and cache them in the transaction context;

封装模块30,用于在接收到事务提交指令时,将所述事务上下文中缓存的正向事务元素封装为Redis事务,并向主节点提交执行所述Redis事务;The encapsulation module 30 is configured to encapsulate the forward transaction element cached in the transaction context into a Redis transaction when receiving the transaction submission instruction, and submit and execute the Redis transaction to the master node;

确定模块40,用于在执行完成时,调用预设等待WAIT命令,以确定所述Redis事务对应的写入数据是否成功同步至备节点上;The determination module 40 is configured to call the preset waiting WAIT command when the execution is completed, to determine whether the write data corresponding to the Redis transaction is successfully synchronized to the standby node;

回滚模块50,用于若同步失败,则基于所述事务上下文中缓存的反向事务元素进行事务回滚。The rollback module 50 is configured to roll back the transaction based on the reverse transaction element cached in the transaction context if the synchronization fails.

进一步地,所述封装模块30包括:Further, the packaging module 30 includes:

队列开启单元,用于在接收到事务提交指令时,通过WATCH命令对所述事务上下文中缓存的正向事务元素对应的第一键key进行监视,并通过MULTI命令开启第一命令队列;The queue opening unit is used to monitor the first key key corresponding to the forward transaction element cached in the transaction context through the WATCH command when receiving the transaction submission instruction, and open the first command queue through the MULTI command;

第一封装单元,用于将所述正向事务元素按照缓存顺序依次追加至所述第一命令队列中,封装得到Redis事务;a first encapsulation unit, configured to sequentially append the forward transaction elements to the first command queue according to the cache order, and encapsulate to obtain a Redis transaction;

第一提交单元,用于通过EXEC命令向主节点提交执行所述Redis事务。The first submitting unit is configured to submit and execute the Redis transaction to the master node through an EXEC command.

进一步地,所述数据一致性的实现装置还包括:Further, the device for realizing data consistency also includes:

放弃执行模块,用于在接收到异常回滚指令时,调用所述预设API的回滚命令,清除所述第一命令队列中的命令并放弃执行。The abandoning execution module is configured to call the rollback command of the preset API when receiving an abnormal rollback instruction, clear the commands in the first command queue and abandon the execution.

进一步地,所述回滚模块50包括:Further, the rollback module 50 includes:

加锁单元,用于对所述事务上下文中缓存的反向事务元素对应的第二key施加锁,并通过MULTI命令开启第二命令队列;A locking unit, for applying a lock to the second key corresponding to the reverse transaction element cached in the transaction context, and opening the second command queue through the MULTI command;

第二封装单元,用于将所述反向事务元素按照缓存顺序倒序追加至所述第二命令队列中,封装得到回滚事务;a second encapsulation unit, configured to append the reverse transaction elements to the second command queue in reverse order according to the cache order, and encapsulate to obtain a rollback transaction;

第二提交单元,用于通过EXEC命令向所述主节点提交执行所述回滚事务,以进行事务回滚。The second submitting unit is configured to submit and execute the rollback transaction to the master node through an EXEC command, so as to perform transaction rollback.

进一步地,所述加锁单元具体用于:Further, the locking unit is specifically used for:

通过SETNX命令对所述事务上下文中缓存的反向事务元素对应的第二key施加排他锁;或,Apply an exclusive lock to the second key corresponding to the reverse transaction element cached in the transaction context through the SETNX command; or,

通过WATCH命令对所述事务上下文中缓存的反向事务元素对应的第二key进行监视,以施加乐观锁。The second key corresponding to the reverse transaction element cached in the transaction context is monitored through the WATCH command to apply an optimistic lock.

进一步地,所述事务上下文包括正向事务元素堆栈和反向事务元素堆栈,所述缓存模块20包括:Further, the transaction context includes a forward transaction element stack and a reverse transaction element stack, and the cache module 20 includes:

生成单元,用于调用所述预设API生成与所述数据写入命令对应的正向事务元素,并根据预设映射关系生成与所述正向事务元素对应的反向事务元素;a generating unit, configured to call the preset API to generate a forward transaction element corresponding to the data write command, and generate a reverse transaction element corresponding to the forward transaction element according to a preset mapping relationship;

缓存单元,用于将所述正向事务元素缓存至所述正向事务元素堆栈中,并将所述反向事务元素缓存至所述反向事务元素堆栈中。A caching unit, configured to cache the forward transaction element in the forward transaction element stack, and cache the reverse transaction element in the reverse transaction element stack.

进一步地,所述确定模块40包括:Further, the determining module 40 includes:

调用单元,用于在执行完成时,调用预设等待WAIT命令,以获取预设时间内返回确认的备节点的数量;The calling unit is used to call the preset waiting WAIT command when the execution is completed, so as to obtain the number of standby nodes that return confirmation within the preset time;

判断单元,用于判断所述数量是否大于或等于预设阈值;a judgment unit for judging whether the quantity is greater than or equal to a preset threshold;

确定单元,用于若所述数量小于预设阈值,则确定所述Redis事务对应的写入数据未成功同步至备节点上。A determining unit, configured to determine that the write data corresponding to the Redis transaction is not successfully synchronized to the standby node if the number is less than a preset threshold.

其中,上述数据一致性的实现装置中各个模块的功能实现与上述数据一致性的实现方法实施例中各步骤相对应,其功能和实现过程在此处不再一一赘述。Wherein, the function implementation of each module in the above-mentioned apparatus for realizing data consistency corresponds to each step in the above-mentioned embodiment of the above-mentioned method for realizing data consistency, and the functions and implementation process thereof will not be repeated here.

本发明还提供一种计算机存储介质,该计算机存储介质上存储有数据一致性的实现程序,所述数据一致性的实现程序被处理器执行时实现如以上任一项实施例所述的数据一致性的实现方法的步骤。The present invention also provides a computer storage medium, where a program for realizing data consistency is stored thereon, and when the program for realizing data consistency is executed by a processor, the data consistency according to any of the above embodiments is realized The steps of the realization method.

本发明计算机存储介质的具体实施例与上述数据一致性的实现方法各实施例基本相同,在此不作赘述。The specific embodiments of the computer storage medium of the present invention are basically the same as the above-mentioned embodiments of the data consistency implementation method, and will not be repeated here.

需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。It should be noted that, herein, the terms "comprising", "comprising" or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article or system comprising a series of elements includes not only those elements, It also includes other elements not expressly listed or inherent to such a process, method, article or system. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article or system that includes the element.

上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present invention are only for description, and do not represent the advantages or disadvantages of the embodiments.

通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method of the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on such understanding, the technical solutions of the present invention can be embodied in the form of software products in essence or the parts that make contributions to the prior art, and the computer software products are stored in a storage medium (such as ROM/RAM) as described above. , magnetic disk, optical disk), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of the present invention.

以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the scope of the present invention. Any equivalent structure or equivalent process transformation made by using the contents of the description and drawings of the present invention, or directly or indirectly applied in other related technical fields , are similarly included in the scope of patent protection of the present invention.

Claims (10)

1. A method for implementing data consistency is characterized in that the method for implementing data consistency comprises the following steps:
when a transaction opening instruction is received, calling a preset Application Program Interface (API) to generate an object context;
when a data write-in command is received, calling the preset API to generate a forward transaction element and a reverse transaction element corresponding to the data write-in command, and caching the forward transaction element and the reverse transaction element into the transaction context;
when a transaction submitting instruction is received, packaging forward transaction elements cached in the transaction context into a Redis transaction, and submitting and executing the Redis transaction to a main node;
when the execution is completed, calling a preset WAIT WAIT command to determine whether write-in data corresponding to the Redis transaction is successfully synchronized to a standby node;
and if the synchronization fails, performing transaction rollback based on the cached reverse transaction elements in the transaction context.
2. An implementation method of data consistency according to claim 1, wherein the step of encapsulating a forward transaction element cached in the transaction context as a Redis transaction and committing execution of the Redis transaction to a master node upon receiving a transaction commit instruction comprises:
when a transaction submission instruction is received, monitoring a first key corresponding to a forward transaction element cached in the transaction context through a WATCH command, and opening a first command queue through an MU L TI command;
sequentially adding the forward transaction elements to the first command queue according to a cache sequence, and packaging to obtain a Redis transaction;
and submitting to the main node through an EXEC command to execute the Redis transaction.
3. The method for implementing data consistency of claim 2, wherein the method for implementing data consistency further comprises:
and when an abnormal rollback instruction is received, calling a rollback command of the preset API, clearing the commands in the first command queue and abandoning execution.
4. The method of claim 1, wherein the step of transaction rollback based on the cached backward transaction elements in the transaction context comprises:
applying a lock to a second key corresponding to a reverse transaction element cached in the transaction context, and opening a second command queue through an MU L TI command;
adding the reverse transaction elements to the second command queue in a reverse order according to a cache sequence, and packaging to obtain a rollback transaction;
submitting the rollback transaction to the master node for transaction rollback through an EXEC command.
5. The method of claim 4, wherein the step of locking the second key corresponding to the cached reverse transaction element in the transaction context comprises:
applying an exclusive lock to a second key corresponding to a cached reverse transaction element in the transaction context through an SETNX command; or the like, or, alternatively,
monitoring a second key corresponding to a cached reverse transaction element in the transaction context through a WATCH command to apply an optimistic lock.
6. The method for implementing data consistency according to claim 1, wherein the transaction context includes a forward transaction element stack and a reverse transaction element stack, and the step of calling the API to generate the forward transaction element and the reverse transaction element corresponding to the data write command and cache the forward transaction element and the reverse transaction element in the transaction context includes:
calling the preset API to generate a forward transaction element corresponding to the data write-in command, and generating a reverse transaction element corresponding to the forward transaction element according to a preset mapping relation;
caching the forward transaction element into the forward transaction element stack and caching the reverse transaction element into the reverse transaction element stack.
7. The method for implementing data consistency according to claim 1, wherein the step of invoking a preset WAIT command to determine whether write data corresponding to the Redis transaction is successfully synchronized to a standby node when the execution is completed comprises:
when the execution is finished, calling a preset WAIT WAIT command to acquire the number of the backup nodes returning confirmation in the preset time;
judging whether the number is greater than or equal to a preset threshold value;
and if the number is smaller than a preset threshold value, determining that the write-in data corresponding to the Redis transaction is not successfully synchronized to the standby node.
8. An apparatus for implementing data consistency, the apparatus for implementing data consistency comprising:
the generating module is used for calling a preset Application Program Interface (API) to generate an object context when receiving an object starting instruction;
the cache module is used for calling the preset API to generate a forward transaction element and a reverse transaction element corresponding to the data write-in command when the data write-in command is received, and caching the forward transaction element and the reverse transaction element into the transaction context;
the encapsulation module is used for encapsulating forward transaction elements cached in the transaction context into Redis transactions and submitting and executing the Redis transactions to the main node when a transaction submitting instruction is received;
the determining module is used for calling a preset WAIT WAIT command when the execution is completed so as to determine whether write-in data corresponding to the Redis transaction is successfully synchronized to the standby node;
and the rollback module is used for rolling back the transaction based on the reverse transaction element cached in the transaction context if the synchronization fails.
9. An implementation device of data consistency, characterized in that the implementation device of data consistency comprises: memory, processor and a data consistency implementation program stored on the memory and executable on the processor, the data consistency implementation program, when executed by the processor, implementing the steps of the data consistency implementation method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that the computer storage medium stores thereon a data consistency implementation program, and the data consistency implementation program, when executed by a processor, implements the steps of the data consistency implementation method according to any one of claims 1 to 7.
CN202010303936.7A 2020-04-16 2020-04-16 Method, device, equipment and computer storage medium for realizing data consistency Active CN111488367B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010303936.7A CN111488367B (en) 2020-04-16 2020-04-16 Method, device, equipment and computer storage medium for realizing data consistency

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010303936.7A CN111488367B (en) 2020-04-16 2020-04-16 Method, device, equipment and computer storage medium for realizing data consistency

Publications (2)

Publication Number Publication Date
CN111488367A true CN111488367A (en) 2020-08-04
CN111488367B CN111488367B (en) 2024-07-02

Family

ID=71798328

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010303936.7A Active CN111488367B (en) 2020-04-16 2020-04-16 Method, device, equipment and computer storage medium for realizing data consistency

Country Status (1)

Country Link
CN (1) CN111488367B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112699325A (en) * 2021-01-14 2021-04-23 福建天晴在线互动科技有限公司 Method and system for guaranteeing data consistency through cache secondary elimination
CN113485998A (en) * 2021-07-27 2021-10-08 中国银行股份有限公司 Redis transaction processing method and device, electronic device and storage medium
CN117478741A (en) * 2023-11-01 2024-01-30 中国烟草总公司湖北省公司 Data context processing method based on cloud network convergence service orchestrator
CN117632140A (en) * 2023-12-07 2024-03-01 易方达基金管理有限公司 Business process processing method, device and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473318A (en) * 2013-09-12 2013-12-25 中国科学院软件研究所 Distributed transaction security method for memory data grid
CN105278877A (en) * 2015-09-30 2016-01-27 成都华为技术有限公司 Object storage method and device
US9830223B1 (en) * 2015-01-26 2017-11-28 Intel Corporation Methods for repairing a corrupted database to a new, correct state
CN107528709A (en) * 2016-06-22 2017-12-29 中兴通讯股份有限公司 A kind of configuration status backing method and device
CN108900585A (en) * 2018-06-15 2018-11-27 浙江华信区块链科技服务有限公司 Across chain transaction consistency implementation method
CN110012008A (en) * 2019-04-02 2019-07-12 山东国子软件股份有限公司 Distributed coordination and consistency method and system for heterogeneous data sources based on HTTP protocol
CN110019050A (en) * 2017-10-19 2019-07-16 中兴通讯股份有限公司 A kind of data rewind method, system, equipment and computer readable storage medium
CN110502317A (en) * 2018-05-16 2019-11-26 北京京东尚科信息技术有限公司 A kind of method and apparatus of transaction management

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473318A (en) * 2013-09-12 2013-12-25 中国科学院软件研究所 Distributed transaction security method for memory data grid
US9830223B1 (en) * 2015-01-26 2017-11-28 Intel Corporation Methods for repairing a corrupted database to a new, correct state
CN105278877A (en) * 2015-09-30 2016-01-27 成都华为技术有限公司 Object storage method and device
CN107528709A (en) * 2016-06-22 2017-12-29 中兴通讯股份有限公司 A kind of configuration status backing method and device
CN110019050A (en) * 2017-10-19 2019-07-16 中兴通讯股份有限公司 A kind of data rewind method, system, equipment and computer readable storage medium
CN110502317A (en) * 2018-05-16 2019-11-26 北京京东尚科信息技术有限公司 A kind of method and apparatus of transaction management
CN108900585A (en) * 2018-06-15 2018-11-27 浙江华信区块链科技服务有限公司 Across chain transaction consistency implementation method
CN110012008A (en) * 2019-04-02 2019-07-12 山东国子软件股份有限公司 Distributed coordination and consistency method and system for heterogeneous data sources based on HTTP protocol

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112699325A (en) * 2021-01-14 2021-04-23 福建天晴在线互动科技有限公司 Method and system for guaranteeing data consistency through cache secondary elimination
CN113485998A (en) * 2021-07-27 2021-10-08 中国银行股份有限公司 Redis transaction processing method and device, electronic device and storage medium
CN117478741A (en) * 2023-11-01 2024-01-30 中国烟草总公司湖北省公司 Data context processing method based on cloud network convergence service orchestrator
CN117632140A (en) * 2023-12-07 2024-03-01 易方达基金管理有限公司 Business process processing method, device and storage medium

Also Published As

Publication number Publication date
CN111488367B (en) 2024-07-02

Similar Documents

Publication Publication Date Title
CN111488367A (en) Method, device and equipment for realizing data consistency and computer storage medium
CN108932338B (en) Data updating method, device, equipment and medium
EP2795476B1 (en) Application consistent snapshots of a shared volume
CN112306743B (en) Data processing method, device, electronic equipment and computer storage medium
EP2774031B1 (en) Oracle rewind: metadata-driven undo
CN108021338B (en) System and method for implementing a two-layer commit protocol
US20070179992A1 (en) Maintaining coherency in a symbiotic computing system and method of operation thereof
US10474493B2 (en) Systems and methods for semi-durable transaction log storage in two-phase commit protocol transaction processing
US7991971B2 (en) State management for transactional backup consistency
CN114925084B (en) Distributed transaction processing method, system, equipment and readable storage medium
CN111339131A (en) Data reading and writing method and system
WO2022048358A1 (en) Data processing method and device, and storage medium
US20100287407A1 (en) Computer Storage Synchronization and Backup System
CN110413687B (en) Distributed transaction fault processing method and related equipment based on node interaction verification
JP4461147B2 (en) Cluster database using remote data mirroring
US20100185582A1 (en) Web Deployment Functions and Interfaces
US7072912B1 (en) Identifying a common point in time across multiple logs
WO2020060620A1 (en) Storage segment server covered cache
US10877868B2 (en) Applying a log to storage segments
US7506116B2 (en) Maintaining and using information on updates to a data group after a logical copy is made of the data group
US11334445B2 (en) Using non-volatile memory to improve the availability of an in-memory database
US6868418B1 (en) Methods and systems for performing reliable asynchronous notification of high-level document operations
CN113051008A (en) Interface request processing method and device, computer equipment and storage medium
CN112740639B (en) Backup combined computing system, method and program product in a computing environment
WO2014027881A1 (en) A configuration profile management system for mobile

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant