Data generation method, device and equipment for distributed database

By generating verifiable data in a tree structure on the master database node and synchronizing it to the slave database nodes, the problem of inconsistent verifiable data in distributed database systems is solved, ensuring the normal operation of the data anti-tampering function on the slave database nodes.

CN123178503APending Publication Date: 2026-11-27BEIJING ZITIAO NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510686509.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-26
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In a distributed database system, the asynchronous operation of master and slave database nodes leads to inconsistencies in the generated verifiable data, affecting the normal operation of the data anti-tampering function of the slave database node.

Method used

Data consistency is achieved by generating verifiable data with a tree structure within the master database node and synchronizing it to the slave database node via binary logs, ensuring that the slave database node generates the same mirrored data as the master database node.

Benefits of technology

Ensure that the data anti-tampering function of the database node is working properly to prevent data from being tampered with.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178503A_ABST
    Figure CN123178503A_ABST
Patent Text Reader

Abstract

The embodiment of the present disclosure provides a data generation method, device and equipment for a distributed database. The target data in the master database node of the distributed database is obtained, and the target data includes at least two data records. Corresponding verifiable data is generated based on the target data, wherein the verifiable data includes at least one data group with a tree structure, the leaf node of the data group is used to map the data record, the tree root node of the data group is generated based on the leaf node, and the tree root node of each data group is used to verify the data integrity of the verifiable data. The target data and the verifiable data are synchronized to the slave database node of the distributed database through a binary log. The target data is obtained in the master database node, and the target data is converted into the verifiable data, which is synchronized to the slave database node through the binary log, so that the mirror data in the slave database node is consistent with the target data and the verifiable data in the master database node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of cloud computing technology, and in particular to a data generation method, apparatus, and device for distributed databases. Background Technology

[0002] A distributed database is a database system that distributes data across multiple nodes and communicates and collaborates via a network. It is widely used in the data service industry due to its high scalability and high availability. A distributed database system typically consists of a master database node and multiple slave database nodes. The master database node provides data writing and reading services, while the slave database nodes only provide data reading services.

[0003] In related technologies, in order to achieve the function of preventing data tampering, database nodes record the original data written to the database and generate corresponding verifiable data. The verifiable data is then used to compare and verify the original data stored in the database node, so as to ensure the integrity of the original data at the database node.

[0004] However, in distributed database systems, since the master and slave database nodes operate asynchronously, inconsistencies can arise in the verifiable data generated by the master and slave database nodes, which in turn affects the normal operation of the data anti-tampering function of the slave database node. Summary of the Invention

[0005] This disclosure provides a data generation method, apparatus, and device for distributed databases to overcome the problem of inconsistency between verifiable data generated by master and slave database nodes.

[0006] In a first aspect, embodiments of this disclosure provide a data generation method for a distributed database, including:

[0007] Obtain target data from the master database node of the distributed database, the target data containing at least two data records; based on the target data, generate corresponding verifiable data, wherein the verifiable data includes at least one data group with a tree structure, the leaf nodes of the data group are used to map the data records, the root node of the data group is generated based on the leaf nodes, and the root nodes of each data group are used to jointly verify the data integrity of the verifiable data; synchronize the target data and the verifiable data to the slave database node of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and the verifiable data respectively on the slave database node.

[0008] Secondly, embodiments of this disclosure provide a data generation apparatus for a distributed database, comprising:

[0009] The acquisition module is used to acquire target data within the master database node of the distributed database, wherein the target data contains at least two data records;

[0010] A generation module is used to generate corresponding verifiable data based on the target data. The verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map the data records. The root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data.

[0011] The synchronization module is used to synchronize the target data and the verifiable data to the slave database nodes of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and the verifiable data respectively on the slave database nodes.

[0012] Thirdly, embodiments of this disclosure provide an electronic device, including: a processor and a memory;

[0013] The memory stores computer-executed instructions;

[0014] The processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the data generation method for a distributed database as described in the first aspect and various possible designs of the first aspect.

[0015] Fourthly, embodiments of this disclosure provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the data generation method for a distributed database as described in the first aspect and various possible designs of the first aspect.

[0016] Fifthly, embodiments of this disclosure provide a computer program product, including a computer program that, when executed by a processor, implements the data generation method for a distributed database as described in the first aspect and various possible designs of the first aspect.

[0017] This embodiment provides a data generation method, apparatus, and device for distributed databases. The method involves acquiring target data from the master database node of the distributed database. The target data contains at least two data records. Based on the target data, corresponding verifiable data is generated. This verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map the data records, and the root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data. The target data and the verifiable data are synchronized to the slave database node of the distributed database via binary logs, thereby generating mirror data corresponding to the target data and the verifiable data on the slave database node. By acquiring the target data from the master database node, converting it into verifiable data containing multiple data groups with a tree structure, and synchronizing it to the slave database node via binary logs to generate mirror data, the method ensures that the mirror data on the slave database node is consistent with the target data and verifiable data on the master database node, enabling the data anti-tampering function of the slave database node to operate normally. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a schematic diagram illustrating an application scenario of the anti-tampering function provided in an embodiment of this disclosure;

[0020] Figure 2 A flowchart illustrating the data generation method for a distributed database provided in this embodiment of the disclosure. Figure 1 ;

[0021] Figure 3 This is a schematic diagram of the structure of verifiable data provided in an embodiment of the present disclosure;

[0022] Figure 4 for Figure 2 A flowchart illustrating the specific implementation of step S102 in the illustrated embodiment;

[0023] Figure 5 This is a schematic diagram illustrating a process of generating mirrored data from a database node, as provided in an embodiment of the present disclosure.

