A data processing method, device and medium for a database cluster

By using a blockchain platform and contract variable comparison to automate data synchronization in a database cluster, the problem of manually checking for data synchronization errors in existing technologies is solved, achieving efficient and flexible data synchronization and improving user experience.

CN117076561BActive Publication Date: 2026-03-20INSPUR YUNZHOU (SHANDONG) IND INTERNET CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310961779.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-01
Publication Date
2026-03-20
Estimated Expiration
2043-08-01

AI Technical Summary

Technical Problem

Existing database clusters require manual troubleshooting of data synchronization errors during the data synchronization process, making it difficult to achieve flexible, efficient, and reasonable data synchronization, which affects the user experience.

Method used

By obtaining the operation completion identifier from the main database, generating operation information to be synchronized, and uploading it to the blockchain platform using a hash algorithm, the transaction hash value is compared and updated using contract variables to automatically synchronize data, and data consistency is achieved by leveraging the immutability of the blockchain.

Benefits of technology

It has achieved an automated data synchronization process, reduced manual intervention, improved the flexibility and efficiency of data synchronization, and enhanced the user experience of the database cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117076561B_ABST
    Figure CN117076561B_ABST
Patent Text Reader

Abstract

The application provides a data processing method, device and medium for a database cluster, and belongs to the technical field of data processing. The method obtains an operation completion identifier after a business data operation is completed from a master database, generates to-be-synchronized operation information corresponding to the operation completion identifier through a preset information uploading tool. Then, through a hash algorithm, a transaction hash value corresponding to the to-be-synchronized operation information is uploaded to an operation synchronization block of a preset blockchain platform. According to a preset information synchronization rule, each transaction hash value of each operation synchronization block in the blockchain platform is compared with each first transaction hash value corresponding to a first contract variable. Based on the comparison result, the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to a second contract variable are updated, so as to synchronize operation information of the database cluster based on the first contract variable and the second contract variable.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a data processing method, device and medium for a database cluster. BACKGROUND

[0002] With the continuous development of computer technology, the scale of business systems is increasing, and the storage capacity of databases used to store system operation data, operation data and other information is also increasing. In order to meet the data storage needs of large systems and meet the response speed and performance of the system, a database cluster is generally used for data storage and management.

[0003] The database cluster includes a master database and at least one slave database. For business services, the master database has read and write functions, and the slave database is read-only, that is, business data written to the system can only be written through the master database. In order to ensure the normal use of the database cluster, the storage data in the master database and the slave database needs to be consistent.

[0004] However, during the data synchronization process of the master-slave database, the slave database may be in a use state or an abnormal state, resulting in data synchronization errors. At this time, manual error detection and problem repair are required, which brings additional workload to maintenance personnel and affects the user experience of the database cluster. SUMMARY

[0005] The embodiments of the present application provide a data processing method, device and medium for a database cluster, which are used to solve the problem that the current database cluster needs manual troubleshooting of data synchronization error problems during data synchronization, and it is difficult to achieve flexible, efficient and reasonable data synchronization, which affects the user experience.

[0006] In one aspect, the embodiments of the present application provide a data processing method for a database cluster, which comprises:

[0007] Obtaining an operation completion identifier after completing a business data operation from a master database;

[0008] Generating, through a preset information uploading tool, to-be-synchronized operation information corresponding to the operation completion identifier;

[0009] Uploading, through a hash algorithm, a transaction hash value corresponding to the to-be-synchronized operation information to an operation synchronization block of a preset blockchain platform;

[0010] According to a preset information synchronization rule, comparing each transaction hash value of each operation synchronization block in the blockchain platform with each first transaction hash value corresponding to a first contract variable; wherein the first contract variable corresponds to each first transaction hash value that has completed operation synchronization of the slave database;

[0011] Based on the comparison result, the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to the second contract variable is updated to synchronize operation information of the database cluster based on the first contract variable and the second contract variable.

[0012] In an implementation manner of the present application, through a preset information uploading tool, the to-be-synchronized operation information corresponding to the operation completion identifier is generated, specifically including:

