Index data synchronization method, system and device
By using version numbers to control index data synchronization in a distributed database, the problem of contention for mutex locks and concurrency in index data synchronization is solved, costs are reduced, and processing capabilities are improved.
Patent Information
- Application Number
- CN202010605957.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-29
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2040-06-29
AI Technical Summary
The synchronization of index data in distributed databases has problems such as contention for mutex locks and reduced concurrency, resulting in high system development and maintenance costs.
By writing the index data to be synchronized in the key-value database of the target partition node, changing the temporary version number to the status version number according to the writing result, recording the transaction value, and synchronizing the data to the object storage node after detecting that the preset synchronization conditions are met. Use version numbers to control index data synchronization.
It improves the concurrency capability of index nodes, reduces development and maintenance costs, and improves the processing capability of index data to be synchronized.
Smart Images

Figure CN113297201B
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to an index data synchronization method, system and device. Background Art
[0002] With the development of Internet technology, databases are used in various scenarios, and indexes are a very important type of data in databases, which are responsible for quickly locating the data required for queries. Usually, distributed databases store indexes on local computers. In order to ensure availability, multiple disaster recovery nodes are often configured, and distributed consistency protocols are used to ensure the correctness of indexes. Multiple nodes and consistency protocols will significantly increase the development and maintenance costs of the system, and multiple partition nodes of distributed databases will frequently add index data. The use of global indexing solutions will cause problems with competing for mutex locks, or the use of partitioned indexing solutions will result in decreased concurrency. Therefore, an effective solution is urgently needed to solve the above problems. Summary of the invention
[0003] In view of this, an embodiment of the present application provides an index data synchronization method. The present application also relates to an index data synchronization system, an index data synchronization device, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of the present application, there is provided an index data synchronization method, comprising:
[0005] Get the index data to be synchronized submitted by the target partition node;
[0006] Writing the to-be-synchronized index data into the key-value database corresponding to the target partition node;
[0007] The value of the temporary version number is changed to the value of the state version number according to the writing result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data;
[0008] Recording the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node;
[0009] When it is detected that the transaction value after the record meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node.
[0010] Optionally, writing the to-be-synchronized index data into a key-value database corresponding to the target partition node includes:
[0011] Obtaining a node identifier of the target partition node;
[0012] Determine a target key value storage area of the target partition node in the key value database according to the node identifier;
[0013] The to-be-synchronized index data is written into the target key-value storage area.
[0014] Optionally, writing the to-be-synchronized index data into the target key-value storage area includes:
[0015] Determine the time information for submitting the index data to be synchronized;
[0016] Generate a key name of the index data to be synchronized based on the time information, and determine a key value and a data type of the index data to be synchronized;
[0017] The key-value item data of the to-be-synchronized index data is composed according to the key name, the key value and the data type, and written into the target key-value storage area.
[0018] Optionally, also include:
[0019] Determining a writing time for writing the to-be-synchronized index data into the key-value database;
[0020] Recording the write time into the metadata table of the key-value database;
[0021] Correspondingly, when it is detected that the transaction value after the record meets the preset synchronization condition, synchronizing the to-be-synchronized index data in the key-value database to the object storage node includes:
[0022] When it is detected that the transaction value after the record meets the preset synchronization condition, the metadata table of the key-value database is read to obtain the write time;
[0023] The to-be-synchronized index data in the key-value database is synchronized to the object storage node according to the write time.
[0024] Optionally, also include:
[0025] When it is detected that the recorded transaction value does not satisfy the preset synchronization condition, a step of detecting whether the transaction value satisfies the preset synchronization condition according to a time period is performed.
[0026] Optionally, after the step of synchronizing the to-be-synchronized index data in the key-value database to the object storage node is executed, the step further includes:
[0027] Receiving the synchronization result returned by the object storage node;
[0028] According to the synchronization result, the value of the state version number is updated;
[0029] The object version number is assigned a value based on the updated state version number; wherein the value of the object version number indicates that synchronization of the to-be-synchronized index data of the target partition node is complete.
[0030] Optionally, after the step of synchronizing the to-be-synchronized index data in the key-value database to the object storage node is executed, the step further includes:
[0031] Determine whether the value of the object version number after the assignment is greater than the value of the temporary version number after the change;
[0032] If so, the recorded transaction value is adjusted, and a synchronization completion result is sent to the target partition node according to the adjustment result.
[0033] Optionally, when the target partition node submits at least two index data to be synchronized within the time period, synchronizing the index data to be synchronized in the key-value database to the object storage node includes:
[0034] Determine a submission time for submitting the at least two index data to be synchronized;
[0035] Calculate the time difference between the starting index data and the ending index data in the at least two index data to be synchronized according to the submission time;
[0036] When the time difference is greater than or equal to the time period, the at least two index data to be synchronized in the key-value database are synchronized to the object storage node.
[0037] Optionally, the object storage node is a disaster recovery service node of the target partition node;
[0038] Correspondingly, after the step of synchronizing the to-be-synchronized index data in the key-value database to the object storage node is executed, the method further includes:
[0039] Receive an index data read request submitted by the target partition node;
[0040] Forwarding the index data read request to the disaster recovery service node, and receiving the target index data returned by the disaster recovery service node;
[0041] The target index data is sent to the target partition node for data processing operations.
[0042] According to a second aspect of an embodiment of the present application, there is provided an index data synchronization system, including:
[0043] Target partition nodes, index nodes and object storage nodes;
[0044] The target partition node is configured to obtain an operation request from a user; read the target data and perform a processing operation according to the user identifier included in the operation request; and send the generated index data to be synchronized to the index node according to the processing operation result;
[0045] The index node is configured to write the to-be-synchronized index data into the key-value database corresponding to the target partition node; change the value of the temporary version number to the value of the status version number according to the writing result; wherein the value of the temporary version number indicates the transaction status of the synchronization transaction corresponding to the target partition node, and the value of the status version number indicates the synchronization progress of the target partition node submitting the index data; record the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node; when it is detected that the recorded transaction value meets the preset synchronization condition, synchronize the to-be-synchronized index data in the key-value database to the object storage node;
[0046] The object storage node is configured to store the index data to be synchronized and return a synchronization result to the target partition node.
[0047] Optionally, writing the to-be-synchronized index data into a key-value database corresponding to the target partition node includes:
[0048] Obtaining a node identifier of the target partition node;
[0049] Determine a target key value storage area of the target partition node in the key value database according to the node identifier;
[0050] The to-be-synchronized index data is written into the target key-value storage area.
[0051] Optionally, writing the to-be-synchronized index data into the target key-value storage area includes:
[0052] Determine the time information for submitting the index data to be synchronized;
[0053] Generate a key name of the index data to be synchronized based on the time information, and determine a key value and a data type of the index data to be synchronized;
[0054] The key-value item data of the to-be-synchronized index data is composed according to the key name, the key value and the data type, and written into the target key-value storage area.
[0055] Optionally, the index node is further configured as:
[0056] Receive the synchronization result returned by the object storage node; update the value of the state version number according to the synchronization result; assign the object version number based on the value of the updated state version number; wherein the value of the object version number indicates that the synchronization of the to-be-synchronized index data of the target partition node is complete.
[0057] Optionally, the index node is further configured as:
[0058] Determine whether the value of the assigned object version number is greater than the value of the changed temporary version number; if so, adjust the recorded transaction value and send the synchronization completion result to the target partition node according to the adjustment result.
[0059] According to a third aspect of an embodiment of the present application, there is provided an index data synchronization device, including:
[0060] An acquisition module is configured to acquire the index data to be synchronized submitted by the target partition node;
[0061] A writing module is configured to write the to-be-synchronized index data into a key-value database corresponding to the target partition node;
[0062] A change module is configured to change the value of the temporary version number to the value of the state version number according to the write result; wherein the value of the temporary version number represents the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number represents the synchronization progress of the target partition node submitting the index data;
[0063] A recording module is configured to record a change behavior of the value of the temporary version number through a transaction value of a target synchronization transaction corresponding to the target partition node;
[0064] The synchronization module is configured to synchronize the to-be-synchronized index data in the key-value database to the object storage node when it is detected that the transaction value after the record meets the preset synchronization condition.
[0065] According to a fourth aspect of an embodiment of the present application, a computing device is provided, including:
[0066] Memory and processor;
[0067] The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions:
[0068] Get the index data to be synchronized submitted by the target partition node;
[0069] Writing the to-be-synchronized index data into the key-value database corresponding to the target partition node;
[0070] The value of the temporary version number is changed to the value of the state version number according to the writing result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data;
[0071] Recording the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node;
[0072] When it is detected that the transaction value after the record meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node.
[0073] According to a fifth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer-executable instructions, and when the instructions are executed by a processor, the steps of the index data synchronization method are implemented.
[0074] The index data synchronization method provided by the present application writes the to-be-synchronized index data submitted by the target partition node into a key-value database, changes the value of the temporary version number to the value of the state version number according to the writing result, and then records the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node, and finally detects the recorded transaction value, and when it is detected that the recorded transaction value meets the preset synchronization condition, synchronizes the to-be-synchronized index data in the key-value database to the object storage node; by adopting the version number method to control the synchronization of index data, the concurrency capability of the index node can be effectively improved, and by storing the to-be-synchronized index data through the object storage node, not only the development cost but also the maintenance cost can be reduced, thereby effectively improving the processing capability of the to-be-synchronized index data. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] Figure 1 is a flowchart of an index data synchronization method provided by an embodiment of the present application;
[0076] Figure 2 It is a processing flow chart of an index data synchronization method applied to a data addition scenario provided by an embodiment of the present application;
[0077] Figure 3 is a schematic diagram of an index data synchronization method provided by an embodiment of the present application;
[0078] Figure 4 It is a structural diagram of an index data synchronization system provided by an embodiment of the present application;
[0079] Figure 5 It is a structural diagram of an index data synchronization device provided by an embodiment of the present application;
[0080] Figure 6 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0081] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0082] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0083] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0084] First, the terms involved in one or more embodiments of the present application are explained.
[0085] Object storage: also called object-based storage, is a general term used to describe the method of solving and processing discrete units, which are called objects; object storage contains data like files, but unlike files, objects no longer have a hierarchical structure in a layered structure. Each object is at the same level in a flat address space called a storage pool, and one object does not belong to the next level of another object.
[0086] Index data: is a separate, physical storage structure that sorts the values of one or more columns in a database table. It is a collection of one or more column values in a table and a corresponding list of logical pointers pointing to the data pages in the table that physically identify these values.
[0087] Partition: Data in a distributed database is divided into multiple non-overlapping sub-data sets, each of which is a partition; correspondingly, partition node: a server that maintains a partition of data.
[0088] Data disaster recovery: the full name is data disaster backup, which refers to the process of copying the entire system or part of the data set from the hard disk or array of the application host to other storage media to prevent data loss due to operational errors or system failures; correspondingly, the disaster recovery service node: refers to the server that provides disaster recovery services.
[0089] In the present application, an index data synchronization method is provided. The present application also relates to an index data synchronization system, an index data synchronization apparatus, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0090] Figure 1 A flowchart of an index data synchronization method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0091] Step S102: obtaining the index data to be synchronized submitted by the target partition node.
[0092] In practical applications, index data is a relatively important type of data in the database, and its maintenance is particularly important. Usually, in the process of index data maintenance, each partition node corresponding to the database maintains the corresponding index data respectively, or all partition nodes jointly maintain the global index data, and use multiple disaster recovery nodes to ensure high reliability and consistency of the data. Each update operation of the index data must wait for the data to be synchronized to the disaster recovery node to ensure data consistency. However, there are disadvantages of low query efficiency and low concurrency performance when the partition node maintains its own index data, and there is a disadvantage of high maintenance cost when the partition nodes jointly maintain all index data.
[0093] The index data synchronization method provided by the present application, in order to achieve the purpose of high concurrency and low maintenance cost, writes the index data to be synchronized submitted by the target partition node into the key-value database, changes the value of the temporary version number to the value of the state version number according to the writing result, and then records the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node, and finally detects the recorded transaction value. When it is detected that the recorded transaction value meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node; by using the version number method to control the synchronization of the index data, the concurrency capability of the index node can be effectively improved, and storing the index data to be synchronized by the object storage node can not only reduce the development cost, but also reduce the maintenance cost, thereby effectively improving the processing capability of the index data to be synchronized.
[0094] The index data synchronization method provided in this embodiment is applied to the index node, and the synchronization of the index data to be synchronized of the target partition node is completed through the index node, so as to achieve the effect of high concurrency and low maintenance cost. For details, please refer to the description corresponding to step S102 to step S110 in this embodiment. It should be noted that this embodiment describes the index data synchronization process with any one of the multiple partition nodes as the target partition node. The synchronization process of the index data to be synchronized of the multiple partition nodes can refer to the corresponding description of this embodiment, and no excessive details will be given here.
[0095] In the specific implementation, due to the complex architecture of distributed databases, such as time series databases, the data stored in the distributed database needs to be divided into multiple non-intersecting sub-data sets. At this time, each sub-data set is a partition. In order to facilitate the management of data in the distributed database, a corresponding server will be configured for each partition to maintain the data in the partition, that is, the partition of the configured server is the partition node.
[0096] Based on this, the target partition node is: the data in the corresponding partition changes, such as deletion, addition or modification. At this time, the target partition node will generate index data to be synchronized according to the data change result, so that the deleted, added or modified data can be queried in the partition according to the index data to be synchronized later; that is: the target partition node is a partition node with index data synchronization requirements, and the index data to be synchronized is the index data generated after the data in the partition corresponding to the target partition node changes.
[0097] In practical applications, the index data to be synchronized may be a target partition node, which may be composed of index data after multiple groups of data in the partition change at one moment. For example, if data S and data N in the partition change at the same moment, then index data S_in corresponding to data S and index data N_in corresponding to data N are generated. Then, index data S_in and index data N_in may be integrated as index data to be synchronized and submitted to the index node for synchronization, or submitted to the index node for synchronization separately.
[0098] Furthermore, during the process of synchronizing index data, if the index data to be synchronized received by the index node is the integration of index data S_in and index data N_in, the index node can then use the integrated index data S_in and index data N_in as the index data to be synchronized and perform subsequent synchronization processes together; if the index data to be synchronized received is index data S_in and index data N_in, the index node can then perform subsequent synchronization processes by processing the index data separately.
[0099] Step S104: write the to-be-synchronized index data into the key-value database corresponding to the target partition node.
[0100] Specifically, on the basis of obtaining the index data to be synchronized submitted by the target partition node as mentioned above, further, in order to improve the synchronization efficiency of the index data of the synchronization object storage node, the index data to be synchronized can be written into the key-value database corresponding to the target partition node for temporary storage. When the index node triggers the synchronization condition, the index data to be synchronized can be extracted from the key-value database for synchronization.
[0101] In actual applications, since the data in the partition corresponding to the target partition node changes irregularly, multiple index data to be synchronized may be submitted continuously during the process of the target partition node submitting the index data to be synchronized. At this time, if each index data to be synchronized is synchronized separately, the synchronization efficiency will be reduced and the synchronization resources occupied will also be high.
[0102] Based on this, the key-value database will be deployed in the index node to temporarily store the index data to be synchronized submitted by the target partition node. After that, the index node will synchronize the index data to be synchronized according to the time period, that is, a detection will be performed every time K. When index data to be synchronized is detected, the synchronization process will be performed. In specific implementation, the time K can be set to 1 millisecond, 2 milliseconds or 5 milliseconds. The specific setting can be set according to the actual application scenario, and this embodiment does not make too many restrictions here.
[0103] Furthermore, since there are too many partition nodes in the distributed database in the process of writing the index data to be synchronized into the key-value database, if the index data to be synchronized of each partition node is written into the key-value database indiscriminately, confusion of the index data to be synchronized will be caused, and the index data to be synchronized of each partition node cannot be correctly determined. Therefore, it is necessary to perform the write operation according to the node identifier of each partition node. In this embodiment, the specific implementation method is as follows:
[0104] (a) Obtain the node identifier of the target partition node.
[0105] When the index data to be synchronized is obtained, it indicates that subsequent index data synchronization is required. At this time, the index data to be synchronized needs to be written into the key-value database so that more index data to be synchronized can be uploaded at one time in the future. In addition, in order to be able to distinguish the index data to be synchronized for different partition nodes, the node identifier of the target partition node is obtained and subsequently stored in the storage location corresponding to the node identifier.
[0106] In practical applications, the node identifier specifically refers to a unique identifier of a target partition node, which may be a character string or a digital number or other unique identification information, and this embodiment does not impose too many limitations on this.
[0107] (b) determining a target key-value storage area of the target partition node in the key-value database according to the node identifier.
[0108] After obtaining the node identifier corresponding to the target partition node, the target key value storage area corresponding to the target partition node will be determined in the key value database according to the node identifier, so as to write the to-be-synchronized index data submitted by the target partition node into the target key value storage area.
[0109] (c) Writing the to-be-synchronized index data into the target key-value storage area.
[0110] Furthermore, in the process of writing the to-be-synchronized index data into the target key-value storage area, due to the high performance and easy scalability of the key-value database, the to-be-synchronized index data can be stored in a specific form. In this embodiment, the specific implementation is as follows:
[0111] Determine the time information for submitting the index data to be synchronized;
[0112] Generate a key name of the index data to be synchronized based on the time information, and determine a key value and a data type of the index data to be synchronized;
[0113] The key-value item data of the to-be-synchronized index data is composed according to the key name, the key value and the data type, and written into the target key-value storage area.
[0114] Specifically, the key name specifically refers to the unique identifier of the index data to be synchronized, the key value specifically refers to the actual configuration information and data of the index data to be synchronized, and the data type specifically refers to the type of the index data to be synchronized; based on this, first determine the time information for submitting the index data to be synchronized, then generate the key name of the index data to be synchronized based on the time information, and determine the key value and data type of the index data to be synchronized at the same time, and finally, write the key value item data of the index data to be synchronized into the target key value storage area according to the key name, the key value and the data type.
[0115] In actual applications, the key value item data can be a string value type, a binary value type or a DWORD value type, wherein the string value type represents a file description or a hardware identifier, etc. The key value item data of the string value type consists of letters and numbers, and its maximum length cannot exceed 255 characters; the binary value type has no length limit and can be any number of bytes long; the DWORD value type is a 32-bit (double-byte long) value.
[0116] For example, the target partition node A1 submits the index data to be synchronized. At this time, the node identifier of the target partition node A1 is obtained as ID_A1. Then, the target key value storage area of the target partition node A1 is determined in the key value database according to the node identifier ID_A1. At the same time, the key name is generated according to the time information of submitting the index data to be synchronized, and the key value and data type are determined. Finally, the key value item data of the index data to be synchronized is composed according to the key name, key value and data type, and written into the target key value storage area corresponding to the node identifier ID_A1 for subsequent synchronization to the object storage node.
[0117] In summary, in order to make full use of synchronization resources, the index data to be synchronized submitted to the target partition node is written into the key-value database for temporary storage, which can effectively improve the efficiency of subsequent synchronization. In addition, temporary storage of the index data to be synchronized in the key-value database can make full use of the scalable characteristics of the key-value data and avoid the problem of insufficient database storage space.
[0118] Step S106, changing the value of the temporary version number to the value of the status version number according to the writing result.
[0119] Specifically, based on the above-mentioned writing of the index data to be synchronized into the key-value database, further, the value of the local temporary version number of the index node is changed to the value of the local status version number of the index node according to the writing result; wherein, the value of the temporary version number represents the transaction status of the synchronization transaction corresponding to the target partition node, and the value of the status version number represents the synchronization progress of the index data submitted by the target partition node.
[0120] During specific implementation, the synchronization transaction corresponding to the target partition node specifically refers to the transaction of synchronizing the index data of the target partition node. Correspondingly, the transaction status specifically refers to the status stage of synchronizing the index data to be synchronized. When the value of the temporary version number cur_ver is 0, it indicates that there is no index data to be synchronized in the index node. When the value of the temporary version number cur_ver is not 0 after being changed, it indicates that there is index data to be synchronized in the index node and the index data needs to be synchronized. Based on this, the value of the temporary version number can be understood as a detector for synchronizing index data of the index node, which is used to detect whether there is an operation to synchronize the index data to be synchronized.
[0121] Among them, the value syn_ver of the status version number specifically refers to the synchronization progress of the index data submitted by the target partition node. The value syn_ver of the status version number can be understood as a counter for detecting the synchronization progress of the index data to be synchronized. When the synchronization is completed, the value syn_ver of the status version number is incremented by 1, and the value syn_ver of the status version number is monotonically increasing, so it is incremented by 1 each time data synchronization is completed.
[0122] In actual applications, the value of the temporary version number is changed to the value of the status version number. The purpose is to determine whether new index data to be synchronized is written through the value of the temporary version number, and then to reach the operation of subsequent synchronization of index data. That is, by changing the value of the temporary version number, the purpose of detecting whether the transaction value meets the preset synchronization condition is triggered. In this way, when there is index data to be synchronized written, the index data can be synchronized by triggering the synchronization condition. When there is no index data to be synchronized written, the index node is put into sleep state, so as to reduce the resource cost of the index node operation.
[0123] Step S108: Record the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node.
[0124] Specifically, based on the above-mentioned change of the value of the temporary version number, the change behavior of the value of the temporary version number is further recorded through the transaction value of the target synchronization transaction corresponding to the target partition node.
[0125] In actual applications, recording the change behavior of the value of the temporary version number based on the transaction value waiter_cnt specifically means that when the temporary version number is changed to the status version number, it means that the index data to be synchronized needs to be synchronized, then the transaction value waiter_cnt of the target synchronization transaction of the target partition node is incremented by 1, thereby recording that the index data to be synchronized needs to be synchronized to the object storage node. At this time, it can be concluded that the transaction value waiter_cnt is not 0, and subsequent synchronization of the index data to be synchronized can be performed.
[0126] It should be noted that the transaction value waiter_cnt can be used to detect the synchronization result of the index data to be synchronized within the time period, that is, each index data to be synchronized uploaded within the time period will increase the transaction value waiter_cnt by 1, and then when the time period is reached, the synchronization of the index data to be synchronized is performed, and the synchronization is completed and the transaction value waiter_cnt is decremented by 1, which is used to indicate the completion of the synchronization of the transaction value of the synchronization transaction.
[0127] Further, after recording the change behavior of the value of the temporary version number based on the transaction value, a cyclic detection will be performed according to the time period, and synchronization processing or sleep will be performed according to the detection result. In this embodiment, the specific implementation method is as follows:
[0128] When it is detected that the recorded transaction value does not satisfy the preset synchronization condition, a step of detecting whether the transaction value satisfies the preset synchronization condition according to a time period is performed.
[0129] Specifically, when it is detected that the transaction value after recording does not meet the preset synchronization condition, it means that the transaction value after recording has not yet reached the condition for synchronization to the object storage node, then the step of detecting whether the transaction value meets the preset synchronization condition according to the time period can be executed, wherein the synchronization condition specifically refers to the synchronization condition for synchronizing the index data to be synchronized to the object storage node, which can be detecting whether the transaction value is not 0.
[0130] Based on this, the index node will detect whether the transaction value at the current moment meets the preset synchronization condition according to the time period. If it does, the subsequent step S110 will be executed. If it does not, the step of detecting whether the transaction value meets the preset synchronization condition according to the time period will continue to be executed to achieve the purpose of detection, thereby achieving the effect of timely synchronization of the index data to be synchronized.
[0131] Continuing with the above example, after A submits the target key value storage area corresponding to the node ID ID_A1 that index data to be synchronized is written to, the index node will detect whether the transaction value waiter_cnt of the synchronization transaction of the target partition node A1 is 0 in 1 millisecond. Since the target key value storage area corresponding to the node ID ID_A1 that index data to be synchronized is written to, the value cur_ver of the temporary version number of the index node will be changed to the value syn_ver of the status version number of the index node, and the value syn_ver of the status version number is 100. Therefore, the value cur_ver of the temporary version number is 100 at this time, and the transaction value wait_cnt is incremented by 1. If it is detected that the transaction value wait_cnt is not 0, the subsequent synchronization processing of the index data to be synchronized can be performed.
[0132] Assuming that the transaction value waiter_cnt is 0, it means that the index node has no index data to be synchronized to the object storage node, then the transaction value waiter_cnt of the synchronization transaction of the target partition node A1 will continue to be detected for 1 millisecond until it is detected that the transaction value wait_cnt is not 0, and then the subsequent synchronization processing of the index data to be synchronized can be performed.
[0133] In actual applications, the synchronization condition can be set according to the actual application scenario, that is, the detection of whether the transaction value waiter_cnt is 0 can be set to: whether the transaction value waiter_cnt is 20 or 30, etc., to accumulate the index data to be synchronized in the key-value database, and then detect that the transaction value wait_cnt meets the condition after k time, and then perform synchronization processing. This can achieve one-time upload of more index data to be synchronized, and make better use of synchronization resources.
[0134] In summary, the purpose of synchronization is achieved by using a time period cyclic detection method. Not only can the amount of index data to be synchronized in the key-value database be controlled by the time period, but also the synchronization resources of the index node can be fully utilized to further improve the synchronization processing efficiency.
[0135] Step S110: when it is detected that the recorded transaction value meets the preset synchronization condition, the to-be-synchronized index data in the key-value database is synchronized to the object storage node.
[0136] Specifically, based on the above-mentioned behavior of recording the change of the value of the temporary version number through the transaction value, further, when it is detected that the transaction value after the record meets the preset synchronization condition, it means that the index data to be synchronized in the key-value database has reached the synchronization condition, then the index data to be synchronized in the key-value database can be synchronized to the object storage node.
[0137] Further, on the basis of writing the to-be-synchronized index data into the key-value database, in order to achieve that when the to-be-synchronized index data in the key-value database is subsequently uploaded to the object storage node, no repeated uploading occurs, synchronization processing can be performed according to the writing time. In this embodiment, the specific implementation method is as follows:
[0138] Determining a writing time for writing the to-be-synchronized index data into the key-value database;
[0139] Recording the write time into the metadata table of the key-value database;
[0140] Correspondingly, when the transaction value after the record is detected to meet the preset synchronization condition, the step S110 is executed to synchronize the index data to be synchronized in the key-value database to the object storage node. The step S110 specifically refers to reading the metadata table of the key-value database to obtain the write time when the transaction value after the record is detected to meet the preset synchronization condition; and synchronizing the index data to be synchronized in the key-value database to the object storage node according to the write time.
[0141] In actual applications, the write time specifically refers to the time when the writing of the index data to be synchronized is completed, and the metadata table specifically refers to a data table that records the description information of the key-value database, such as the write time, data type or data size. Based on this, when it is subsequently detected that the transaction value after the record meets the preset synchronization condition, the metadata table of the key-value database is read to obtain the write time, and then the index data to be synchronized in the key-value database is synchronized to the object storage node according to the write time.
[0142] Continuing with the above example, when it is detected that the transaction value waiter_cnt is not 0, the write time of the to-be-synchronized index data written to the target partition node A1 in the key-value database is obtained, and then the to-be-synchronized index data of the target partition node A1 is extracted from the target key-value storage area corresponding to the node identifier ID_A1 according to the write time, and the to-be-synchronized index data of the target partition node A1 is synchronized to the object storage node.
[0143] Further, after the synchronization of the index data to be synchronized is completed, it is necessary to assign a value to the object version number in the index node to determine whether the synchronization of the index data to be synchronized is completed. In this embodiment, the specific implementation method is as follows:
[0144] Receiving the synchronization result returned by the object storage node;
[0145] According to the synchronization result, the value of the state version number is updated;
[0146] The object version number is assigned a value based on the updated state version number; wherein the value of the object version number indicates that synchronization of the to-be-synchronized index data of the target partition node is complete.
[0147] Specifically, receive the synchronization result returned by the object storage node, then update the value of the state version number according to the synchronization result, and finally assign the object version number based on the value of the updated state version number, wherein the value of the object version number indicates that the synchronization of the index data to be synchronized of the target partition node is completed.
[0148] Continuing with the above example, after the to-be-synchronized index data of the target partition node A1 is synchronized to the object storage node, the synchronization result returned by the object storage node is received, and the value of the status version number syn_ver:100 is incremented by 1 according to the synchronization result. At this time, the value of the status version number syn_ver is 101, which is used to indicate that the to-be-synchronized index data has been synchronized to the object storage node. Then, according to the value of the status version number syn_ver:101, the value of the object version number fin_ver is assigned. At this time, the value of the object version number fin_ver is 101, and the index node can determine that the to-be-synchronized index data is completed according to the value of the object version number fin_ver:101.
[0149] Furthermore, after the value of the object version number is assigned, in order to accurately determine the completion of synchronization, the value of the object version number is compared with the value of the temporary version number. In this embodiment, the specific implementation method is as follows:
[0150] Determine whether the value of the object version number after the assignment is greater than the value of the temporary version number after the change;
[0151] If yes, adjust the recorded transaction value, and send the synchronization completion result to the target partition node according to the adjustment result;
[0152] If not, no action is taken.
[0153] In a specific implementation, the synchronization completion result specifically refers to informing the target partition node that the synchronization of the to-be-synchronized index data has been completed.
[0154] Using the above example, the object version number value fin_ver: 101 is compared with the temporary version number value cur_ver: 100. According to the comparison result, it is determined that the object version number value is greater than the temporary version number value. At this time, it can be accurately understood that the synchronization of the index data to be synchronized is completed, and the transaction value waiter_cnt corresponding to the target partition node is reduced by 1, that is, the transaction value waiter_cnt corresponding to the target partition node is restored to 0, and the sleep state is entered. When it is detected that waiter_cnt is not 0, it means that the target partition node has new index data to be synchronized that needs to be synchronized, and the synchronization process can be executed.
[0155] In summary, the synchronization requests for the to-be-synchronized index data from the partitioned nodes are processed concurrently by comparing the version number values. This avoids the introduction of mutex locks, and large-scale concurrent submission requests from the partitioned nodes will not cause serious blocking or performance degradation, thus greatly improving the concurrency capability of the index nodes.
[0156] In addition, when the target partition node submits at least two index data to be synchronized within the time period, the synchronization process will be performed according to the time difference. In this embodiment, the specific implementation method is as follows:
[0157] Determine a submission time for submitting the at least two index data to be synchronized;
[0158] Calculate the time difference between the starting index data and the ending index data in the at least two index data to be synchronized according to the submission time;
[0159] When the time difference is greater than or equal to the time period, the at least two index data to be synchronized in the key-value database are synchronized to the object storage node.
[0160] For example, the target partition node B1 submits the index data B1_in, B2_in and B3_in to be synchronized, and writes them into the key-value database. The submission time of the three index data is completed continuously within 0.6 milliseconds, and the submission order is index data B1_in-index data B2_in-index data B3_in. At this time, the starting index data is determined to be B1_in and the ending index data is B3_in. The time difference between the two is 0.6 milliseconds. It is determined by judgment that 0.6 milliseconds is greater than 1 millisecond, then the index data B1_in, B2_in and B3_in need to be synchronized to the object storage node.
[0161] By performing synchronization processing on the index data to be synchronized in a time comparison manner, the effect of accumulating and synchronizing the index data to be synchronized is achieved, thereby effectively utilizing synchronization resources and saving the cost of maintaining index data.
[0162] In practical applications, the object storage node is a disaster recovery service node of the target partition node; when the target partition node has data confusion or damage, it is necessary to obtain the target index data from the disaster recovery service node and process the data of the target partition node. In this embodiment, the specific implementation method is as follows:
[0163] Receive an index data read request submitted by the target partition node;
[0164] Forwarding the index data read request to the disaster recovery service node, and receiving the target index data returned by the disaster recovery service node;
[0165] The target index data is sent to the target partition node for data processing operations.
[0166] In practical applications, the disaster recovery service node specifically refers to a server that provides disaster recovery services, and data disaster recovery refers to the process of copying the entire system or part of the data set from the hard disk or array of the application host to other storage media to prevent data loss due to operational errors or system failures;
[0167] Based on this, when an index data read request submitted by the target partition node is received, it means that the data in the target partition node has changed, or the data in the target partition node needs to be queried, then the index data read request is forwarded to the disaster recovery service node, and the target index data returned by the disaster recovery service node is received; finally, the target index data is sent to the target partition node for data processing operations.
[0168] For example, the target partition node corresponds to the partition that stores the merchant's access user data. When the merchant needs to query some user access data (query access time, access product content), it will need to query based on the index data. When the user submits a query request, the index node will receive the index data read request submitted by the target partition node, and forward the index data read request to the object storage node. After that, it will receive the target index data returned by the object storage node, and send the target index data to the target partition node. The target partition node can query the access data of some users based on the target index data and display it to the merchant, thereby achieving the purpose of quickly querying data.
[0169] The index data synchronization method provided by the present application writes the to-be-synchronized index data submitted by the target partition node into a key-value database, changes the value of the temporary version number to the value of the state version number according to the writing result, and then records the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node, and finally detects the recorded transaction value, and when it is detected that the recorded transaction value meets the preset synchronization condition, synchronizes the to-be-synchronized index data in the key-value database to the object storage node; by adopting the version number method to control the synchronization of index data, the concurrency capability of the index node can be effectively improved, and by storing the to-be-synchronized index data through the object storage node, not only the development cost but also the maintenance cost can be reduced, thereby effectively improving the processing capability of the to-be-synchronized index data.
[0170] The following combination Figure 2 , taking the application of the index data synchronization method provided by the present application in the data increase scenario as an example, the index data synchronization method is further described. Figure 2 A processing flow chart of an index data synchronization method applied to a data addition scenario provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0171] Step S202: Obtain the index data to be synchronized submitted by the target partition node.
[0172] Specifically, this embodiment will take the application of the index data synchronization method in the data addition scenario as an example to further describe the index data synchronization method, that is, in a distributed database, when data is added to the partition corresponding to the target partition node, it is necessary to generate index data according to the added data and synchronize it to the object storage node;
[0173] Based on this, see Figure 3 As shown, the distributed database includes partition node 1, partition node 2, index node and object storage node. Data is added to partition node 1 and partition node 2 at the same time. At this time, partition node 1 and partition node 2 have generated index data that needs to be synchronized to the object storage node. This embodiment will describe the synchronization process of index data with partition node 2 as the target partition node. The synchronization process of the index data to be synchronized of partition node 1 can refer to the corresponding description content in this embodiment, and this embodiment will not be described in detail here.
[0174] It should be noted that Figure 3 Schematic diagram of the index data synchronization method in Figure 2 The processing flow chart steps shown correspond to the steps, that is, Figure 3 The meaning of the labels in Figure 2 The steps corresponding to the numbers in the table have the same meaning, namely Figure 3The synchronization process of index data needs to be done through Figure 2 The corresponding steps S202 to S220 are implemented.
[0175] Step S204: write the index data to be synchronized into the key value storage space corresponding to the target partition node.
[0176] Step S206, setting the value cur_ver of the temporary version number to the value syn_ver of the state version number according to the writing result.
[0177] Specifically, the value of the temporary version number indicates the transaction status of the synchronization transaction corresponding to the target partition node, and the value of the status version number indicates the synchronization progress of the target partition node submitting index data; Figure 3 Transaction 1 in FIG. 1 is the synchronous transaction in this embodiment.
[0178] Step S208: According to the change result, the transaction value waiter_cnt of the target synchronization transaction corresponding to the target partition node is incremented by 1.
[0179] Specifically, the transaction value waiter_cnt incremented by 1 specifically refers to recording the change behavior of the value of the temporary version number through the transaction value waiter_cnt of the target synchronization transaction corresponding to the target partition node.
[0180] Step S210 , checking whether the transaction value waiter_cnt is not 0 every time period k milliseconds; if not, continue to execute the step of checking whether the transaction value waiter_cnt is not 0 every time period k milliseconds; if yes, execute step 212 .
[0181] Step S212, the value syn_ver of the status code is incremented by 1.
[0182] Step S214: synchronize the index data to be synchronized in the key-value storage space to the object storage node.
[0183] Step S216, assign the value syn_ver of the state number after incrementing by 1 to the value fin_ver of the object version number.
[0184] The value of the object version number indicates that the synchronization of the to-be-synchronized index data of the target partition node has been completed.
[0185] Step S218, determine whether the value fin_ver of the assigned object version number is greater than the value cur_ver of the temporary version number; if so, execute step S220; if not, do nothing.
[0186] Step S220: the transaction value waiter_cnt of the target synchronization transaction corresponding to the target partition node is decremented by 1.
[0187] Specifically, by decrementing the transaction value waiter_cnt of the target synchronization transaction corresponding to the target partition node by 1, the index node is informed that the synchronization of the to-be-synchronized index data of the partition node 2 is completed.
[0188] The index data synchronization method provided by the present application writes the to-be-synchronized index data submitted by the target partition node into a key-value database, changes the value of the temporary version number to the value of the state version number according to the writing result, and then records the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node, and finally detects the recorded transaction value, and when it is detected that the recorded transaction value meets the preset synchronization condition, synchronizes the to-be-synchronized index data in the key-value database to the object storage node; by adopting the version number method to control the synchronization of index data, the concurrency capability of the index node can be effectively improved, and by storing the to-be-synchronized index data through the object storage node, not only the development cost but also the maintenance cost can be reduced, thereby effectively improving the processing capability of the to-be-synchronized index data.
[0189] Corresponding to the above method embodiment, the present application also provides an index data synchronization system embodiment, Figure 4 FIG. 1 shows a schematic diagram of the structure of an index data synchronization system provided by an embodiment of the present application. Figure 4 As shown, the index data synchronization system 400 includes:
[0190] Target partition node 402, index node 404 and object storage node 406;
[0191] The target partition node 402 is configured to obtain an operation request from a user; read the target data and perform a processing operation according to the user identifier included in the operation request; and send the generated index data to be synchronized to the index node 404 according to the processing operation result;
[0192] The index node 404 is configured to write the to-be-synchronized index data into the key-value database corresponding to the target partition node; change the value of the temporary version number to the value of the status version number according to the writing result; wherein the value of the temporary version number indicates the transaction status of the synchronization transaction corresponding to the target partition node, and the value of the status version number indicates the synchronization progress of the target partition node submitting the index data; record the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node; when it is detected that the recorded transaction value meets the preset synchronization condition, synchronize the to-be-synchronized index data in the key-value database to the object storage node 406;
[0193] The object storage node 406 is configured to store the index data to be synchronized and return a synchronization result to the target partition node 402 .
[0194] In an optional embodiment, writing the to-be-synchronized index data into a key-value database corresponding to the target partition node includes:
[0195] Obtain a node identifier of the target partition node; determine a target key value storage area of the target partition node in the key value database according to the node identifier; and write the index data to be synchronized into the target key value storage area.
[0196] In an optional embodiment, writing the to-be-synchronized index data into the target key-value storage area includes:
[0197] Determine the time information for submitting the index data to be synchronized; generate the key name of the index data to be synchronized based on the time information, and determine the key value and data type of the index data to be synchronized; compose the key value item data of the index data to be synchronized according to the key name, the key value and the data type, and write them into the target key value storage area.
[0198] In an optional embodiment, the index node 404 is further configured as:
[0199] Determine a writing time for writing the to-be-synchronized index data into the key-value database; and record the writing time into a metadata table of the key-value database;
[0200] Correspondingly, when it is detected that the transaction value after the record meets the preset synchronization condition, synchronizing the to-be-synchronized index data in the key-value database to the object storage node includes:
[0201] When it is detected that the transaction value after the record meets the preset synchronization condition, the metadata table of the key-value database is read to obtain the write time; and the index data to be synchronized in the key-value database is synchronized to the object storage node according to the write time.
[0202] In an optional embodiment, the index node 404 is further configured as:
[0203] When it is detected that the recorded transaction value does not satisfy the preset synchronization condition, detection is performed according to a time period to determine whether the transaction value satisfies the preset synchronization condition.
[0204] In an optional embodiment, the index node 404 is further configured as:
[0205] Receive the synchronization result returned by the object storage node; update the value of the state version number according to the synchronization result; assign the object version number based on the value of the updated state version number; wherein the value of the object version number indicates that the synchronization of the to-be-synchronized index data of the target partition node is complete.
[0206] In an optional embodiment, the index node 404 is further configured as:
[0207] Determine whether the value of the assigned object version number is greater than the value of the changed temporary version number; if so, adjust the recorded transaction value and send the synchronization completion result to the target partition node according to the adjustment result.
[0208] In an optional embodiment, when the target partition node submits at least two index data to be synchronized within the time period, the index node 404 is further configured as follows:
[0209] Determine the submission time for submitting the at least two index data to be synchronized; calculate the time difference between the starting index data and the ending index data in the at least two index data to be synchronized according to the submission time; when the time difference is greater than or equal to the time period, synchronize the at least two index data to be synchronized in the key-value database to the object storage node 406.
[0210] In an optional embodiment, the object storage node 406 is a disaster recovery service node of the target partition node 402;
[0211] Accordingly, the index node 404 is further configured as follows:
[0212] Receive the index data read request submitted by the target partition node 402; forward the index data read request to the disaster recovery service node, and receive the target index data returned by the disaster recovery service node; send the target index data to the target partition node 402 for data processing operations.
[0213] The index data synchronization system provided by the present embodiment writes the to-be-synchronized index data submitted by the target partition node into the key-value database, changes the value of the temporary version number to the value of the state version number according to the writing result, and then records the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node, and finally detects the recorded transaction value, and when it is detected that the recorded transaction value meets the preset synchronization condition, synchronizes the to-be-synchronized index data in the key-value database to the object storage node; by adopting the version number method to control the synchronization of index data, the concurrency capability of the index node can be effectively improved, and by storing the to-be-synchronized index data through the object storage node, not only the development cost but also the maintenance cost can be reduced, thereby effectively improving the processing capability of the to-be-synchronized index data.
[0214] The above is a schematic scheme of an index data synchronization system of this embodiment. It should be noted that the technical scheme of the index data synchronization system and the technical scheme of the above-mentioned index data synchronization method belong to the same concept, and the details not described in detail in the technical scheme of the index data synchronization system can be referred to the description of the technical scheme of the above-mentioned index data synchronization method.
[0215] Corresponding to the above method embodiment, the present application also provides an index data synchronization device embodiment, Figure 5 FIG. 1 shows a schematic diagram of the structure of an index data synchronization device provided by an embodiment of the present application. Figure 5 As shown, the device comprises:
[0216] The acquisition module 502 is configured to acquire the index data to be synchronized submitted by the target partition node;
[0217] A writing module 504 is configured to write the to-be-synchronized index data into a key-value database corresponding to the target partition node;
[0218] The change module 506 is configured to change the value of the temporary version number to the value of the state version number according to the write result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data;
[0219] The recording module 508 is configured to record the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node;
[0220] The synchronization module 510 is configured to synchronize the to-be-synchronized index data in the key-value database to the object storage node when it is detected that the transaction value after the record meets the preset synchronization condition.
[0221] In an optional embodiment, the writing module 504 includes:
[0222] A node identification obtaining unit, configured to obtain a node identification of the target partition node;
[0223] A storage area determination unit is configured to determine a target key-value storage area of the target partition node in the key-value database according to the node identifier;
[0224] The data writing unit is configured to write the to-be-synchronized index data into the target key-value storage area.
[0225] In an optional embodiment, the data writing unit includes:
[0226] A time information determination subunit is configured to determine time information for submitting the index data to be synchronized;
[0227] A key name generating subunit is configured to generate a key name of the index data to be synchronized based on the time information, and determine a key value and a data type of the index data to be synchronized;
[0228] The data writing subunit is configured to compose the key-value item data of the to-be-synchronized index data according to the key name, the key value and the data type, and write the key-value item data into the target key-value storage area.
[0229] In an optional embodiment, the index data synchronization device further includes:
[0230] A write time determination module is configured to determine a write time for writing the to-be-synchronized index data into the key-value database;
[0231] A write time recording module, configured to record the write time into a metadata table of the key-value database;
[0232] Accordingly, the synchronization module 510 includes:
[0233] A metadata table reading unit is configured to read the metadata table of the key-value database to obtain the write time when it is detected that the transaction value after the record meets the preset synchronization condition;
[0234] The synchronization index data unit is configured to synchronize the to-be-synchronized index data in the key-value database to the object storage node according to the write time.
[0235] In an optional embodiment, the index data synchronization device further includes:
[0236] The detection module is configured to execute the step of detecting whether the transaction value satisfies the preset synchronization condition according to a time period when it is detected that the recorded transaction value does not satisfy the preset synchronization condition.
[0237] In an optional embodiment, the index data synchronization device further includes:
[0238] A receiving module, configured to receive the synchronization result returned by the object storage node;
[0239] An updating module, configured to update the value of the state version number according to the synchronization result;
[0240] The assignment module is configured to assign a value to the object version number based on the value of the updated state version number; wherein the value of the object version number indicates that synchronization of the to-be-synchronized index data of the target partition node is completed.
[0241] In an optional embodiment, the index data synchronization device further includes:
[0242] A determination module is configured to determine whether the value of the assigned object version number is greater than the value of the changed temporary version number;
[0243] If so, the synchronization completion result sending module is executed, and the synchronization completion result sending module is configured to adjust the recorded transaction value and send the synchronization completion result to the target partition node according to the adjustment result.
[0244] In an optional embodiment, when the target partition node submits at least two index data to be synchronized within the time period, the synchronization module 510 includes:
[0245] A submission time determination unit, configured to determine a submission time for submitting the at least two index data to be synchronized;
[0246] A time difference calculation unit is configured to calculate a time difference between the start index data and the end index data in the at least two index data to be synchronized according to the submission time;
[0247] The data synchronization unit is configured to synchronize the at least two index data to be synchronized in the key-value database to the object storage node when the time difference is greater than or equal to the time period.
[0248] In an optional embodiment, the object storage node is a disaster recovery service node of the target partition node;
[0249] Correspondingly, the index data synchronization device further includes:
[0250] A request receiving module is configured to receive an index data reading request submitted by the target partition node;
[0251] A forwarding request module, configured to forward the index data read request to the disaster recovery service node, and receive the target index data returned by the disaster recovery service node;
[0252] The data sending module is configured to send the target index data to the target partition node for data processing operation.
[0253] The index data synchronization device provided in the present embodiment writes the to-be-synchronized index data submitted by the target partition node into the key-value database, changes the value of the temporary version number to the value of the state version number according to the writing result, and then records the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node, and finally detects the recorded transaction value, and when it is detected that the recorded transaction value meets the preset synchronization condition, synchronizes the to-be-synchronized index data in the key-value database to the object storage node; by adopting the version number method to control the synchronization of index data, the concurrency capability of the index node can be effectively improved, and by storing the to-be-synchronized index data through the object storage node, not only the development cost but also the maintenance cost can be reduced, thereby effectively improving the processing capability of the to-be-synchronized index data.
[0254] The above is a schematic scheme of an index data synchronization device of this embodiment. It should be noted that the technical scheme of the index data synchronization device and the technical scheme of the above-mentioned index data synchronization method belong to the same concept, and the details not described in detail in the technical scheme of the index data synchronization device can be referred to the description of the technical scheme of the above-mentioned index data synchronization method.
[0255] Figure 6 The block diagram of a computing device 600 according to an embodiment of the present application is shown. The components of the computing device 600 include but are not limited to a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and the database 650 is used to store data.
[0256] The computing device 600 also includes an access device 640 that enables the computing device 600 to communicate via one or more networks 660. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of network interface (e.g., a network interface card (NIC)) whether wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0257] In one embodiment of the present application, the above components of the computing device 600 and Figure 6 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 6 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0258] The computing device 600 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. The computing device 600 may also be a mobile or stationary server.
[0259] The processor 620 is used to execute the following computer executable instructions:
[0260] Get the index data to be synchronized submitted by the target partition node;
[0261] Writing the to-be-synchronized index data into the key-value database corresponding to the target partition node;
[0262] The value of the temporary version number is changed to the value of the state version number according to the writing result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data;
[0263] Recording the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node;
[0264] When it is detected that the transaction value after the record meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node.
[0265] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above index data synchronization method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above index data synchronization method.
[0266] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which are used when executed by a processor to:
[0267] Get the index data to be synchronized submitted by the target partition node;
[0268] Writing the to-be-synchronized index data into the key-value database corresponding to the target partition node;
[0269] The value of the temporary version number is changed to the value of the state version number according to the writing result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data;
[0270] Recording the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node;
[0271] When it is detected that the transaction value after the record meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node.
[0272] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above-mentioned index data synchronization method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above-mentioned index data synchronization method.
[0273] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0274] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0275] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0276] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0277] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A method for synchronizing index data, comprising: Get the index data to be synchronized submitted by the target partition node; Writing the to-be-synchronized index data into the key-value database corresponding to the target partition node; The value of the temporary version number is changed to the value of the state version number according to the writing result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data; Recording the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node; When it is detected that the transaction value after the record meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node.
2. According to the index data synchronization method of claim 1, the step of writing the to-be-synchronized index data into the key-value database corresponding to the target partition node comprises: Obtaining a node identifier of the target partition node; Determine a target key value storage area of the target partition node in the key value database according to the node identifier; The to-be-synchronized index data is written into the target key-value storage area.
3. The index data synchronization method according to claim 2, wherein writing the to-be-synchronized index data into the target key-value storage area comprises: Determine the time information for submitting the index data to be synchronized; Generate a key name of the index data to be synchronized based on the time information, and determine a key value and a data type of the index data to be synchronized; The key-value item data of the to-be-synchronized index data is composed according to the key name, the key value and the data type, and written into the target key-value storage area.
4. The index data synchronization method according to claim 1, further comprising: Determining a writing time for writing the to-be-synchronized index data into the key-value database; Recording the write time into the metadata table of the key-value database; Correspondingly, when it is detected that the transaction value after the record meets the preset synchronization condition, synchronizing the to-be-synchronized index data in the key-value database to the object storage node includes: When it is detected that the transaction value after the record meets the preset synchronization condition, the metadata table of the key-value database is read to obtain the write time; The to-be-synchronized index data in the key-value database is synchronized to the object storage node according to the write time.
5. The index data synchronization method according to claim 1, further comprising: When it is detected that the recorded transaction value does not satisfy the preset synchronization condition, a step of detecting whether the transaction value satisfies the preset synchronization condition according to a time period is performed.
6. The index data synchronization method according to claim 5, after the step of synchronizing the to-be-synchronized index data in the key-value database to the object storage node is executed, further comprising: Receiving the synchronization result returned by the object storage node; According to the synchronization result, the value of the state version number is updated; The object version number is assigned a value based on the updated state version number; wherein the value of the object version number indicates that synchronization of the to-be-synchronized index data of the target partition node is complete.
7. The index data synchronization method according to claim 6, after the step of synchronizing the to-be-synchronized index data in the key-value database to the object storage node is executed, further comprising: Determine whether the value of the object version number after the assignment is greater than the value of the temporary version number after the change; If so, the recorded transaction value is adjusted, and a synchronization completion result is sent to the target partition node according to the adjustment result.
8. The index data synchronization method according to claim 5, wherein when the target partition node submits at least two index data to be synchronized within the time period, synchronizing the index data to be synchronized in the key-value database to the object storage node comprises: Determine a submission time for submitting the at least two index data to be synchronized; Calculate the time difference between the starting index data and the ending index data in the at least two index data to be synchronized according to the submission time; When the time difference is greater than or equal to the time period, the at least two index data to be synchronized in the key-value database are synchronized to the object storage node.
9. The index data synchronization method according to claim 1, wherein the object storage node is a disaster recovery service node of the target partition node; Correspondingly, after the step of synchronizing the to-be-synchronized index data in the key-value database to the object storage node is executed, it also includes: Receive an index data read request submitted by the target partition node; Forwarding the index data read request to the disaster recovery service node, and receiving the target index data returned by the disaster recovery service node; The target index data is sent to the target partition node for data processing operations.
10. An index data synchronization system, comprising: Target partition nodes, index nodes and object storage nodes; The target partition node is configured to obtain an operation request from a user; Read the target data and perform processing operations according to the user identifier contained in the operation request; Sending the generated index data to be synchronized to the index node according to the processing operation result; The index node is configured to write the to-be-synchronized index data into the key-value database corresponding to the target partition node; change the value of the temporary version number to the value of the status version number according to the writing result; wherein the value of the temporary version number indicates the transaction status of the synchronization transaction corresponding to the target partition node, and the value of the status version number indicates the synchronization progress of the target partition node submitting the index data; record the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node; when it is detected that the recorded transaction value meets the preset synchronization condition, synchronize the to-be-synchronized index data in the key-value database to the object storage node; The object storage node is configured to store the index data to be synchronized and return a synchronization result to the target partition node.
11. The index data synchronization system according to claim 10, wherein the step of writing the to-be-synchronized index data into the key-value database corresponding to the target partition node comprises: Obtaining a node identifier of the target partition node; Determine a target key value storage area of the target partition node in the key value database according to the node identifier; The to-be-synchronized index data is written into the target key-value storage area.
12. The index data synchronization system according to claim 11, wherein writing the to-be-synchronized index data into the target key-value storage area comprises: Determine the time information for submitting the index data to be synchronized; Generate a key name of the index data to be synchronized based on the time information, and determine a key value and a data type of the index data to be synchronized; The key-value item data of the to-be-synchronized index data is composed according to the key name, the key value and the data type, and written into the target key-value storage area.
13. The index data synchronization system according to claim 10, wherein the index node is further configured as follows: Receive the synchronization result returned by the object storage node; update the value of the state version number according to the synchronization result; assign a value to the object version number based on the value of the updated state version number; wherein, The value of the object version number indicates that the synchronization of the to-be-synchronized index data of the target partition node is complete.
14. The index data synchronization system according to claim 13, wherein the index node is further configured as: Determine whether the value of the assigned object version number is greater than the value of the changed temporary version number; if so, adjust the recorded transaction value and send the synchronization completion result to the target partition node according to the adjustment result.
15. An index data synchronization device, comprising: An acquisition module is configured to acquire the index data to be synchronized submitted by the target partition node; A writing module is configured to write the to-be-synchronized index data into a key-value database corresponding to the target partition node; A change module is configured to change the value of the temporary version number to the value of the state version number according to the write result; wherein the value of the temporary version number represents the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number represents the synchronization progress of the target partition node submitting the index data; A recording module is configured to record a change behavior of the value of the temporary version number through a transaction value of a target synchronization transaction corresponding to the target partition node; The synchronization module is configured to synchronize the to-be-synchronized index data in the key-value database to the object storage node when it is detected that the transaction value after the record meets the preset synchronization condition.
16. A computing device comprising: Memory and processor; The memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions: Get the index data to be synchronized submitted by the target partition node; Writing the to-be-synchronized index data into the key-value database corresponding to the target partition node; The value of the temporary version number is changed to the value of the state version number according to the writing result; wherein the value of the temporary version number indicates the transaction state of the synchronization transaction corresponding to the target partition node, and the value of the state version number indicates the synchronization progress of the target partition node submitting the index data; Recording the change behavior of the value of the temporary version number through the transaction value of the target synchronization transaction corresponding to the target partition node; When it is detected that the transaction value after the record meets the preset synchronization condition, the index data to be synchronized in the key-value database is synchronized to the object storage node.
17. A computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the index data synchronization method according to any one of claims 1 to 9.