[0024] Figure 6 A flowchart illustrating the data generation method for a distributed database provided in this embodiment of the disclosure. Figure 2 ;

[0025] Figure 7 for Figure 6 A flowchart illustrating the specific implementation of step S204 in the illustrated embodiment;

[0026] Figure 8 A schematic diagram illustrating a process for generating verifiable log data, provided in an embodiment of this disclosure;

[0027] Figure 9 This is a structural block diagram of a data generation apparatus for a distributed database provided in an embodiment of the present disclosure;

[0028] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure;

[0029] Figure 11 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.

[0031] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0032] The application scenarios of the embodiments of this disclosure are explained below:

[0033] The data generation method for distributed databases provided in this disclosure can be applied to tamper-proof data generation scenarios in distributed database systems. Specifically, this solution can be applied to servers or electronic devices with similar functions that deploy master database nodes or independent control nodes in distributed database systems. The server or electronic device can implement the data generation method for distributed databases provided in this disclosure by running various computer-executable instructions or computer programs. For example, computer-executable instructions can be program-level commands, machine instructions, or software instructions. Computer programs can be native programs or software modules in an operating system; they can be local applications, i.e., programs that need to be installed in the operating system to run; or they can be small programs embedded in any APP, i.e., programs that run based on a browser environment. In summary, the aforementioned computer-executable instructions can be any form of instruction, and the aforementioned computer programs can be any form of application, module, or plugin, and the specific implementation can be configured as needed.

[0034] Figure 1 This is a schematic diagram illustrating an application scenario of an anti-tampering function provided in an embodiment of this disclosure, such as... Figure 1 As shown, the distributed database consists of a master database node and multiple slave database nodes. The master database node can generate original data in the database by receiving write commands from user-operated terminal devices, and can synchronize this original data to the slave database nodes to form mirrored data. Simultaneously, the master database node can also receive read commands from terminal devices to access the original data in the database. The slave database nodes only provide data read services, accessing the mirrored data in the database by receiving read commands from terminal devices. In this distributed database system, to achieve data tamper-proofing, the master database node constructs corresponding verifiable data based on the original data. This verifiable data is then used to compare and verify the original data stored within the database node, ensuring the integrity of the original data at that database node.

[0035] However, because the process of constructing verifiable data, relative to the writing of the original data and the synchronization to the slave database node, is executed asynchronously by the master database node—for example, periodically obtaining newly written original data and constructing it into verifiable data—the size and content of the verifiable data constructed based on the original data may exhibit a degree of randomness. In this situation, if the slave database node also independently constructs corresponding verifiable data based on the received original data, the verifiable data constructed by the slave database node will be inconsistent with the verifiable data of the master database node. This will cause the slave database node's data synchronization and abnormal data location functions to malfunction, thus rendering the data anti-tampering function ineffective.

[0036] This disclosure provides a data generation method for distributed databases to solve the above-mentioned problems.

[0037] refer to Figure 2 , Figure 2 A flowchart illustrating the data generation method for a distributed database provided in this embodiment of the disclosure. Figure 1 The method of this embodiment can be applied to servers or other electronic devices used to deploy master database nodes or control nodes in a distributed database system. For example, the data generation method for a distributed database provided in this embodiment includes:

[0038] Step S101: Obtain the target data within the master database node of the distributed database. The target data contains at least two data records.

[0039] Step S102: Based on the target data, generate corresponding verifiable data, wherein the verifiable data includes at least one data group with a tree structure, the leaf nodes of the data group are used to map data records, the root node of the data group is generated based on the leaf nodes, and the root nodes of each data group are used to jointly verify the data integrity of the verifiable data.

[0040] Step S103: Synchronize the target data and verifiable data to the slave database nodes of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and verifiable data respectively on the slave database nodes.

[0041] refer to Figure 1The illustrated application scenario diagram illustrates a data generation method for distributed databases, presented in this embodiment using a server as the execution entity. For example, the server can retrieve target data from the master database node of the distributed database based on a fixed period or other user-configured triggering conditions. This retrieval is asynchronous; the server maintains an independent processing flow to retrieve the target data, which is independent of the process of writing data to the master database node. The target data can be one or more data tables, each containing multiple data records. These records represent specific user data and can be stored in the data table as rows, such as product data, transaction data, or other specific business data. The specific content of the data records is not limited here.

[0042] Subsequently, the server constructs verifiable data with a special data format based on the target data. Specifically, the verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map data records, and the root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data.

[0043] Specifically, verifiable data is a data structure with a forest structure (including one or more tree-like structures). A data group constituting verifiable data is equivalent to a subset of verifiable data. It is a tree-like structure composed of leaf nodes, root nodes, and other components, such as complete binary trees and Merkle trees. The leaf nodes are located at the very end of the data group and are used to store or map the target data. In one possible implementation, the leaf nodes store a data digest of the target data. The data digest is data representing the content of a data record, obtained by performing methods such as hash calculations on the data records in the target data. By hashing one or more data records, a corresponding data digest can be obtained and stored in the leaf node. When a data record is modified, the data digest obtained through the hash mapping will change. Therefore, by comparing the data in the leaf nodes of the tamper-proof data group, the modification of the data record can be detected.

[0044] Furthermore, the tree-structured data set also includes at least one root node at the top level of the tree structure. This root node data is generated based on the corresponding leaf nodes. In one possible implementation, the root node and leaf nodes are adjacent, meaning the root node is the parent node of a leaf node. The root node can be directly obtained by hashing at least two leaf nodes. In another possible implementation, at least one intermediate node is included between the root node and leaf nodes. This intermediate node is obtained by concatenating and hashing at least two leaf nodes. The parent node of the intermediate node is then concatenated and hashed, and this process is repeated recursively until the root node of the data set is finally calculated.