[0013] Upon receiving the operation completion identifier, the operation type, the database table identifier, and the data content corresponding to the operation completion identifier are determined through the information uploading tool, wherein the operation type at least includes adding, modifying, deleting, batch adding, and batch deleting;

[0014] According to the operation type, the database table identifier, and the data content, an operation information triple is generated, and the operation information triple is taken as the to-be-synchronized operation information.

[0015] In an implementation manner of the present application, the information uploading tool is a web3j component.

[0016] In an implementation manner of the present application, before uploading the transaction hash value corresponding to the to-be-synchronized operation information to the operation synchronization block of the preset blockchain platform, the method further includes:

[0017] The to-be-synchronized operation information is converted into synchronizable operation information through a preset information conversion smart contract, wherein the synchronizable operation information includes executable database statements.

[0018] In an implementation manner of the present application, before comparing each transaction hash value of each operation synchronization block in the blockchain platform with each first transaction hash value corresponding to a first contract variable according to a preset information synchronization rule, the method further includes:

[0019] According to the information synchronization rule, the first contract variable and the second contract variable are generated, wherein the data structure of the first contract variable and the second contract variable is a key-value pair; the key of the key-value pair corresponds to a slave database identifier, and the value of the key-value pair corresponds to the transaction hash value of the to-be-synchronized operation information; the first contract variable corresponds to the to-be-synchronized operation information that is successfully synchronized from the slave database; and the second contract variable corresponds to the to-be-synchronized operation information that is unsuccessfully synchronized from the slave database.

[0020] In an implementation manner of the present application, the first transaction hash corresponding to the first contract variable and / or the second transaction hash corresponding to the second contract variable is updated based on the comparison result, specifically comprising:

[0021] In the case that the transaction hash of the operation synchronization block is successfully compared with the first transaction hash corresponding to the first contract variable, the transaction hash is excluded from the operation synchronization block;

[0022] Otherwise, the to-be-synchronized operation information corresponding to the transaction hash of the operation synchronization block is synchronized to the corresponding slave database, so as to update the first transaction hash corresponding to the first contract variable and / or the second transaction hash corresponding to the second contract variable according to the synchronization result.

[0023] In an implementation manner of the present application, the first transaction hash corresponding to the first contract variable and / or the second transaction hash corresponding to the second contract variable is updated according to the synchronization result, specifically comprising:

[0024] In the case that the transaction hash is successfully synchronized to the corresponding slave database, the first value list of the key-value pair corresponding to the first contract variable is determined according to the slave database identifier corresponding to the transaction hash, so as to add the transaction hash as the first transaction hash to the corresponding first value list; the first value list corresponds to the slave database identifier one by one; and

[0025] It is determined whether the transaction hash exists in each second value list of the second transaction hash corresponding to the second contract variable; if yes, the transaction hash is excluded from the second value list;

[0026] In the case that the transaction hash fails to be synchronized to the corresponding slave database, the second value list of the key-value pair corresponding to the second contract variable is determined according to the slave database identifier corresponding to the transaction hash, so as to add the transaction hash as the second transaction hash to the corresponding second value list.

[0027] In an implementation manner of the present application, the method further comprises:

[0028] The retry synchronization number of each second transaction hash corresponding to the second contract variable and the cumulative storage duration are determined by the data synchronization smart contract corresponding to the information synchronization rule;

[0029] In the case that the retry synchronization number is greater than a preset number and / or the cumulative storage duration is greater than a preset duration, synchronization exception information is generated, and the synchronization exception information is sent to the corresponding user terminal.

[0030] In another aspect, the embodiments of the present application also provide a data processing device for a database cluster, the device comprising:

[0031] at least one processor; and,

[0032] a memory in communication connection with the at least one processor; wherein,

[0033] the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:

[0034] obtain an operation completion identifier from a main database after completing a business data operation;

[0035] generate, through a preset information uploading tool, to-be-synchronized operation information corresponding to the operation completion identifier;

[0036] upload, through a hash algorithm, a transaction hash value corresponding to the to-be-synchronized operation information to an operation synchronization block of a preset blockchain platform;

