A distributed system data synchronization method, device, equipment and storage medium
By querying the processing status of database tables in a distributed system and processing transaction requests, the problems of data inconsistency and insufficient system reliability in a distributed system are solved, and data synchronization between open systems and host systems and high system availability are achieved.
Patent Information
- Application Number
- CN202210113501.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-30
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-01-30
AI Technical Summary
In distributed systems, due to network failure or host exceptions, the coordinator needs to roll back transactions, resulting in inconsistent open and host data, insufficient system reliability and fault tolerance, and resource locking and performance bottlenecks in the coordination method of third-party servers.
By obtaining the transaction request, querying the processing status of the database table, and processing the database table according to the status, obtaining the processing results, returning the result to the first transaction processing, and calling the second transaction with the same function after success, realizing the open system and the host system Data synchronization.
It realizes unlimited repeated submissions of transactions, ensures consistency between open and host system data, takes into account the overall consistency and availability requirements of distributed systems, and avoids resource locking and performance bottlenecks.
Smart Images

Figure CN114443773B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a distributed system data synchronization method, device, equipment and storage medium. Background Art
[0002] In a distributed system, the host and the open system realize information transmission and interaction through computer networks. When both the open and host databases store the same data, the data is updated and maintained through the open transaction collaborative call host transaction. Network failures and other reasons may cause the collaborative host transaction processing to fail, resulting in inconsistency between the open and host data.
[0003] Although it is proposed to use a third-party server as a coordinator to coordinate the problem of inconsistent open and host data, if a network failure or host abnormality occurs, the coordinator will roll back all transactions of the open and host participants involved in the transaction, and the transaction cannot be carried out normally, the service is interrupted, and the reliability and fault tolerance of the system are insufficient. In addition, the coordinator must wait for all participants to express their opinions before executing the commit or rollback operation, which may cause long-term resource locking, easily cause performance bottlenecks, and reduce system availability. Therefore, the current method of adding a third-party server cannot effectively achieve the data synchronization problem between the open system and the host system. Summary of the invention
[0004] The present invention provides a distributed system data synchronization method to solve the problem of inconsistent data between the distributed system and the host system.
[0005] According to one aspect of the present invention, a distributed system data synchronization method is provided, comprising: obtaining a transaction request, wherein the transaction request includes a database table, an operation type, a screening condition, and an execution parameter of the transaction;
[0006] Query the current processing status of the database table of the transaction effect, the processing status includes processed or unprocessed;
[0007] Processing the database table according to the transaction request based on the processing status to obtain a database processing result;
[0008] The database processing result is returned to the first transaction processing, and after determining that the first transaction processing is successful, the second transaction is called to synchronize data between the open system and the host system, wherein the first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same function.
[0009] According to another aspect of the present invention, a distributed system data synchronization device is provided, comprising: a transaction request acquisition module, used to acquire a transaction request, wherein the transaction request includes a database table of a transaction effect, an operation type, a screening condition, and an execution parameter;
[0010] A processing status query module, used to query the current processing status of the database table of the transaction effect, wherein the processing status includes processed or unprocessed;
[0011] A database processing result acquisition module, used to process the database table according to the transaction request based on the processing status and acquire a database processing result;
[0012] A data synchronization module is used to return the database processing result to the first transaction processing, and call the second transaction after determining that the first transaction processing is successful, so as to keep the open system and the host system in data synchronization, wherein the first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same function.
[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0014] at least one processor; and
[0015] a memory communicatively connected to the at least one processor; wherein,
[0016] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the distributed system data synchronization device described in any embodiment of the present invention.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the distributed system data synchronization device described in any embodiment of the present invention when executed.
[0018] The technical solution of the embodiment of the present invention processes the database table by querying the current processing status of the database table affected by the transaction as different states of processed or unprocessed, and returns the database processing result to the first transaction processing of the open system. If the processing is successful, the second transaction with the same function in the host system is called, so that unlimited repeated submission of transactions can be achieved. Even in the case of unilateral data, consistency of data on both sides can be achieved through repeated submission, taking into account the consistency and availability requirements of the overall distributed system.
[0019] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0021] Figure 1A is a flow chart of a distributed system data synchronization method provided according to Embodiment 1 of the present invention;
[0022] Figure 1B This is a schematic diagram of an application scenario of a distributed system data synchronization method provided according to Embodiment 2 of the present invention;
[0023] Figure 2 is a flow chart of a distributed system data synchronization method provided according to Embodiment 1 of the present invention;
[0024] Figure 3 is a schematic diagram of the structure of a distributed system data synchronization device provided according to Embodiment 3 of the present invention;
[0025] Figure 4 It is a structural diagram of an electronic device for implementing the distributed system data synchronization method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] Embodiment 1
[0029] Figure 1A This is a flow chart of a distributed system data synchronization method provided in the first embodiment of the present invention. This embodiment is applicable to the case of data synchronization between an open system and a host system. The method can be executed by a distributed system data synchronization device in the embodiment of the present invention, and the device can be implemented in the form of hardware and / or software. Figure 1A As shown, the method includes:
[0030] Step S110: Obtain a transaction request, which includes the database table of the transaction effect, the operation type, the screening condition and the execution parameter.
[0031] Optionally, obtaining a transaction request includes: generating an online compensation indication when no collaborative processing response from the host system is received within a preset time; displaying the online compensation indication on a front-end transaction interface; and obtaining a transaction request sent by a user based on the online compensation indication.
[0032] Specifically, Figure 1B The figure shows an application scenario diagram of the present embodiment. The open system and the host system are interconnected through a network to transmit messages and communicate, and form a distributed system. In the distributed system, they collaborate with each other to jointly provide services. They are physically dispersed and logically unified. In the distributed system, a group of independent devices present a unified whole to the user.
[0033] In addition, the transaction request in this embodiment can be submitted for the first time or repeatedly, and the specific applicable situation for repeated submission is that the open system has obtained the database processing result according to the historical transaction request and sent it to the host system, but due to network delay, host transaction is not enabled, etc., the host system's collaborative processing response is not received within the preset time. At this time, an online compensation instruction will be generated and displayed on the front-end transaction interface of the open system. For example, the online compensation instruction is "transaction abnormality, please resubmit" to prompt the operator. The operator can not make any changes in the original transaction interface or modify the non-primary key information in the original transaction request, and resubmit the transaction request. The open system will obtain the transaction request sent by the user based on the online compensation instruction, thereby realizing transaction idempotent processing. In addition, the application-level online compensation is realized based on the database-level judgment mechanism. The judgment logic does not rely on the transaction log or result identification. In the case of sudden transaction interruptions such as power outages, network failures, and system failures, the accuracy of transaction judgment and compensation is high.
[0034] Specifically, in this implementation, the open system receives a transaction request initiated from a client or an associated system, executes transaction TR1 in the open system, and after the processing of transaction TR1 is completed, the host system executes transaction TR2 by calling the synchronous transaction of the host system through the open. TR1 and TR2 transactions implement the same function. The data R1 generated by TR1 is stored in the open system database, and the data R2 generated by TR2 is stored in the host system database. Data R1 is consumed by the open application and there is a need to query and modify the data. Data R2 is consumed by the host application and only supports query requirements, and data R1 and data R2 must be consistent.
[0035] It should be noted that the transaction request received by the open system includes the database table, operation type, screening conditions and execution parameters of the transaction effect, wherein the operation type specifically includes insert operation, update operation, delete operation or select operation, and the database tables included in this embodiment may be multiple, and each database has a corresponding operation type, screening conditions and execution parameters, and the specific number of database tables is not limited in this embodiment.
[0036] Step S120: query the current processing status of the database table of the transaction effect, where the processing status includes processed or unprocessed.
[0037] Optionally, querying the current processing status of the database table affected by the transaction may include: querying the modification record of the database table from the open system database; verifying the modification record according to the operation type to obtain the current processing status of the database table.
[0038] Among them, for each database table affected by the transaction, the open system will query the processing status of the database table, specifically, query the modification record of the database from the open system according to the table name of the data table, verify the modification record according to the operation type, and obtain the current processing status of the database table, specifically: when the operation type is an insert operation, determine whether the query result for the modification record of the database table is empty, if so, determine the processing status as unprocessed, otherwise it is processed; when the operation type is an update operation, determine whether the query result for the modification record of the database table is the same as the execution parameter, if so, determine the processing status as processed, otherwise it is unprocessed; when the operation type is a delete operation, determine whether the query result for the modification record of the database table is empty, if so, determine the processing status as processed, otherwise it is unprocessed; when the operation type is a select operation, directly determine the current processing status of the database table as unprocessed. Therefore, the open system in this embodiment compares the request data with the table records for each database table affected by the transaction, and determines the current processing status of the database table. According to the current processing status, it can be determined whether this transaction request is submitted for the first time or repeatedly. Therefore, for different submission situations, the open system and the host system will perform corresponding compensation processing, thereby achieving idempotence of the transaction.
[0039] It should be noted that the characteristic of idempotent operations is that the impact of any multiple executions is the same as the impact of a single execution. Idempotent functions, or idempotent methods, refer to functions that can be executed repeatedly with the same parameters and obtain the same results. These functions will not affect the system state, and there is no need to worry that repeated execution will cause changes to the system. In this implementation, for the same request data, unlimited repeated submissions of open collaborative host transactions can be achieved. Even in the case of unilateral data, consistency of data on both sides can be achieved through repeated submissions, taking into account the overall consistency and availability requirements of the distributed system.
[0040] Step S130: Process the database table according to the transaction request based on the processing status to obtain the database processing result.
[0041] Optionally, based on the processing status, the database table is processed according to the transaction request to obtain the database processing result, including: when the processing status is unprocessed, insert operation, update operation, delete operation or select operation are performed on the database according to the operation type, filter conditions and execution parameters to obtain the database processing result; the database processing result is saved to the open system database.
[0042] Optionally, the database table is processed according to the transaction request based on the processing status to obtain the database processing result, including: when the processing status is processed and the operation type is an insert operation, judging whether the execution parameters are consistent with the modification record of the database table, if not, updating the database table according to the execution parameters, otherwise directly skipping and using the current data of the database table as the database processing result; when the processing status is processed and the operation type is an update operation, judging whether the execution parameters are consistent with the modification record of the database table, if not, updating the database table according to the execution parameters, otherwise directly skipping and using the current data of the database table as the database processing result; when the processing status is processed and the operation type is a delete operation or a select operation, directly skipping and using the current data of the database table as the database processing result.
[0043] Specifically, in this embodiment, after obtaining the current processing status of the database table, since the processing status includes two states, unprocessed and processed, the database table will be processed accordingly according to the transaction request based on different processing states. When the processing status is determined to be unprocessed, it means that the open system has received a transaction request for the database table for the first time. At this time, the database table will be operated normally according to the transaction rules based on the operation type, screening conditions and execution parameters. For example, when the operation type is determined to be an update operation, the database table is table1, the screening conditions are row1, colmn2, and the execution parameter is 1, it means that in the database table table1, the data determined in the first row and the second column are updated to 1, and the database processing result is obtained according to the update result, and the database processing result is saved in the open system database. Of course, this embodiment is only an example, and the parameters for other operation types are roughly the same, so it will not be repeated in this embodiment. And for the processing status being unprocessed, the operation result is recorded as success or failure.
[0044] In addition, when the processing status is determined to be processed, it means that the open system has received a transaction request for the database table repeatedly rather than for the first time. At this time, different actions will be performed according to different operation types. For example, for the two operation types of insert and update, the execution parameters will be judged first, specifically whether the modification record of the non-primary key and the database table are consistent. If they are inconsistent, it means that the operator has modified the non-primary key information in the request data through the original transaction interface, and the database table will be updated according to the non-primary key; if they are consistent, it means that the operator has not made any modification in the original transaction interface, so it is directly skipped without processing, and the modification record of the database table is directly used as the database processing result. And for the processing status of processed, the operation result is recorded as success or failure, and for the process that is skipped and not processed, the result is recorded as success.
[0045] It should be noted that some operations adopt the skipping mechanism to minimize the operation of opening and host data maintenance, reduce the system's overhead on database operations, and reduce the deadlock and performance risks caused by frequent database modifications. After processing the database table according to the transaction request based on the processing status, the table name, operation type, screening conditions and operation results of the database table will be uniformly recorded in the result data group for subsequent transaction processing.
[0046] Step S140: Return the database processing result to the first transaction processing, and call the second transaction after determining that the first transaction processing is successful, so as to keep the open system and the host system synchronized with each other.
[0047] Among them, the first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same functions and the same input parameters. The open system in this embodiment returns the database processing result to the first transaction processing, such as TR1, and the first transaction TR1 completes the subsequent transaction logic and transaction status processing according to the returned database processing result. If the open transaction processing is successful, the second transaction of the host system will be called, such as TR2, and the second transaction TR2 performs logical processing and interacts with the host database. The host system returns the host database processing result to the second transaction TR2, and the second transaction TR2 completes the subsequent transaction logic and transaction status processing according to the returned host database processing. Since the first transaction and the second transaction have the same functions and input parameters, the data synchronization between the open system and the host system is guaranteed.
[0048] It should be noted that the present embodiment can also obtain transaction requests through the host system and synchronize the database processing results to the open system associated with the host system. The way in which the host system obtains the database processing results for TR2 is roughly the same as the principle of the open system obtaining the database processing results for TR1, so it will not be repeated in this embodiment.
[0049] In the implementation mode of the present application, the current processing status of the database table affected by the transaction is queried as different states of processed or unprocessed, the database table is processed, and the database processing result is returned to the first transaction processing of the open system. If the processing is successful, the second transaction with the same function in the host system is called, so that unlimited repeated submission of transactions can be achieved. Even in the case of unilateral data, consistency of data on both sides can be achieved through repeated submission, taking into account the overall consistency and availability requirements of the distributed system.
[0050] Embodiment 2
[0051] Figure 2This is a flow chart of a distributed system data synchronization method provided by the second embodiment of the present invention. This embodiment is based on the above embodiment. After returning the database processing result to the first transaction processing, calling the second transaction after determining that the first transaction processing is successful, so that the open system and the host system maintain data synchronization, it also includes: receiving a coordinated response from the host system; generating a transaction completion indication according to the coordinated response. Figure 2 As shown, the method includes:
[0052] Step S210: Obtain a transaction request, which includes a database table of the transaction effect, an operation type, a screening condition, and an execution parameter.
[0053] Optionally, obtaining a transaction request includes: generating an online compensation indication when no collaborative processing response from the host system is received within a preset time; displaying the online compensation indication on a front-end transaction interface; and obtaining a transaction request sent by a user based on the online compensation indication.
[0054] Step S220: query the current processing status of the database table of the transaction effect, where the processing status includes processed or unprocessed.
[0055] Optionally, querying the current processing status of the database table affected by the transaction may include: querying the modification record of the database table from the open system database; verifying the modification record according to the operation type to obtain the current processing status of the database table.
[0056] Step S230: Process the database table according to the transaction request based on the processing status to obtain the database processing result.
[0057] Optionally, based on the processing status, the database table is processed according to the transaction request to obtain the database processing result, including: when the processing status is unprocessed, insert operation, update operation, delete operation or select operation are performed on the database according to the operation type, filter conditions and execution parameters to obtain the database processing result; the database processing result is saved to the open system database.
[0058] Optionally, the database table is processed according to the transaction request based on the processing status to obtain the database processing result, including: when the processing status is processed and the operation type is an insert operation, judging whether the execution parameters are consistent with the modification record of the database table, if not, updating the database table according to the execution parameters, otherwise directly skipping and using the current data of the database table as the database processing result; when the processing status is processed and the operation type is an update operation, judging whether the execution parameters are consistent with the modification record of the database table, if not, updating the database table according to the execution parameters, otherwise directly skipping and using the current data of the database table as the database processing result; when the processing status is processed and the operation type is a delete operation or a select operation, directly skipping and using the current data of the database table as the database processing result.
[0059] Step S240: Return the database processing result to the first transaction processing, and call the second transaction after determining that the first transaction processing is successful, so as to keep the open system and the host system synchronized with each other.
[0060] The first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same function and the same input parameters.
[0061] Step S250, receiving a coordinated response from the host system, and generating a transaction completion indication according to the coordinated response.
[0062] Specifically, the open system in this embodiment returns the database processing result to the first transaction processing, and after determining that the first transaction processing is successful, the second transaction is called. After the TR2 transaction processing is completed, if the processing is successful, the host system will send a coordinated response to the open system, and the open system will generate a transaction completion indication according to the coordinated response. This makes it convenient for users to timely understand the data synchronization status of the host system, so as to perform response detection according to the response result, so as to further ensure the security of data synchronization in the distributed system.
[0063] The implementation method of the present application processes the database table by querying the current processing status of the database table affected by the transaction as different states of processed or unprocessed, and returns the database processing result to the first transaction processing of the open system. If the processing is successful, the second transaction with the same function in the host system is called, so that the transaction can be submitted repeatedly for unlimited times. Even in the case of unilateral data, the consistency of the data on both sides can be achieved through repeated submission, taking into account the consistency and availability requirements of the distributed system as a whole. By receiving the coordinated response of the host system and generating a transaction completion indication according to the coordinated response, it is convenient for the user to timely understand the data synchronization status of the host system, so as to perform response detection according to the response result, so as to further ensure the security of data synchronization in the distributed system.
[0064] Embodiment 3
[0065] Figure 3 This is a schematic diagram of the structure of a distributed system data synchronization device provided by Embodiment 3 of the present invention. Figure 3 As shown, the device includes: a transaction request acquisition module 310, a processing status query module 320, a database processing result acquisition module 330 and a data synchronization module 340.
[0066] The transaction request acquisition module 310 is used to acquire a transaction request, wherein the transaction request includes a database table, operation type, screening conditions and execution parameters of the transaction;
[0067] A processing status query module 320 is used to query the current processing status of the database table of the transaction effect, wherein the processing status includes processed or unprocessed;
[0068] A database processing result acquisition module 330 is used to process the database table according to the transaction request based on the processing status and obtain the database processing result;
[0069] The data synchronization module 340 is used to return the database processing result to the first transaction processing, and call the second transaction after determining that the first transaction processing is successful, so as to keep the open system and the host system in data synchronization, wherein the first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same function.
[0070] Optionally, a transaction request acquisition module is specifically used to generate an online compensation indication when a collaborative processing response from the host system is not received within a preset time;
[0071] Display online compensation instructions on the front-end trading interface;
[0072] Get the transaction request sent by the user based on the online compensation instruction.
[0073] Optional, processing status query module, including:
[0074] A modification record query submodule is used to query modification records of a database table from an open system database;
[0075] The processing status query submodule is used to verify the modification record according to the operation type and obtain the current processing status of the database table.
[0076] Optional, the operation type includes insert operation, update operation, delete operation or select operation;
[0077] Optionally, a processing status query submodule is used to determine whether the query result for the modified record of the database table is empty when the operation type is an insert operation. If so, the processing status is determined to be unprocessed, otherwise it is processed;
[0078] When the operation type is an update operation, determine whether the query result of the modified record of the database table is the same as the execution parameter. If so, determine that the processing status is processed, otherwise it is unprocessed;
[0079] When the operation type is a delete operation, determine whether the query result for the modified record of the database table is empty. If so, determine that the processing status is processed, otherwise it is unprocessed;
[0080] When the operation type is a select operation, it is directly determined that the current processing status of the database table is unprocessed.
[0081] Optionally, a database processing result acquisition module is used to perform an insert operation, an update operation, a delete operation or a select operation on the database according to the operation type, the filter condition and the execution parameter to obtain the database processing result when the processing status is unprocessed;
[0082] The database processing results are saved to the open system database.
[0083] Optionally, a database processing result acquisition module is used to determine whether the execution parameters are consistent with the modification records of the database table when the processing status is processed and the operation type is an insert operation. If not, the database table is updated according to the execution parameters; otherwise, it is directly skipped and the current data of the database table is used as the database processing result;
[0084] When the processing status is processed and the operation type is update operation, determine whether the execution parameters are consistent with the modification records of the database table. If not, update the database table according to the execution parameters. Otherwise, skip directly and use the current data of the database table as the database processing result.
[0085] When the processing status is processed and the operation type is a delete operation or a select operation, it is skipped directly and the current data in the database table is used as the database processing result.
[0086] Optionally, the device further comprises a response module, configured to receive a coordinated response from the host system;
[0087] A transaction completion indication is generated based on the coordinated response.
[0088] The distributed system data synchronization device provided in the embodiment of the present invention can execute the distributed system data synchronization method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0089] Embodiment 4
[0090] Figure 4 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0091] like Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0092] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0093] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a distributed system data synchronization method.
[0094] In some embodiments, the distributed system data synchronization method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the distributed system data synchronization method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to execute the distributed system data synchronization method in any other appropriate manner (e.g., by means of firmware).
[0095] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0096] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0097] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0098] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0099] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0100] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0101] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0102] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A distributed system data synchronization method, characterized in that: include: Obtaining a transaction request, wherein the transaction request includes a database table of the transaction effect, an operation type, a screening condition, and an execution parameter; Query the current processing status of the database table of the transaction effect, the processing status includes processed or unprocessed; Processing the database table according to the transaction request based on the processing status to obtain a database processing result; Return the database processing result to the first transaction processing, and call the second transaction after determining that the first transaction processing is successful, so as to keep the open system and the host system synchronized with each other. The first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same function; The transaction request is submitted for the first time or repeatedly; for the repeatedly submitted transaction request, obtaining the transaction request includes: generating an online compensation indication when no collaborative processing response from the host system is received within a preset time; Displaying the online compensation instruction on the front-end transaction interface; Acquire the transaction request sent by the user based on the online compensation instruction; The querying of the current processing status of the database table of the transaction effect includes: Querying the modification record of the database table from the open system database; Verify the modification record according to the operation type to obtain the current processing status of the database table; wherein querying the modification record of the database table from the open system database is specifically querying the modification record of the database table from the open system according to the table name of the database table; The operation type includes an insert operation, an update operation, a delete operation or a select operation; The verifying the modification record according to the operation type to obtain the current processing status of the database table includes: When the operation type is an insert operation, determine whether the query result for the modified record of the database table is empty, if so, determine the processing status as unprocessed, otherwise it is processed; When the operation type is an update operation, determine whether the query result for the modified record of the database table is the same as the execution parameter, and if so, determine that the processing status is processed, otherwise it is unprocessed; When the operation type is a delete operation, determine whether the query result for the modified record of the database table is empty, if so, determine the processing status as processed, otherwise as unprocessed; When the operation type is a select operation, it is directly determined that the current processing state of the database table is unprocessed; Wherein, the processing of the database table according to the transaction request based on the processing status to obtain a database processing result includes: When the processing status is processed and the operation type is an insert operation, determine whether the execution parameter is consistent with the modification record of the database table. If not, update the database table according to the execution parameter. Otherwise, skip directly and use the current data of the database table as the database processing result. When the processing status is processed and the operation type is an update operation, determine whether the execution parameter is consistent with the modification record of the database table. If not, update the database table according to the execution parameter. Otherwise, skip directly and use the current data of the database table as the database processing result. When the processing status is processed, and the operation type is a delete operation or a select operation, it is directly skipped and the current data of the database table is used as the database processing result.
2. The method according to claim 1, characterized in that The processing of the database table according to the transaction request based on the processing status to obtain a database processing result includes: When the processing status is unprocessed, an insert operation, an update operation, a delete operation or a select operation is performed on the database according to the operation type, the screening condition and the execution parameter to obtain the database processing result; The database processing result is saved in the open system database.
3. The method according to any one of claims 1 to 2, characterized in that: The returning the database processing result to the first transaction processing, after calling the second transaction after determining that the first transaction processing is successful, further includes: receiving a coordinated response from the host system; A transaction completion indication is generated according to the coordinated response.
4. A distributed system data synchronization device, characterized in that: include: A transaction request acquisition module, used to acquire a transaction request, wherein the transaction request includes a database table of transaction effects, an operation type, a screening condition, and an execution parameter; A processing status query module, used to query the current processing status of the database table of the transaction effect, wherein the processing status includes processed or unprocessed; A database processing result acquisition module, used to process the database table according to the transaction request based on the processing status and acquire a database processing result; A data synchronization module is used to return the database processing result to the first transaction processing, and call the second transaction after determining that the first transaction processing is successful, so as to keep the open system and the host system synchronized with each other. The first transaction belongs to the open system, the second transaction belongs to the host system, and the first transaction and the second transaction have the same function; Wherein, the transaction request is submitted for the first time or repeatedly; for the repeatedly submitted transaction request, the transaction request acquisition module is specifically used to generate an online compensation indication when no collaborative processing response from the host system is received within a preset time; Display online compensation instructions on the front-end trading interface; Obtaining a transaction request sent by a user based on an online compensation instruction; Wherein, the processing status query module includes: A modification record query submodule is used to query modification records of a database table from an open system database; The processing status query submodule is used to verify the modification record according to the operation type and obtain the current processing status of the database table; The modification record query submodule is specifically used to query the modification record of the database table from the open system according to the table name of the database table; The operation type includes an insert operation, an update operation, a delete operation or a select operation; The processing status query submodule is used to determine whether the query result for the modified record of the database table is empty when the operation type is an insert operation. If so, the processing status is determined to be unprocessed, otherwise it is processed; When the operation type is an update operation, determine whether the query result of the modified record of the database table is the same as the execution parameter. If so, determine that the processing status is processed, otherwise it is unprocessed; When the operation type is a delete operation, determine whether the query result for the modified record of the database table is empty. If so, determine that the processing status is processed, otherwise it is unprocessed; When the operation type is a select operation, the current processing status of the database table is directly determined to be unprocessed; The database processing result acquisition module is used to determine whether the execution parameters are consistent with the modification records of the database table when the processing status is processed and the operation type is an insert operation. If not, the database table is updated according to the execution parameters; otherwise, it is directly skipped and the current data of the database table is used as the database processing result; When the processing status is processed and the operation type is update operation, determine whether the execution parameters are consistent with the modification records of the database table. If not, update the database table according to the execution parameters. Otherwise, skip directly and use the current data of the database table as the database processing result. When the processing status is processed and the operation type is delete operation or select operation, it is skipped directly and the current data in the database table is used as the database processing result.
5. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the data synchronization method according to any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the data synchronization method according to any one of claims 1 to 3 when executed.
Citation Information
Patent Citations
Method and device and system for supporting ultimate consistency of micro-service architecture transaction
CN106777026A
Data synchronization method and device of heterogeneous database and electronic equipment
CN113486109A