[0045] Furthermore, if the verifiable data with a forest structure includes one or more data groups, then the root node data of each data group is used to jointly verify the data integrity of the verifiable data. For example, after retrieving log records from the database, the log records are hashed multiple times according to the data structure of the data group (the same calculation process as when generating the data group), resulting in a calculated hash value. This calculated hash value is then compared with the verification hash value calculated based on the root nodes of each data group in the verifiable data corresponding to the target data. If the calculated hash value matches the verification hash value of the verifiable data, it indicates that the data record corresponding to the target data is complete and has not been tampered with; otherwise, it has been tampered with. The verification hash values ​​calculated by the root nodes of each data group in the verifiable data are configured to be immutable.

[0046] Figure 3 This is a schematic diagram of the structure of verifiable data provided in an embodiment of this disclosure, such as... Figure 3As shown, the verifiable data includes data groups T1, T2, and T3. Data group T1 includes leaf nodes P1, P2, P3, and P4 within the leaf node layer; data group T2 includes leaf nodes P5 and P6 within the leaf node layer; and data group T3 includes leaf nodes P7 and P8 within the leaf node layer (shown as P1, P2, P3, P4, P5, P6, P7, and P8 in the diagram). The leaf nodes P1 to P8 are arranged consecutively, and each leaf node stores a data digest of data records R1, R2, R3, R4…R32 from the target data. Furthermore, data group T1 includes the root node Root_1 within the root node layer; data group T2 includes the root node Root_2 within the root node layer; and data group T3 includes the root node Root_3 within the root node layer. In data group T2, the root node Root_2 is directly generated based on the corresponding leaf nodes P5 and P6, for example, by concatenating leaf nodes P7 and P8 and then performing a hash calculation. In data group T3, the root node Root_3 is directly generated based on the corresponding leaf nodes P7 and P8. In data group T1, the root node Root_1 is obtained by first calculating the intermediate nodes M1 and M2 in pairs from leaf nodes P1, P2, P3, and P4, and then performing a hash calculation on the intermediate nodes M1 and M2 (shown as M1 and M2 in the diagram). The root node at the top level of each data group represents the data integrity of a data record group within the target data. When any data record within a data record group in the target data is modified, the value of this root node changes. This change in the root node's value alters the calculated hash value generated based on each root node, making it unable to match the verification hash value of the verifiable data corresponding to the target data. Consequently, the consistency verification of the target data fails, indicating that modification has been detected. This method effectively prevents tampering of the target data.

[0047] In one possible implementation, such as Figure 4 As shown, the specific implementation of step S102 includes:

[0048] Step S1021: Obtain the preset maximum data length;

[0049] Step S1022: Based on the maximum data length, read the data records in the target data to obtain at least one data record group, wherein the length of the data record group is not greater than the maximum data length;

[0050] Step S1023: Construct the data group corresponding to each data record group, and obtain verifiable data based on the set of each data group.

[0051] For example, before constructing verifiable data, the server uses an independent asynchronous thread to select data records of no more than a preset maximum data length (e.g., 100 records) and define them as a data record block. When there are many data records to be processed in the target data, the resulting data record block has a larger length, and vice versa. Therefore, the data length of the data record block has a certain degree of randomness. Then, based on the data record blocks, corresponding data groups are constructed, and the set of data groups constitutes verifiable data. The maximum data length determines the data's tamper-proof performance. A larger maximum data length means more data records are generated in the same data group, resulting in higher space utilization but lower tamper-proof performance. Therefore, in one possible implementation, the maximum data length can be determined based on the data type of the target data. That is, the maximum data length is obtained according to the data type of the target data. Different data types determine the corresponding maximum data length, matching the data type with the performance requirements of the tamper-proof function and improving the resource utilization of storage space.

[0052] The process of generating verifiable data described above can be executed within the master database node. Afterwards, the master and slave database nodes synchronize data via binary logs (binlog), synchronizing the target data and its corresponding verifiable data to the slave database node. This ensures that the slave database node generates mirror data identical to the target and verifiable data within the master database node, while also providing data tamper-proof functionality. Users can then access the verifiable data corresponding to the target data from the slave database node to verify the integrity of the target data and prevent data tampering.

[0053] Figure 5 This is a schematic diagram illustrating a process of generating mirrored data from a database node, provided by an embodiment of this disclosure. The following is in conjunction with... Figure 5 To further explain the above process, such as... Figure 5 As shown, after a user sends a write command to the master database node and writes the original data, the server asynchronously configures a portion of the original data stored in the master database node as target data with tamper-proof functionality. Then, based on this target data, corresponding verifiable data is constructed. After generating the verifiable data, the target data and the corresponding verifiable data are synchronized to the slave database nodes through the binary log in the distributed database system, generating mirror data of the target data and mirror data of the verifiable data. This ensures that the target data and verifiable data stored in the slave database nodes are consistent with those in the master database node.

[0054] Furthermore, in one possible implementation, the target data table is stored within the master database node, and before step S101, the following steps are also included:

[0055] Step S100: In response to the first configuration statement input by the user, configure the target data table as a tamper-proof data table.

[0056] Accordingly, the specific implementation of step S101 includes:

[0057] Step S101A: Asynchronously retrieve data records from the target data table within the main database node.