[0037] compare, according to a preset information synchronization rule, each transaction hash value of each operation synchronization block in the blockchain platform with each first transaction hash value corresponding to a first contract variable; wherein the first contract variable corresponds to each first transaction hash value that has completed operation synchronization from the database;

[0038] update, based on a comparison result, the first transaction hash value corresponding to the first contract variable and / or a second transaction hash value corresponding to a second contract variable, to synchronize operation information of the database cluster based on the first contract variable and the second contract variable.

[0039] In still another aspect, the embodiments of the present application also provide a non-volatile computer storage medium for a database cluster, storing computer executable instructions, the computer executable instructions being configured to:

[0040] obtain an operation completion identifier from a main database after completing a business data operation;

[0041] generate, through a preset information uploading tool, to-be-synchronized operation information corresponding to the operation completion identifier;

[0042] upload, through a hash algorithm, a transaction hash value corresponding to the to-be-synchronized operation information to an operation synchronization block of a preset blockchain platform;

[0043] According to a preset information synchronization rule, each transaction hash value of each operation synchronization block in the blockchain platform is compared with each first transaction hash value corresponding to a first contract variable, wherein the first contract variable corresponds to each first transaction hash value that has completed operation synchronization from the database;

[0044] Based on the comparison result, the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to a second contract variable are updated to synchronize operation information of the database cluster based on the first contract variable and the second contract variable.

[0045] The application saves all data on the blockchain, achieves data persistence and data backup, and saves details of database operation commands, traces operation conditions and operation time of the database, and the like by means of the characteristics of the blockchain, such as non-tamperability and data sharing. Thus, the problem that the current database cluster needs manual troubleshooting of data synchronization error problems and is difficult to realize flexible, efficient and reasonable data synchronization is solved, and the use experience of the user for the database cluster is improved. BRIEF DESCRIPTION OF DRAWINGS

[0046] The accompanying drawings, which are included to provide a further understanding of the application and constitute a part of this application, illustrate certain illustrative embodiments of the application and together with the description serve to explain the application. In the drawings:

[0047] Figure 1 FIG. 1 is a flowchart of a data processing method for a database cluster according to an embodiment of the application;

[0048] Figure 2 FIG. 2 is a structural diagram of a data processing device for a database cluster according to an embodiment of the application. DETAILED DESCRIPTION

[0049] To make the objectives, technical solutions and advantages of the application clearer, the technical solutions of the application will be described below in detail with reference to the embodiments of the application and the corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the application, but not all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the application.

[0050] The current database cluster needs manual troubleshooting of data synchronization error problems and is difficult to realize flexible, efficient and reasonable data synchronization in the data synchronization process, which affects the use experience of the user.

[0051] Based on this, the embodiments of the present application provide a data processing method, device and medium for a database cluster to solve the above problems.

[0052] The various embodiments of the present application will be described in detail below with reference to the accompanying drawings.

[0053] The embodiments of the present application provide a data processing method for a database cluster, as shown in the method can include steps S101-S105: Figure 1

[0054] S101, the server acquires the operation completion identifier after the main database completes the business data operation.

[0055] It should be noted that the server as the execution subject of the data processing method for the database cluster only exists as an example, and the execution subject is not limited to the server, and the present application does not make specific limitations. The server can be a server connected to the database cluster, used to upload and save the business data of the user's related operation of the database cluster to the blockchain, and synchronize the related business data in the blockchain to the slave database in the database cluster.

[0056] The business data operation includes but is not limited to adding, modifying, deleting operation of business data in the database list, and the operation completion identifier is generated by the main database after the user completes the operation of the main database of the database cluster. For example, the user will use various functional operations of the business service system, and after generating business data, the business service writes data through the main database. After the main database receives the data, it will first save the data, return the operation completion identifier after success, and then notify the server, at which time the server can determine that the data has been successfully added to the main database.

[0057] S102, the server generates the to-be-synchronized operation information corresponding to the operation completion identifier through the preset information uploading tool.

[0058] In the embodiments of the present application, the to-be-synchronized operation information corresponding to the operation completion identifier is generated through the preset information uploading tool, which specifically includes:

[0059] In the case of receiving the operation completion identifier, the operation type, database table identifier and data content corresponding to the operation completion identifier are determined through the information uploading tool. The operation type at least includes add, modify, delete, batch add, and batch delete. According to the operation type, database table identifier and data content, an operation information triple is generated, and the operation information triple is used as the to-be-synchronized operation information.

[0060] ​The information uploading tool is a web3j component, and the web3j is a lightweight, reactive, and type-safe Java and Android library for connecting clients to the Ethereum network. The operation information to be synchronized is mainly dynamically generated according to a specific operation type and a table name of saved data. For example, the approximate structure of the operation information triple for adding a piece of data is [add, table name, data content in JSON format]. The approximate structure of the operation information triple for deleting a piece of data is [delete, table name, data content in JSON format].

[0061] In S103, the server uploads, by using a hash algorithm, a transaction hash value corresponding to the operation information to be synchronized to an operation synchronization block of a preset blockchain platform.

[0062] In the embodiment of the application, before the transaction hash value corresponding to the operation information to be synchronized is uploaded to the operation synchronization block of the preset blockchain platform by using the hash algorithm, the method further includes:

[0063] The server converts, by using a preset information conversion smart contract, the operation information to be synchronized into operation information that can be synchronized. The operation information that can be synchronized includes an executable database statement.

[0064] The information conversion smart contract is generated by being written by a user. The main function of the information conversion smart contract is to convert the operation information to be synchronized into a database operation command that can be directly executed by splicing a database SQL statement. Taking the operation information to be synchronized for adding a piece of data as an example, the SQL statement corresponding to the add type is insert into. The data in JSON format is parsed into a key-value form. The key is a table field name of a database, and the value is a table field value of the database. Then, the table name is added to obtain an actual command, such as insert into table name (key1, key2) values (value1, value2). The operation commands of other types are generated according to respective rules. After the database operation command is generated, the information conversion smart contract saves the command as the operation information that can be synchronized to the blockchain.

[0065] The hash algorithm can calculate the transaction hash value of the operation information that can be synchronized and store the transaction hash value to the operation synchronization block of the blockchain platform.

[0066] In S104, the server compares, according to a preset information synchronization rule, each transaction hash value of each operation synchronization block in the blockchain platform with each first transaction hash value corresponding to a first contract variable.

[0067] The first contract variable corresponds to the first transaction hash values of the operations that have been completed on the database.

[0068] In the embodiment of the present application, before the server compares each transaction hash value of each operation synchronization block in the blockchain platform with each first transaction hash value corresponding to the first contract variable according to the preset information synchronization rule, the method further comprises:

[0069] The server generates the first contract variable and the second contract variable according to the information synchronization rule. The data structure of the first contract variable and the second contract variable is a key-value pair. The key of the key-value pair corresponds to a slave database identifier, and the value of the key-value pair corresponds to a transaction hash value of the operation information to be synchronized. The first contract variable corresponds to the operation information to be synchronized that is synchronized successfully in the corresponding slave database. The second contract variable corresponds to the operation information to be synchronized that is not synchronized successfully in the corresponding slave database.

[0070] After the above S103 step is completed, the blockchain has saved all kinds of operation commands to the master database, that is, the operation information to be synchronized, and according to the mechanism of the blockchain itself, all operation commands as transaction content have been arranged in time sequence and stored persistently. Then, the server will call the data synchronization smart contract in the information synchronization rule on the blockchain at regular intervals.

[0071] The information synchronization rule includes a data synchronization smart contract, which is used to process and filter the operation information to be synchronized (transaction data) in all operation synchronization blocks on the blockchain. The smart contract maintains a first contract variable a and a second contract variable b inside. The contract variables a and b are both key-value pair data structures. The key corresponds to each slave database identifier (used to represent slave database numbers such as slave database 1 and slave database 2), and the value is a list of several operation information to be synchronized transaction hashes. Each transaction hash in the blockchain corresponds to a transaction.

[0072] In the case that the transaction hash value of the operation synchronization block is successfully compared with the first transaction hash value corresponding to the first contract variable, the transaction hash value is removed from the operation synchronization block. Otherwise, the operation information to be synchronized corresponding to the transaction hash value of the operation synchronization block is synchronized to the corresponding slave database, so as to update the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to the second contract variable according to the synchronization result.