[0058] For example, before executing the above-mentioned generation of verifiable data corresponding to the target data, the server can configure the data table specified by the first configuration statement as a tamper-proof data table according to the first configuration statement input by the user. Specifically, for example, the main database node stores data tables sheet_1, sheet_2, and sheet_3, which are used to store different business data. Based on this, by responding to the first configuration statement input by the user, the server configures the data table sheet_2 as a tamper-proof data table. Then, the server will use the data table sheet_2 as the target data, obtain the data records in the data table sheet_2, and construct the verifiable data corresponding to the data table sheet_2 based on the data records, thereby realizing the tamper-proof function of the data table sheet_2 and improving configuration flexibility. In another possible implementation, the server can also automatically determine the data table of the target business type as the target data according to the business type of each data table in the main database node, and generate the corresponding verifiable data, thereby activating the tamper-proof function of the data table of the target business type and improving data security.

[0059] In this embodiment, target data containing at least two data records is obtained from the master database node of the distributed database. Based on the target data, corresponding verifiable data is generated. This verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map data records, and the root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data. The target data and verifiable data are synchronized to the slave database nodes of the distributed database via binary logs to generate mirror data corresponding to the target data and verifiable data on the slave database nodes. By obtaining the target data from the master database node, converting it into verifiable data containing multiple data groups with a tree structure, and synchronizing it to the slave database nodes via binary logs to generate mirror data, the mirror data in the slave database nodes is ensured to be consistent with the target data and verifiable data in the master database node, enabling the data anti-tampering function of the slave database nodes to operate normally.

[0060] refer to Figure 6 , Figure 6 A flowchart illustrating the data generation method for a distributed database provided in this embodiment of the disclosure. Figure 2 This embodiment is in Figure 2 Based on the illustrated embodiment, step S102 is further refined, and a step of generating verifiable log data is added. This data generation method for distributed databases includes:

[0061] Step S201: Write the newly added data input by the user to the main database node through the first processing process.

[0062] Step S202: Through the second processing process, periodically read the newly added data in the main database node to obtain the target data.

[0063] For example, in a distributed database application scenario, the master database node generates verifiable data through asynchronous sampling and processing. Specifically, the master database node responds to user input commands through a first processing process, writing the newly added data input by the user into the master database. On the other hand, the master database node periodically reads the aforementioned newly added data from its own database through a separate second processing process, using this data as target data to construct corresponding verifiable data, thus making the newly added data tamper-proof. Generating verifiable data through asynchronous processing can fully utilize computing resources and improve resource utilization efficiency.

[0064] Step S203: Through the second processing process, based on the maximum data length, read the data records in the target data to obtain at least one data record group, wherein the length of the data record group is not greater than the maximum data length.

[0065] Step S204: Construct the data groups corresponding to each data record group through the second processing process.

[0066] Step S205: Through the second processing process, verifiable data is obtained based on the set of each data group.

[0067] For example, after selecting target data, a second processing process periodically reads data records from the target data based on the maximum data length, and combines them into at least one data record group based on the number of data records, wherein the length of the data record group is no greater than the maximum data length. Then, based on this data record group, a corresponding data set is constructed.

[0068] In one possible implementation, such as Figure 7 As shown, the specific implementation of step S204 includes:

[0069] Step S2041: Calculate the data summary for each data record in the data record group. The data summary is used to characterize the record content of the data record.

[0070] Step S2042: Group the data digest as leaf nodes to obtain at least one leaf node group;

[0071] Step S2043: Concatenate the data digests corresponding to the leaf nodes in each leaf node group, and perform hash mapping on the concatenation results to obtain the upper-level root node corresponding to each leaf node group.

[0072] Step S2044: Based on each upper-level root node, calculate the root node of the data group to obtain the data group.

[0073] For example, regarding the specific implementation of constructing a data group, firstly, through a second processing step, data digests are extracted from each data record in the data record group. For instance, this is done by performing hash calculations on the data records to obtain data digests representing the content of the data records. Then, using the data digests as leaf nodes of the data group, a series of consecutively arranged leaf nodes can be obtained. Taking the case where the array structure of the data group is a complete binary tree as an example, every two adjacent leaf nodes form a leaf node group. Of course, it is understandable that when the data group has other tree structures, more leaf nodes can be used to form leaf node groups, such as every four adjacent leaf nodes forming a leaf node group. The specific implementation of the leaf node groups is not limited here. Next, for each leaf node group, the data digests stored in the leaf nodes within the leaf node group are concatenated, and the concatenation result is hashed to obtain the corresponding upper-level root node of the leaf node group. Following this pattern, the adjacent upper-level root nodes are grouped together, and the upload root nodes within each group are concatenated and hashed to obtain the upload root node at the next higher level. This process is repeated until the root node of the data group is calculated. Finally, based on the leaf nodes, intermediate nodes, and root node, and their mapping relationships (i.e., the tree structure), the data group corresponding to the data record group is obtained. Afterward, the above process is repeated to obtain the data groups corresponding to all data record values ​​of the target data. Combining these data groups generates verifiable data.

[0074] For example, verifiable data includes a verifiable data table, and the steps in this embodiment further include:

[0075] Step S2045: Write the non-root nodes in the data group to the verifiable data table, and write the root node of the data group to the system metadata table.

[0076] For example, when verifiable data is implemented in the form of a data table, after obtaining the node data of each level corresponding to the data group, the data corresponding to the leaf nodes and intermediate nodes are written into the verifiable data table, and the root node of the data group is written into the system metadata table. The system metadata table has the characteristic of being immutable, thereby ensuring the immutability of the verifiable data. Then, based on the root node of each data group, the integrity verification of the target data can be achieved.

[0077] Furthermore, on the other hand, before generating verifiable data corresponding to the target data to prevent tampering of the target data, the server can also generate verifiable log data corresponding to the target log data within the database node, thereby achieving tamper-proofing of the target log data. Specifically, this embodiment also includes:

[0078] Step S206: Asynchronously obtain the target log data within the target database node of the distributed database. The target log data contains at least two operation log records. The target database node is the master database node and / or the slave database node.

[0079] Step S207: Based on the target log data, generate corresponding verifiable log data locally on the target database node.

[0080] For example, log data is used to record operations performed on data in a database. For instance, after a user accesses specific data in the database, corresponding access log data is generated to record this operation. There is also a need to prevent tampering with such data logs. In this embodiment, while implementing tamper-proofing for the target data (data records), tamper-proofing for the target log data (operation log records) can also be implemented. Specifically, the database node can generate corresponding verifiable log data based on the target log data stored in the database. When the target log data is modified, the calculated hash value generated based on the target log data will be inconsistent with the verification hash value corresponding to the verifiable log data, thereby achieving tamper-proofing for the target log data. The data structure of the verifiable log data is similar to that of the verifiable data, both consisting of data groups with a tree structure. The leaf nodes of the data groups of the verifiable log data are used to map operation log records, and the root nodes of the data groups are generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable log data. The specific implementation methods for obtaining target log data and generating verifiable log data based on the target log data can be found in the previous embodiments, and will not be repeated here.

[0081] Furthermore, the step of generating verifiable log data corresponding to the target log data is similar to the step of generating verifiable data; it is also executed asynchronously by the database nodes. That is, the processes of generating the target log data and generating verifiable log data within the database node are executed asynchronously by different threads / processes. However, unlike the step of generating verifiable data, both the master and slave database nodes can generate log data separately, asynchronously acquire the target log data, and generate verifiable log data based on the target log data, without needing to synchronize the verifiable log data through binary logs. In other words, the target log data within the target database node of the distributed database is acquired asynchronously, and the corresponding verifiable log data is generated locally on the target database node based on the target log data. Here, the target database node is the master database node and / or the slave database node.

[0082] In one possible implementation, the method of this embodiment further includes:

[0083] Step S2060: Respond to the user access command through the third processing process and generate the operation log record corresponding to the user access command on the target database node that received the user access command.

[0084] Accordingly, the specific implementation of step S206 includes: periodically reading the operation log records in the target database node through the fourth processing process to obtain the target log data.

[0085] For example, the third processing process can be a process of the master database node or a process of the slave database node. That is, when a user accesses data in the master or slave database node, the master or slave database node receiving the user's access instruction will generate a corresponding operation log record locally, including information such as access time and visitor identifier. Afterwards, the master or slave database node will periodically read the operation log record in the target database node through an independent fourth processing process, using it as the target log data. In subsequent steps, based on the tamper-proof data structure and the target log data, corresponding verifiable log data is constructed, thus implementing tamper-proof functionality for the target log data.

[0086] Optionally, the target database node stores a target log table, and before step S206, the following steps are also included:

[0087] In response to the second configuration statement input by the user, the target log table in the target database node is configured as an anti-tampering log table. Accordingly, the specific implementation of step S206 includes: asynchronously obtaining log records in the target log table in the target database node.

[0088] For example, before acquiring the target log data, the master or slave database node stores log records in the form of a log table. The master or slave node can configure specific log records as tamper-proof data by receiving a second configuration statement from the user, i.e., configuring the target log table as a tamper-proof log table. Then, by asynchronously acquiring the log records in the target log table within the target database node, verifiable log data is generated based on these records, thus recording the content of the target log table and achieving the purpose of verifying the integrity of the target log table based on the verifiable log data.

[0089] Figure 8 This is a schematic diagram illustrating a process for generating verifiable log data, as provided in an embodiment of the present disclosure. Figure 8As shown, the distributed database includes a master database node P1, slave database nodes P2 and P3. After receiving a user access command from the user, each of the master, slave, and slave nodes generates a corresponding operation log record locally, such as operation log record R1 on the master node P1, operation log record R2 on the slave node P2, and operation log record R3 on the slave node P3. Then, each of the master, slave, and slave nodes asynchronously processes its generated operation log record, generating corresponding verifiable log data locally, i.e., verifiable log data mR1 on the master node P1, mR2 on the slave node P2, and mR3 on the slave node P3. Although the database nodes communicate with each other, the verifiable log data within each database node is not synchronized. Instead, it is used to verify the integrity of the target log data within each database node, thus implementing the anti-tampering function for the operation log records of each database node.

[0090] Corresponding to the data generation method for distributed databases in the above embodiments, Figure 9 This is a structural block diagram of a data generation apparatus for a distributed database provided in an embodiment of this disclosure. The method described in the above embodiments can be executed by this data generation apparatus for a distributed database. This apparatus can be implemented in software and / or hardware, and can be integrated into an electronic device with certain data processing capabilities. The electronic device may include, but is not limited to, mobile terminals with big data processing capabilities, as well as fixed terminals with big data processing capabilities such as desktop computers and supercomputers.

[0091] For ease of explanation, only the parts relevant to embodiments of this disclosure are shown. (Refer to...) Figure 9 The data generation device 3 for distributed databases includes:

[0092] The acquisition module 31 is used to acquire target data within the master database node of the distributed database. The target data contains at least two data records.

[0093] The generation module 32 is used to generate corresponding verifiable data based on the target data. The verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map data records. The root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data.

[0094] Synchronization module 33 is used to synchronize target data and verifiable data to slave database nodes of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and verifiable data respectively on the slave database nodes.