[0073] The server can call the get command method in the data synchronization smart contract, the get command method is used to query all transactions recorded on the blockchain, and then compare each transaction hash with the transaction hash saved in the first contract variable a. If there is the same transaction hash, the transaction is removed from the blockchain, and then the transaction content and transaction time saved in the remaining transactions are returned to the server. In fact, the server has obtained the synchronizable operation information that needs to be executed and the time sequence of the execution of each synchronizable operation information. Subsequently, the server writes data to the slave database 1 and the slave database 2 according to the above, so as to achieve the data consistency with the master database. The above example gives the existence of slave database 1 and 2 as an example. In actual use, the number of slave databases is not limited.

[0074] In S105, the server updates the first transaction hash corresponding to the first contract variable and / or the second transaction hash corresponding to the second contract variable based on the comparison result, so as to synchronize the operation information of the database cluster based on the first contract variable and the second contract variable.

[0075] After the comparison of the transaction hash of each operation synchronization block and the first transaction hash corresponding to the first contract variable is completed, the comparison result is obtained. In the embodiment of the present application, the server updates the first transaction hash corresponding to the first contract variable and / or the second transaction hash corresponding to the second contract variable according to the synchronization result, which specifically includes:

[0076] In the case that the transaction hash is successfully synchronized to the corresponding slave database, the first value list of the key-value pair corresponding to the first contract variable is determined according to the slave database identifier corresponding to the transaction hash, so as to add the transaction hash as the first transaction hash to the corresponding first value list. The first value list corresponds to the slave database identifier one by one. And determine whether the transaction hash exists in the second value list of the key-value pair corresponding to the second contract variable. If yes, the transaction hash is removed from the second value list. In the case that the transaction hash fails to be synchronized to the corresponding slave database, the second value list of the key-value pair corresponding to the second contract variable is determined according to the slave database identifier corresponding to the transaction hash, so as to add the transaction hash as the second transaction hash to the corresponding second value list.

[0077] In other words, the server cannot successfully write all the synchronizable operation information in the blockchain to the slave database. Therefore, the server records whether the data is successfully written, the corresponding transaction hash, and the slave database identifier of the failed write, and then calls the synchronization record method of the data synchronization smart contract to update the first contract variable a and the second contract variable b according to the slave database number, the transaction hash, and the success or failure identifier.

[0078] Specifically, in the case that the transaction hash is successfully synchronized to the corresponding slave database, the corresponding value list is obtained from the first contract variable a according to the slave database identifier as the key, the transaction hash of the synchronizable operation information is added to the value list, and then the corresponding value list is obtained from the second contract variable b according to the slave database identifier as the key. It is judged whether the transaction hash synchronized to the value list of the first contract variable a exists, and if it exists, it is removed from the value list of the second contract variable b; in the case that the transaction hash is not successfully synchronized to the corresponding slave database, the corresponding value list is obtained from the second contract variable b according to the slave database identifier as the key, and the transaction hash of the synchronizable operation information is added to the value list.

[0079] In addition, the server determines the retry synchronization number of times and the cumulative storage duration of each second transaction hash corresponding to the second contract variable through the data synchronization smart contract corresponding to the information synchronization rule. In the case that the retry synchronization number of times is greater than a preset number of times and / or the cumulative storage duration is greater than a preset duration, synchronization exception information is generated and sent to the corresponding user terminal.

[0080] That is, the server can call the retry command method in the data synchronization smart contract, which will find the corresponding transaction in the blockchain according to the transaction hash recorded in the second contract variable b, and return the slave database number, transaction content and transaction time to the server. In fact, it is the database operation command related content that needs to be re-executed because of the previous execution failure. The server will re-write the corresponding data to the slave database 1 and the slave database 2 according to the slave database identifier, and then execute the above S105 step. Here, the above retry step will be repeated until the retry command method returns empty. The retry command method returns empty, which means that there is no failed database command, and all operations of the master database have been executed in the slave database. The data of the master database and the slave database is consistent.