[0095] According to one or more embodiments of this disclosure, the generation module 32 is specifically configured to: obtain the maximum data length according to the data type of the target data; read data records in the target data based on the maximum data length to obtain at least one data record group, wherein the length of the data record group is not greater than the maximum data length; construct data groups corresponding to each data record group, and obtain verifiable data based on the set of each data group.

[0096] According to one or more embodiments of this disclosure, when constructing the data group corresponding to each data record group, the generation module 32 is specifically used to: calculate the data digest of each data record in the data record group, the data digest being used to characterize the record content of the data record; group the data digests as leaf nodes to obtain at least one leaf node group; concatenate the data digests corresponding to the leaf nodes in each leaf node group, and perform hash mapping on the concatenation result to obtain the upper-level root node corresponding to each leaf node group; and calculate the root node of the data group based on each upper-level root node to obtain the data group.

[0097] According to one or more embodiments of this disclosure, the verifiable data includes a verifiable data table. When the generation module 32 obtains verifiable data based on the collection of each data group, it is specifically used to: write the non-root nodes in the data group into the verifiable data table and write the root nodes of the data group into the system metadata table.

[0098] According to one or more embodiments of this disclosure, before obtaining the target data in the master database node of the distributed database, the acquisition module 31 is further configured to: write the newly added data input by the user to the master database node through a first processing process; when obtaining the target data in the master database node of the distributed database, the acquisition module 31 is specifically configured to: periodically read the newly added data in the master database node through a second processing process to obtain the target data.

[0099] According to one or more embodiments of this disclosure, a target data table is stored in the main database node; the acquisition module 31 is further configured to: in response to a first configuration statement input by the user, configure the target data table as an anti-tampering data table; the acquisition module 31 is specifically configured to: asynchronously acquire data records in the target data table in the main database node.

[0100] According to one or more embodiments of this disclosure, the acquisition module 31 is further configured to: asynchronously acquire target log data within the target database node of the distributed database, the target log data containing at least two operation log records, the target database node being the master database node and / or the slave database node; the generation module 32 is further configured to: generate corresponding verifiable log data locally on the target database node based on the target log data.

[0101] According to one or more embodiments of this disclosure, the acquisition module 31 is further configured to: respond to a user access instruction through a third processing process and generate an operation log record corresponding to the user access instruction in the target database node that receives the user access instruction; when the acquisition module 31 asynchronously acquires the target log data in the target database node of the distributed database, it is specifically configured to: periodically read the operation log record in the target database node through a fourth processing process to obtain the target log data.

[0102] According to one or more embodiments of this disclosure, a target log table is stored in the target database node; the acquisition module 31 is further configured to: in response to a second configuration statement input by the user, configure the target log table in the target database node as an anti-tampering log table; when the acquisition module 31 asynchronously acquires the target log data in the target database node of the distributed database, it is specifically configured to: asynchronously acquire the log records in the target log table in the target database node.

[0103] The acquisition module 31, generation module 32, and synchronization module 33 are connected sequentially. The data generation device 3 for distributed databases provided in this embodiment can execute the technical solutions of the above-described method embodiments, and its implementation principle and technical effects are similar; therefore, they will not be described again here.

[0104] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure, such as... Figure 10 As shown, the electronic device 4 includes:

[0105] Processor 41, and memory 42 communicatively connected to processor 41;

[0106] Memory 42 stores instructions executed by the computer;

[0107] The processor 41 executes computer execution instructions stored in the memory 42 to achieve, for example, Figures 2-8 The data generation method for a distributed database shown in the embodiment.

[0108] Optionally, the processor 41 and the memory 42 are connected via a bus 43.

[0109] For relevant instructions, please refer to the corresponding text. Figures 2-8The relevant descriptions and effects of the steps in the corresponding embodiments are understood, and will not be elaborated on here.

[0110] This disclosure provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement this disclosure. Figures 2-8 The data generation method for distributed databases provided in any of the corresponding embodiments.

[0111] This disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements this disclosure. Figures 2-8 The data generation method for distributed databases provided in any of the corresponding embodiments.

[0112] To implement the above embodiments, this disclosure also provides an electronic device.

[0113] refer to Figure 11 The diagram illustrates a structural schematic of an electronic device 900 suitable for implementing embodiments of the present disclosure. The electronic device 900 can be a terminal device or a server. The terminal device can include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, personal digital assistants (PDAs), tablet computers, portable media players (PMPs), and in-vehicle terminals (e.g., in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers. Figure 11 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0114] like Figure 11 As shown, the electronic device 900 may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage device 908 into a random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device 900. The processing unit 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0115] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic device 900 to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 11 An electronic device 900 with various devices is shown; however, it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed alternatively.

[0116] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a storage device 908, or installed from a ROM 902. When the computer program is executed by a processing device 901, it performs the functions defined in the methods of embodiments of this disclosure.

[0117] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0118] The aforementioned computer-readable medium may be included in the aforementioned electronic device; or it may exist independently and not assembled into the electronic device.

[0119] The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.

[0120] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0121] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0122] The units or modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the units or modules do not necessarily limit the specific unit itself.

[0123] The functions described above in this document can be performed, at least in part, by one or more hardware logic components. For example, exemplary types of hardware logic components that can be used, without limitation, include: Field Programmable Gate Arrays (FPGAs), Application-Specific Integrated Circuits (ASICs), Application Standard Products (ASSPs), System-on-Chip (SoCs), Complex Programmable Logic Devices (CPLDs), and so on.