[0081] During the retry step, the server can also accumulate the retry synchronization number of times and the storage duration of the transaction hash of the synchronizable operation information recorded in the second contract variable b, and then send synchronization exception information to the user terminal according to the comparison result of the retry synchronization number of times and the cumulative storage duration with the corresponding preset number of times and preset duration. The preset number of times and the preset duration are set by the user, which is used to facilitate manual participation and timely processing when the server cannot retry synchronization successfully. The user terminal can be a mobile phone, computer or other device of a maintenance personnel, which is not limited in the present application.

[0082] The application saves all data on the blockchain, achieves data persistence and makes data backup, and saves details of database operation commands, operation conditions and operation time of the database by means of the characteristics of the blockchain, such as non-tamperability and data sharing, thereby solving the problem that the current database cluster needs manual troubleshooting of data synchronization error in the data synchronization process and is difficult to realize flexible, efficient and reasonable data synchronization, and improving the user experience of the database cluster.

[0083] Figure 2 A structural diagram of a data processing device for a database cluster provided by an embodiment of the application is shown in FIG. 1. Figure 2 As shown in FIG. 1, the device comprises:

[0084] at least one processor; and a memory connected to the at least one processor in communication. The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to:

[0085] obtain an operation completion identifier after a business data operation of a master database is completed. Through a preset information uploading tool, generate to-be-synchronized operation information corresponding to the operation completion identifier. Through a hash algorithm, upload a transaction hash value corresponding to the to-be-synchronized operation information to an operation synchronization block of a preset blockchain platform. According to a preset information synchronization rule, compare each transaction hash value of each operation synchronization block in the blockchain platform with each first transaction hash value corresponding to a first contract variable. The first contract variable corresponds to each first transaction hash value that has completed operation synchronization of the slave database. Based on the comparison result, update the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to a second contract variable, to synchronize operation information of the database cluster based on the first contract variable and the second contract variable.

[0086] An embodiment of the application further provides a non-volatile computer storage medium for a database cluster, which stores computer executable instructions, and the computer executable instructions are set to:

[0087] An operation completion identifier after a business data operation from the primary database is completed is obtained. Through a preset information uploading tool, to-be-synchronized operation information corresponding to the operation completion identifier is generated. Through a hash algorithm, a transaction hash value corresponding to the to-be-synchronized operation information is uploaded to an operation synchronization block of a preset blockchain platform. According to a preset information synchronization rule, each transaction hash value of each operation synchronization block in the blockchain platform is compared with each first transaction hash value corresponding to a first contract variable. The first contract variable corresponds to each first transaction hash value that has completed operation synchronization from the database. Based on the comparison result, the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to a second contract variable are updated, so as to synchronize operation information of the database cluster based on the first contract variable and the second contract variable.

[0088] Each of the embodiments in the present application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment mainly explains the difference from other embodiments. Especially, for the device and medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the related parts can be referred to the part of the method embodiments.

[0089] The device, medium and method in the present application are one-to-one correspondence, so the device and medium also have the similar beneficial technical effects as the method. Since the beneficial technical effects of the method have been described in detail above, the beneficial technical effects of the device and medium will not be described here.

[0090] It should also be noted that the terms "comprising", "containing", or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such a process, method, article or device. Without more limitations, the element defined by the statement "including a" does not exclude the presence of another identical element in the process, method, article or device including the element.

[0091] The above only describes the embodiments of the present application and is not intended to limit the present application. The present application can have various changes and modifications for those skilled in the art. Any modification, equivalent replacement, improvement, etc. within the spirit and principle of the present application shall be included in the scope of claims of the present application.

Claims