[0124] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0125] In a first aspect, according to one or more embodiments of this disclosure, a data generation method for a distributed database is provided, comprising:

[0126] Obtain target data from the master database node of the distributed database, the target data containing at least two data records; based on the target data, generate corresponding verifiable data, wherein the verifiable data includes at least one data group with a tree structure, the leaf nodes of the data group are used to map the data records, the root node of the data group is generated based on the leaf nodes, and the root nodes of each data group are used to jointly verify the data integrity of the verifiable data; synchronize the target data and the verifiable data to the slave database node of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and the verifiable data respectively on the slave database node.

[0127] According to one or more embodiments of this disclosure, generating corresponding verifiable data based on the target data includes: obtaining a maximum data length based on the data type of the target data; reading data records in the target data based on the maximum data length to obtain at least one data record group, wherein the length of the data record group is not greater than the maximum data length; constructing a data group corresponding to each data record group, and obtaining the verifiable data based on the set of each data group.

[0128] According to one or more embodiments of this disclosure, constructing a data group corresponding to each of the data record groups includes: calculating a data digest for each data record in the data record group, the data digest being used to characterize the record content of the data record; grouping the data digests as leaf nodes to obtain at least one leaf node group; concatenating the data digests corresponding to the leaf nodes in each leaf node group and performing a hash mapping on the concatenation result to obtain the upper-level root node corresponding to each of the leaf node groups; and calculating the root node of the data group based on each upper-level root node to obtain the data group.

[0129] According to one or more embodiments of this disclosure, the verifiable data includes a verifiable data table, and obtaining the verifiable data based on the set of each of the data groups includes: writing non-root nodes in the data group into the verifiable data table, and writing root nodes of the data group into the system metadata table.

[0130] According to one or more embodiments of this disclosure, before obtaining the target data within the master database node of the distributed database, the method further includes: writing new data input by the user to the master database node through a first processing process; obtaining the target data within the master database node of the distributed database includes: periodically reading the new data within the master database node through a second processing process to obtain the target data.

[0131] According to one or more embodiments of this disclosure, the master database node stores a target data table; the method further includes: in response to a first configuration statement input by a user, configuring the target data table as a tamper-proof data table; the step of obtaining the target data in the master database node of the distributed database includes: asynchronously obtaining data records in the target data table in the master database node.

[0132] According to one or more embodiments of this disclosure, the method further includes: asynchronously acquiring target log data within a target database node of a distributed database, the target log data containing at least two operation log records, the target database node being a master database node and / or a slave database node; and generating corresponding verifiable log data locally on the target database node based on the target log data.

[0133] According to one or more embodiments of this disclosure, the method further includes: responding to a user access instruction through a third processing process, and generating an operation log record corresponding to the user access instruction at the target database node receiving the user access instruction; the asynchronous acquisition of target log data within the target database node of the distributed database includes: periodically reading the operation log records within the target database node through a fourth processing process to obtain the target log data.

[0134] According to one or more embodiments of this disclosure, the target database node stores a target log table; the method further includes: in response to a second configuration statement input by a user, configuring the target log table in the target database node as a tamper-proof log table; the asynchronous acquisition of target log data in the target database node of the distributed database includes: asynchronously acquiring log records in the target log table in the target database node.

[0135] Secondly, according to one or more embodiments of this disclosure, a data generation apparatus for a distributed database is provided, comprising:

[0136] The acquisition module is used to acquire target data within the master database node of the distributed database, wherein the target data contains at least two data records;

[0137] A generation module is used to generate corresponding verifiable data based on the target data. The verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map the data records. The root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data.

[0138] The synchronization module is used to synchronize the target data and the verifiable data to the slave database nodes of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and the verifiable data respectively on the slave database nodes.

[0139] According to one or more embodiments of this disclosure, the generation module is specifically configured to: obtain a maximum data length based on the data type of the target data; read data records in the target data based on the maximum data length to obtain at least one data record group, wherein the length of the data record group is not greater than the maximum data length; construct a data group corresponding to each data record group, and obtain the verifiable data based on the set of each data group.

[0140] According to one or more embodiments of this disclosure, when constructing the data group corresponding to each of the data record groups, the generation module is specifically configured to: calculate a data digest for each data record in the data record group, wherein the data digest is used to characterize the record content of the data record; group the data digests as leaf nodes to obtain at least one leaf node group; concatenate the data digests corresponding to the leaf nodes in each leaf node group and perform hash mapping on the concatenation result to obtain the upper-level root node corresponding to each of the leaf node groups; and calculate the root node of the data group based on each upper-level root node to obtain the data group.

[0141] According to one or more embodiments of this disclosure, the verifiable data includes a verifiable data table, and when the generation module obtains the verifiable data based on the set of each data group, it is specifically used to: write the non-root nodes in the data group into the verifiable data table, and write the root nodes of the data group into the system metadata table.

[0142] According to one or more embodiments of this disclosure, before obtaining the target data within the master database node of the distributed database, the obtaining module is further configured to: write newly added data input by the user to the master database node through a first processing process; when obtaining the target data within the master database node of the distributed database, the obtaining module is specifically configured to: periodically read the newly added data within the master database node through a second processing process to obtain the target data.

[0143] According to one or more embodiments of this disclosure, the main database node stores a target data table; the acquisition module is further configured to: in response to a first configuration statement input by the user, configure the target data table as an anti-tampering data table; the acquisition module is specifically configured to: asynchronously acquire data records in the target data table within the main database node.

[0144] According to one or more embodiments of this disclosure, the acquisition module is further configured to: asynchronously acquire target log data within a target database node of a distributed database, the target log data containing at least two operation log records, the target database node being a master database node and / or a slave database node; the generation module is further configured to: generate corresponding verifiable log data locally on the target database node based on the target log data.

[0145] According to one or more embodiments of this disclosure, the acquisition module is further configured to: respond to a user access instruction through a third processing process, and generate an operation log record corresponding to the user access instruction at the target database node receiving the user access instruction; when the acquisition module asynchronously acquires target log data within the target database node of the distributed database, it is specifically configured to: periodically read the operation log record within the target database node through a fourth processing process to obtain the target log data.

[0146] According to one or more embodiments of this disclosure, the target database node stores a target log table; the acquisition module is further configured to: in response to a second configuration statement input by the user, configure the target log table in the target database node as a tamper-proof log table; when the acquisition module asynchronously acquires target log data in the target database node of the distributed database, it is specifically configured to: asynchronously acquire log records in the target log table in the target database node.

[0147] Thirdly, according to one or more embodiments of the present disclosure, an electronic device is provided, comprising: at least one processor and a memory;

[0148] The memory stores computer-executed instructions;

[0149] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the data generation method for a distributed database as described in the first aspect and various possible designs of the first aspect above.

[0150] Fourthly, according to one or more embodiments of the present disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, the data generation method for a distributed database as described in the first aspect and various possible designs of the first aspect is implemented.

[0151] Fifthly, according to one or more embodiments of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the data generation method for a distributed database as described in the first aspect and various possible designs of the first aspect.

[0152] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

[0153] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0154] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

Claims

1. A data generation method for distributed databases, characterized in that, include: Obtain target data from the master database node of a distributed database, wherein the target data contains at least two data records; Based on the target data, corresponding verifiable data is generated, wherein the verifiable data includes at least one data group with a tree structure, the leaf nodes of the data group are used to map the data records, the root node of the data group is generated based on the leaf nodes, and the root nodes of each data group are used to jointly verify the data integrity of the verifiable data. The target data and the verifiable data are synchronized to the slave database nodes of the distributed database using binary logs, so as to generate mirror data corresponding to the target data and the verifiable data respectively on the slave database nodes.

2. The method according to claim 1, characterized in that, The step of generating corresponding verifiable data based on the target data includes: Based on the data type of the target data, obtain the maximum data length; Based on the maximum data length, read data records from the target data to obtain at least one data record group, wherein the length of the data record group is not greater than the maximum data length; Construct data groups corresponding to each of the data record groups, and obtain the verifiable data based on the set of each of the data groups.

3. The method according to claim 2, characterized in that, The construction of the data groups corresponding to each of the data record groups includes: Calculate a data digest for each data record in the data record group, wherein the data digest is used to characterize the record content of the data record; The data digest is grouped as leaf nodes to obtain at least one leaf node group; The data digests corresponding to the leaf nodes in each leaf node group are concatenated, and the concatenation results are hashed to obtain the upper-level root node corresponding to each leaf node group. Based on each of the upper-level root nodes, the root node of the data group is calculated to obtain the data group.

4. The method according to claim 3, characterized in that, The verifiable data includes a verifiable data table, and the process of obtaining the verifiable data based on the set of each of the data groups includes: Write the non-root nodes in the data group to the verifiable data table, and write the root nodes of the data group to the system metadata table.

5. The method according to claim 1, characterized in that, Before obtaining the target data within the master database node of the distributed database, the method further includes: The newly added data input by the user is written to the main database node through the first processing process; The process of obtaining the target data within the master database node of the distributed database includes: The second processing step periodically reads newly added data from the main database node to obtain the target data.

6. The method according to claim 1, characterized in that, The main database node stores the target data table; the method further includes: In response to the first configuration statement input by the user, the target data table is configured as a tamper-proof data table; The process of obtaining the target data within the master database node of the distributed database includes: Asynchronously retrieve data records from the target data table within the main database node.

7. The method according to claim 1, characterized in that, The method further includes: Asynchronously obtain target log data within the target database node of the distributed database. The target log data contains at least two operation log records. The target database node is the master database node and / or the slave database node. Based on the target log data, corresponding verifiable log data is generated locally on the target database node.

8. The method according to claim 7, characterized in that, The method further includes: The third processing process responds to the user access command and generates an operation log record corresponding to the user access command at the target database node that receives the user access command. The asynchronous acquisition of target log data within the target database node of the distributed database includes: The fourth processing step periodically reads the operation log records within the target database node to obtain the target log data.

9. The method according to claim 7, characterized in that, The target database node stores a target log table; the method further includes: In response to the second configuration statement input by the user, the target log table in the target database node is configured as a tamper-proof log table; The asynchronous acquisition of target log data within the target database node of the distributed database includes: Asynchronously retrieve log records from the target log table within the target database node.

10. A data generation device for a distributed database, characterized in that, include: The acquisition module is used to acquire target data within the master database node of the distributed database, wherein the target data contains at least two data records; A generation module is used to generate corresponding verifiable data based on the target data. The verifiable data includes at least one data group with a tree structure. The leaf nodes of the data group are used to map the data records. The root node of the data group is generated based on the leaf nodes. The root nodes of each data group are used to jointly verify the data integrity of the verifiable data. The synchronization module is used to synchronize the target data and the verifiable data to the slave database nodes of the distributed database through binary logs, so as to generate mirror data corresponding to the target data and the verifiable data respectively on the slave database nodes.

11. An electronic device, characterized in that, include: Processor and memory; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the data generation method for a distributed database as described in any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the data generation method for a distributed database as described in any one of claims 1 to 9.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the data generation method for a distributed database as described in any one of claims 1 to 9.