1. A data processing method for a database cluster, characterized in that, The method includes: Retrieve the operation completion identifier from the main database after completing the business data operation; Using a preset information upload tool, generate operation information to be synchronized that corresponds to the operation completion identifier; Using a hash algorithm, the transaction hash value corresponding to the operation information to be synchronized is uploaded to the operation synchronization block of the preset blockchain platform; According to the preset information synchronization rules, the transaction hash values ​​of each operation synchronization block in the blockchain platform are compared with the first transaction hash values ​​corresponding to the first contract variables; wherein, the first contract variables correspond to the first transaction hash values ​​that have completed the operation synchronization from the database. Based on the comparison results, update the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to the second contract variable, so as to synchronize the operation information of the database cluster based on the first contract variable and the second contract variable; Before comparing the transaction hash values ​​of each operation synchronization block in the blockchain platform with the first transaction hash values ​​corresponding to the first contract variable according to the preset information synchronization rules, the method further includes: According to the information synchronization rules, a first contract variable and a second contract variable are generated; wherein, the data structure of the first contract variable and the second contract variable is a key-value pair; the key of the key-value pair corresponds to the database identifier, and the value of the key-value pair corresponds to the transaction hash value of the operation information to be synchronized; the first contract variable corresponds to the operation information to be synchronized that was successfully synchronized in the corresponding database; the second contract variable corresponds to the operation information to be synchronized that was unsuccessfully synchronized in the corresponding database.

2. The data processing method for a database cluster according to claim 1, characterized in that, Using a preset information upload tool, generate operation information to be synchronized corresponding to the operation completion identifier, specifically including: Upon receiving the operation completion identifier, the information upload tool determines the operation type, database table identifier, and data content corresponding to the operation completion identifier; wherein, the operation type includes at least add, modify, delete, batch add, and batch delete; Based on the operation type, the database table identifier, and the data content, an operation information triplet is generated, and the operation information triplet is used as the operation information to be synchronized.

3. The data processing method for a database cluster according to claim 2, characterized in that, The information upload tool is a web3j component.

4. The data processing method for a database cluster according to claim 1, characterized in that, Before uploading the transaction hash value corresponding to the operation information to be synchronized to the operation synchronization block of the preset blockchain platform using a hash algorithm, the method further includes: By using a pre-defined information conversion smart contract, the information to be synchronized is converted into information that can be synchronized; wherein, the information that can be synchronized includes executable database statements.

5. A data processing method for a database cluster according to claim 1, characterized in that, Based on the comparison results, update the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to the second contract variable, specifically including: If the transaction hash value of the operation synchronization block is successfully compared with the first transaction hash value corresponding to the first contract variable, the transaction hash value is removed from the operation synchronization block. Otherwise, the operation information to be synchronized corresponding to the transaction hash value of the synchronization block is synchronized to the corresponding slave database, so as to update the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to the second contract variable according to the synchronization result.

6. A data processing method for a database cluster according to claim 1, characterized in that, Based on the synchronization results, update the first transaction hash value corresponding to the first contract variable and / or the second transaction hash value corresponding to the second contract variable, specifically including: Upon successful synchronization of the transaction hash value to the corresponding slave database, a first list of key-value pairs corresponding to the first contract variable is determined based on the slave database identifier corresponding to the transaction hash value. The transaction hash value is then added to the corresponding first value list as the first transaction hash value. The first value list corresponds one-to-one with each slave database identifier. Determine if the transaction hash value exists in the second value list corresponding to the second contract variable; if so, remove the transaction hash value from the second value list. If synchronizing the transaction hash value to the corresponding slave database fails, a second list of key-value pairs corresponding to the second contract variable is determined based on the slave database identifier corresponding to the transaction hash value, so that the transaction hash value is added to the corresponding second list of values ​​as the second transaction hash value.

7. A data processing method for a database cluster according to claim 1, characterized in that, The method further includes: The number of retry synchronizations and the cumulative storage time for each of the second transaction hash values ​​corresponding to the second contract variable are determined by the data synchronization smart contract corresponding to the information synchronization rule. If the number of retry synchronization attempts exceeds a preset number and / or the cumulative storage time exceeds a preset duration, synchronization error information is generated and sent to the corresponding user terminal.

8. A data processing device for a database cluster, characterized in that, The device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a data processing method for a database cluster as described in any one of claims 1-7.

9. A non-volatile computer storage medium for data processing in a database cluster, storing computer-executable instructions, characterized in that, The computer-executable instructions are capable of executing a data processing method for a database cluster as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Data synchronization method and device, electronic equipment and storage medium

    CN109815291A

  • Encryption-based data synchronization method and device, computer equipment and storage medium

    CN115203322A