WO2023109238A1 - Data synchronization method and system, and storage medium - Google Patents

Data synchronization method and system, and storage medium Download PDF

Info

Publication number
WO2023109238A1
WO2023109238A1 PCT/CN2022/120536 CN2022120536W WO2023109238A1 WO 2023109238 A1 WO2023109238 A1 WO 2023109238A1 CN 2022120536 W CN2022120536 W CN 2022120536W WO 2023109238 A1 WO2023109238 A1 WO 2023109238A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
storage node
statement
data
target operation
Prior art date
Application number
PCT/CN2022/120536
Other languages
French (fr)
Chinese (zh)
Inventor
陈洁娜
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2023109238A1 publication Critical patent/WO2023109238A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/273Asynchronous replication or reconciliation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication

Definitions

  • the present application relates to the field of computer technology, in particular to a data synchronization method, system and storage medium.
  • the common method is to send modification requests to other systems at the same time.
  • each other system needs to maintain a copy of the same code.
  • the maintainers of each other system are usually not uniform, which leads to the inconsistency of the code jointly maintained by the system. As a result, it is impossible to respond to the modification request in time, resulting in data inconsistency in the distributed storage system, resulting in low data synchronization efficiency.
  • the embodiment of the present application expects to provide a data synchronization method, system and storage medium, which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves It improves the efficiency of data synchronization in distributed storage systems.
  • a data synchronization method is applied to a first storage node, and the method includes:
  • At least one second storage node having an association relationship with the target data table is determined; wherein the target operation statement is used to change the target data table content in
  • the target operation statement is sent to the corresponding second storage node, so as to realize synchronous update of the target data table in the first storage node and the second storage node.
  • a data synchronization system the system includes: a first storage node and at least one second storage node; wherein:
  • the first storage node is configured to determine at least one second storage node associated with the target data table if a target operation statement belonging to the target operation type is detected for the target data table; wherein the target operation The statement is used to change the content in the target data table; determine the data synchronization mode of each of the second storage nodes; based on each of the data synchronization modes, send the target operation statement to the corresponding second storage node node;
  • the second storage node is configured to receive the target operation statement; use the target operation statement to perform an update operation on the target data table corresponding to the target operation statement in the second storage node, to obtain an updated result.
  • a storage medium stores a data synchronization program, and when the data synchronization program is executed by a processor, the steps of the data synchronization method described in any one of the foregoing are implemented.
  • the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node
  • the data synchronization method and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
  • FIG. 1 is a schematic flow diagram of a data synchronization method provided in an embodiment of the present application
  • FIG. 2 is a schematic flow chart of another data synchronization method provided by the embodiment of the present application.
  • FIG. 3 is a schematic flow diagram of another data synchronization method provided by the embodiment of the present application.
  • FIG. 4 is a schematic flowchart of a data synchronization method provided by another embodiment of the present application.
  • FIG. 5 is a schematic flowchart of another data synchronization method provided by another embodiment of the present application.
  • FIG. 6 is a schematic flowchart of another data synchronization method provided by another embodiment of the present application.
  • FIG. 7 is a schematic flowchart of a data synchronization method provided in another embodiment of the present application.
  • FIG. 8 is a schematic diagram of an application scenario provided by an embodiment of the present application.
  • FIG. 9 is a schematic diagram of an implementation flow of an alarm prompt provided by an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of a data synchronization system provided by an embodiment of the present application.
  • the embodiment of the present application provides a data synchronization method, as shown in FIG. 1, the method is applied to the first storage node, and the method includes the following steps:
  • Step 101 If a target operation statement belonging to the target operation type is detected for the target data table, determine at least one second storage node that has an association relationship with the target data table.
  • the target operation statement is used to change the content in the target data table.
  • the first storage node is a distributed storage node where the user modifies the content of the target data table stored therein.
  • the target operation type is mainly an operation type used to modify the content in the data table.
  • the at least one second storage node that has an association relationship with the target data table refers to a storage node that stores the target data table.
  • Step 102 Determine the data synchronization mode of each second storage node.
  • different data synchronization modes are configured for different second storage nodes.
  • the data synchronization mode of each second storage node may be adjusted according to actual synchronization conditions.
  • Data synchronization methods include at least real-time synchronization methods and asynchronous synchronization methods.
  • Step 103 based on each data synchronization mode, send the target operation statement to the corresponding second storage node.
  • the target operation statement is sent to the corresponding second storage node, so as to realize the synchronous update of the target data table in the first storage node and the second storage node.
  • the target operation statement is sent to the corresponding second storage node, so that After the second storage node obtains the target operation statement, it can directly execute the target operation statement, and then adjust and update the corresponding data content of the target data table in the second storage node.
  • the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node
  • the data synchronization method and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
  • embodiments of the present application provide a data synchronization method, which is applied to a first storage node, and the method includes the following steps:
  • Step 201 If a target operation statement belonging to the target operation type is detected for the target data table, determine at least one second storage node that has an association relationship with the target data table.
  • the target operation statement is used to change the content in the target data table.
  • the target operation statement is that when the first storage node performs a corresponding operation instruction on the target data table of the first storage node from the user, the data service layer of the first storage node responds to the operation instruction and the operation statement belongs to the target operation A statement of type that can be responded to directly by the database in the storage node.
  • the target operation type includes at least the following types: insert (Insert), delete (Delete) and change (Update), and it is determined that the obtained target operation statement belongs to at least one of the above target operation types.
  • At least one second storage node can be obtained by determining the storage node having the identification information of the target data table from the pre-stored relationship between the data table and the storage node.
  • the target operation statement can be, for example, a structured query language (Structured Query Language, SQL) type statement that can directly perform response operations on the database in the storage node, for example, it can be an Insert SQL statement for the target data table, or a Delete statement for the target data table. SQL statements and Update statements for the target data table, etc.
  • Step 202 Determine the data synchronization mode of each second storage node.
  • the configuration parameters of each second storage node are determined to obtain the data synchronization mode of each second storage node, and then the data synchronization mode of at least one second storage node can be obtained.
  • Step 203 based on each data synchronization mode, send the target operation statement to the corresponding second storage node.
  • the target operation statement is used to update the target data table in the corresponding second storage node, so as to implement synchronous update of the target data table in the first storage node and the second storage node.
  • the target operation statement when the data synchronization mode of the second storage node is real-time synchronization mode, the target operation statement can be sent to the corresponding second storage node in real-time synchronization mode, and the data synchronization mode of the second storage node is asynchronous In the synchronous mode, the target operation statement may be sent to the second storage node in an asynchronous and synchronous manner according to a preset asynchronous time period.
  • step 203 may be implemented by steps 203a-203c:
  • Step 203a if each data synchronization mode is a real-time synchronization mode, determine the table creation statement corresponding to the target data table.
  • the node configuration information of the second storage node is read, and the table creation statement corresponding to the target data table is obtained from the node configuration information .
  • Step 203b Generate a first request message based on the table creation statement and the target operation statement.
  • the table creation statement and the target operation statement are respectively filled into the request message to obtain the first request message.
  • Step 203c sending the first request message to the corresponding second storage node in a real-time synchronous manner.
  • the first request message includes the target operation statement
  • the table creation statement included in the first request message is used to generate the target data table when the second storage node detects that the target data table does not exist after receiving the first request message. data sheet.
  • the first request message is sent to the corresponding second storage node in real time in a real-time synchronous manner, so as to realize sending the target operation statement to the second storage node.
  • the first storage node is also used to perform step 204 before performing step 203:
  • Step 204 determining the target data volume corresponding to the target operation statement.
  • the first storage node determines the amount of data included in the content of the data table corresponding to the target operation statement, and after determining the number of fields included in the target data table, calculates the difference between the amount of data included in the content of the data table corresponding to the target operation statement and The quotient between the number of fields can get the target data volume.
  • step 203 can be realized by step 203d:
  • Step 203d based on the target data amount and each data synchronization mode, send the target operation statement to the corresponding second storage node.
  • the default data synchronization mode of the second storage node may be a real-time synchronization mode.
  • different preprocessing methods can be used to preprocess the target operation statement to improve the implementation efficiency of the data synchronization method and improve the ability of the target operation statement to be sent to the corresponding second storage. Node sending efficiency.
  • step 203d may be implemented by steps a11-a13:
  • Step a11 if each data synchronization method is a real-time synchronization method, and the target data volume is less than a preset threshold, determine a table creation statement corresponding to the target data table.
  • the preset threshold can be an empirical value obtained from a large number of experiments, or an empirical value set by the user according to actual needs. During use, the preset threshold can also be based on the response of the target operation statement The duration is dynamically adjusted. The preset threshold has no impact on the performance of the implementation process of the data synchronization method.
  • Step a12 generating a second request message based on the table creation statement and the target operation statement.
  • Step a13 sending the second request message to the corresponding second storage node in a real-time synchronous manner.
  • the second request message includes the target operation statement
  • the table creation statement included in the second request message is used to generate the target data table when the second storage node detects that the target data table does not exist after receiving the second request message. data sheet.
  • the data synchronization mode corresponding to the second storage node is the real-time synchronization mode
  • the target data volume of the target operation statement is less than the preset threshold
  • the target operation statement and the table creation statement are directly generated into the second request message.
  • step "determine the table creation statement corresponding to the target data table" in step 203a or step a11 can be realized through steps b11-b17:
  • Step b11 determining the call information corresponding to the target operation statement.
  • the call information is the data information of the data service layer responding to the target operation statement.
  • Step b12 from the call information, determine the reference field information used to define the structure of the target data table.
  • the corresponding node configuration information is determined from the call information, and the reference field information corresponding to the structure of the target data table can be obtained by parsing the node configuration information.
  • Step b13 replacing the reference character in the reference field information with the target character to obtain the target field information.
  • the target character can be, for example, "*%*" and the blank character "" in the SQL statement, and the corresponding reference characters are "?" and "[ ⁇ s]+". In this way, after the replacement process Get the target field information.
  • step b13 after the first storage node executes step b13, it can choose to execute steps b14 ⁇ b16, or step b17, wherein, if the target field information includes table field entity information, choose to execute steps b14 ⁇ b16, if the target field information does not include table fields Entity information, choose to execute step b17.
  • Step b14 if the target field information includes table field entity information, traverse the target field information to obtain the target field name.
  • Step b15 obtaining the reference field type corresponding to the target field name.
  • the corresponding reference field type is obtained from the table field entity information.
  • Step b16 using the target statement rule to process the reference field type to obtain a table creation statement.
  • the target statement rule is the SQL statement format requirement, for example, if the field is a string type, add single quotes (") to the field, if the field is a date type, convert the field to the date stored in the target data table Format and add single quotes ("). If the field is a valid large number with more than 16 digits, use the conversion string method that comes with the large number to convert the field to a string type and add single quotes ("). In this way, you can get the table statement.
  • Step b17 if the target field information does not include the table field entity information, obtain the statement corresponding to the target operation statement from the target field storage area to obtain the table creation statement.
  • the target field storage area may be, for example, JavaBean.
  • step 204 after the first storage node performs step 204, it is also used to perform step 205:
  • Step 205 If each data synchronization method is a real-time synchronization method, and the target data volume is greater than or equal to a preset threshold, update the corresponding data synchronization method to an asynchronous synchronization method.
  • the data synchronization mode of the second storage node is real-time synchronization mode
  • the target data volume is greater than or equal to the preset threshold
  • the target operation statement is directly sent to the second The storage node. Therefore, the data synchronization mode of the second storage node is adjusted and updated to an asynchronous synchronization mode.
  • step 203 or step 203d can also be implemented by steps c11-c16:
  • Step c11 If each data synchronization method is an asynchronous synchronization method, and the target data volume is greater than or equal to a preset threshold, generate a target operation file based on the target operation statement.
  • the data synchronization method of the second storage node is asynchronous synchronization method
  • the file can be named using the identification information of the target data table.
  • the identification information of the target data table is used In addition to naming the file, it can also include the current time and a randomly generated number, that is, use the identification information of the target data table, the current time, and the randomly generated number to name the file storing the target operation statement to obtain the target operation file.
  • each data synchronization method is an asynchronous synchronization method and the target data volume is less than a preset threshold
  • the asynchronous synchronization method is used to directly send the target operation statement to the corresponding second storage node.
  • the data synchronization method of the second storage node is an asynchronous synchronization method
  • the first storage node sends the target operation statement every preset asynchronous time period to the second storage node, so that the second storage node executes the target operation statement, and implements a synchronous update operation on the target data table and the target data table in the first storage node.
  • Step c12 sending the target operation file to the file server.
  • the file server is a server between the first storage node and at least one second storage node for storing files.
  • Step c13 receiving indication information sent by the file server for indicating the storage location of the target operation file.
  • the indication information may be the identity information (Identity Document, ID) and the corresponding hash value (Hash) generated by the file server to identify the storage file of the target operation file after receiving the target operation file .
  • ID the identity information
  • Hash the corresponding hash value generated by the file server to identify the storage file of the target operation file after receiving the target operation file .
  • the ID of the generated storage file used to identify the target operation file and the corresponding Hash can be obtained by determining the uploaded frame rate (Frames Per Second, FPS).
  • Step c14 storing the indication information.
  • Step c15 generating an acquisition instruction according to a preset asynchronous time period.
  • the obtaining instruction is used to instruct to obtain the target operation file from the instruction information of the file server, and obtain the target operation statement to execute the corresponding update operation.
  • the preset asynchronous time period may be an empirical value of a time period set according to actual conditions, or may be an empirical value of time obtained from a large number of experiments.
  • the preset asynchronous time period may be, for example, every 5 minutes, every 30 minutes, or 6:00 every day.
  • Step c16 sending an acquisition instruction to the corresponding second storage node.
  • the first storage node sends the acquisition instruction to the corresponding second storage node immediately after generating the acquisition instruction every preset asynchronous time period, so that the second storage node acquires the instruction information from the file server.
  • the target operation file at the indicated storage location, so that the second storage node executes the corresponding target operation statement in the target operation file.
  • the first storage node after the first storage node receives the indication information, it generates an acquisition instruction, and sends the acquisition instruction to the corresponding second storage node every preset asynchronous time period, realizing the first storage node and at least one second storage node.
  • steps c11-c16 may also be executed after step 205, that is, after the data synchronization mode corresponding to the second storage node is updated from real-time synchronization mode to asynchronous synchronization mode, continue to select and execute steps c11-c16.
  • step 203 after the first storage node performs step 203, it is also used to perform steps 206-207:
  • Step 206 Receive the update result sent by the corresponding second storage node.
  • the update result is an operation result of executing the target operation statement by the second storage node.
  • the update result may be sent by the second storage node to the first storage node in the form of a response message.
  • the second storage node When the data synchronization mode is the real-time synchronization mode, after the second storage node receives the second request message, it analyzes the second request message to obtain the target operation statement and the table creation statement; Whether there is a target data table corresponding to the target operation statement in the second storage node; if the target data table does not exist in the second storage node, the second storage node executes the parsed table creation statement to create the corresponding target data table, and then The target data table executes the target operation statement to obtain the operation result, that is, the update result; if the target data table exists in the second storage node, the second storage node judges whether the field information in the existing target data table is consistent with the field information in the table creation statement Consistent, where the field information includes at least field name, field type and field length and other information content; if the field information in the target data table is consistent with the field information in the table creation statement, after the second storage node caches the target data table, Execute the target operation statement for the target data table, update the
  • the execution process of the target operation statement by the second storage node is the same as that of the real-time synchronization method
  • the execution process of the target operation statement by the second storage node is the same, which is not specifically limited here.
  • the data synchronization method is asynchronous synchronization method
  • the second storage node analyzes the target operation file, and obtains the target operation file according to The chronological order of the target operation statements, each time a preset number of operation statements are obtained sequentially for execution, the corresponding execution process is consistent with the execution process of the second storage node for the target operation statements in the case of real-time synchronization, and no specific limitation is made here .
  • Step 207 based on the update result, update the data synchronization mode of the corresponding second storage node.
  • the corresponding update modes of the data synchronization mode of the corresponding second storage node are different.
  • step 207 may be implemented by step 207a or step 207b:
  • Step 207a if the data synchronization mode is the real-time synchronization mode, if the update result indicates that the execution of the target operation statement by the second storage node is abnormal, update the data synchronization mode to the asynchronous synchronization mode.
  • the data synchronization mode is real-time synchronization mode
  • the update result indicates that the second storage node successfully executes the target operation statement
  • the corresponding The data synchronization mode of the second storage node is a real-time synchronization mode.
  • Step 207b If the data synchronization mode is an asynchronous synchronization mode, if the update result indicates that the second storage node executes the target operation statement successfully, update the data synchronization mode to a real-time synchronization mode.
  • the data synchronization method when the data synchronization method is asynchronous synchronization method, if the update result indicates that the second storage node fails to execute the target operation statement, the data synchronization method will not be updated, and the data synchronization of the corresponding second storage node will continue to be maintained
  • the method is asynchronous and synchronous.
  • Step 208 If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, determine an exception priority corresponding to the update result.
  • the current synchronization process ends. If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, an exception priority corresponding to the update result is determined according to the content of the update result.
  • Step 209 perform an alarm operation corresponding to the abnormal priority.
  • the exception priority assumption includes indicating levels from high to low as: first level, second level, . . . , n level.
  • the abnormal priority includes three levels in total, the first level represents the highest priority.
  • the alarm operation can be, for example, establishing a voice communication connection with the communication device of the relevant person in charge, reminding to deal with the abnormal situation in time, and the second level represents the second highest level.
  • the corresponding alarm operation can be, for example, to establish a communication connection with the communication device of the relevant person in charge, and remind the relevant person in charge to deal with the abnormal situation when he is free by sending a prompt message.
  • the three marks indicate the lowest priority, and the corresponding The alarm operation may be, for example, generating prompt information and recording it for reference by relevant persons in charge.
  • step 206 after the first storage node performs step 206, it is also used to perform steps 210-211:
  • Step 210 if the update result indicates that the second storage node executes the target operation statement abnormally, determine the second storage node whose update result indicates that the second storage node successfully executes the target operation statement from at least one second storage node, and obtain at least one third Storage nodes.
  • the update result indicates that the execution of the target operation statement by the second storage node is abnormal
  • the second storage node associated with the target data table determine the second storage node whose update result indicates that the target operation statement is executed successfully, and obtain at least one third storage node.
  • Step 211 sending a data rollback control instruction to at least one third storage node.
  • the data rollback control instruction is used to instruct the third storage node to roll back to the data before executing the target operation statement.
  • the first storage node sends the data rollback instruction to at least one third storage node, so that at least one third storage node responds to the data rollback instruction and adopts the target data table cached before executing the target operation statement Replace the target data table after executing the target operation statement to realize the data rollback operation.
  • step 206 after the first storage node performs step 206, it is also used to perform steps 212-213:
  • Step 212 When the update result sent by each second storage node indicates that the second storage node successfully executes the target operation statement, count the data processing consumption time of each second storage node to obtain at least one data processing consumption time.
  • the first storage node analyzes at least one data processing consumption time to determine whether the current preset threshold is reasonable, and if not, analyzes according to a processing consumption time indicated to determine a new threshold to update the preset Threshold, if reasonable, there is no need to update the preset threshold.
  • step 201 may be implemented by steps 201a-201d:
  • Step 201a obtaining mapper declaration parameters and parameter type parameters in the data service layer.
  • Step 201b Process the mapper declaration parameters and parameter type parameters by using the target statement rules to obtain a reference operation statement.
  • the target statement rule that is, the SQL statement rule
  • the SQL statement rule is used to analyze the mapper declaration parameters and parameter type parameters, and splicing the parsed content to obtain the SQL statement.
  • Step 201c if the operation type of the reference operation statement is the target operation type, determine the target operation statement as the reference operation statement.
  • the reference operation statement is analyzed, and if it is determined that the reference operation statement is the target operation type, that is, Insert, Delete or Update, the reference operation statement is determined as the target operation statement.
  • Step 201d determining at least one second storage node that has an association relationship with the target data table.
  • this embodiment of the present application provides a schematic structural diagram of a data synchronization system, as shown in FIG.
  • the main operation database system, the target standby database system 1, the target standby database system 2 and the target standby database system 3 all include: a business logic application layer, a data service layer, an interceptor and a main operation database (Database, DB).
  • the interceptor includes: a data synchronization module, a synchronization result processing module, a data delivery exception monitoring and feedback processing module, and a threshold setting module. It should be noted that in FIG.
  • the main operating system library corresponds to the aforementioned first storage node
  • the target backup library system 1 corresponds to the aforementioned at least one second storage node
  • the first storage node and the second storage node The functions of the roles can be replaced with each other.
  • the embodiment of the present application provides a data synchronization method, and the specific implementation process is as follows:
  • the business logic layer of the main operation database system After the business logic layer of the main operation database system receives the operation request sent by the user for updating the target data table in the main operation database, the business logic layer sends the operation request to the data service layer, and the corresponding The data operation statement responds to the operation request and realizes the operation on the target data table.
  • the interceptor in the main operation library system intercepts the corresponding data operation statement in the data service layer, analyzes the intercepted data operation statement, and determines the target operation type for the target data table, such as Insert type, Delete type and Update Target action statement of type etc.
  • At least one second storage node that has an association relationship with the target data table is determined as the target standby database system 1, the target standby database system 2, and the target standby database system 3, and Determine the data synchronization methods corresponding to target backup system 1, target backup system 2, and target backup system 3, and use the data synchronization methods corresponding to target backup system 1, target backup system 2, and target backup system 3 to synchronize the target
  • the operation statement implements the synchronization process, and receives the update results sent by the target standby database system 1, the target standby database system 2, and the target standby database system 3.
  • the main operating database system can also synchronize the data of the target standby database system 1, the target standby database system 2 and the target standby database system 3 according to the update results sent by the target standby database system 1, the target standby database system 2 and the target standby database system 3 Update and adjust preset thresholds, etc., so as to realize a complete closed-loop feedback system and ensure an effective synchronization strategy.
  • Determining at least one second storage node that has an association relationship with the target data table may be determined from a pre-stored relationship between the data table and the storage node.
  • the relationship between the pre-stored data table and the storage node can be determined from the annotations included in the corresponding framework script, for example, it can be determined from the annotations included in the Spring framework's aspect-oriented programming (Aspect Oriented Programming, AOP),
  • AOP Application Oriented Programming
  • the relationship between the pre-stored data table and the storage node can be expressed in the form of a list, for example, as shown in Table 1, DcnRouter is the identification information of the target data table, SysName is the system name information of the system with the target data table, DcnNo is the system number information of the system with the target data table, and ServiceId is the corresponding mapping relationship when information is sent between the systems with the target data table.
  • the interceptor in the main operating library system can be, for example, a plugin function provided by a persistence layer framework such as MyBatis. Remote call can be used between the main operating library system and the target standby library system.
  • the process for the interceptor to obtain the target operation statement can be, for example: the interceptor obtains the parameters in the data operation statement of the data service layer in response to the operation request, and parses out the command type included in the mapper (mapper) statement (MappedStatement) such as SqlCommandTypeSql from the parameters . According to the command type such as SqlCommandTypeSql, the target operation statement of Insert type, Delete type and Update type is determined.
  • Determining at least one second storage node that has an association relationship with the target data table can also be that the interceptor obtains the class name according to the intercepted mapping statement identifier such as MappedStatementId, maps the class object information according to the class name, and judges the class object information according to the class object information. Whether there are annotations and annotation parameters added to the class, if annotations and annotation parameters are added, it can be determined to obtain at least one second storage node that has an association relationship with the target data table.
  • the interceptor obtains the class name according to the intercepted mapping statement identifier such as MappedStatementId
  • the specific process for the interceptor to determine the target operation statements of the Insert type, Delete type, and Update type according to the command type such as SqlCommandTypeSql can be: the interceptor obtains boundSQL for the MappedStatement and parameter type (ParamObject) in the data service layer. According to the two parameters of MappedStatement and ParamObject, it is parsed and spliced into SQL statements of the target operation type that can be directly executed to obtain the target operation statement. Further, according to the amount of data in the parameter list of boundSQL divided by the number of fields in the table structure, the target data amount to be executed in the SQL statement is obtained.
  • the interceptor parses the node configuration information in the data operation statement that the data service layer responds to the operation request. Since the node configuration information includes each field information that defines the structure of the target data table, each field information in the node configuration information can be traversed , and splicing out the table creation statement of the target data table.
  • the specific implementation process can be: replace all placeholders "?” in the node configuration information with "*%*", replace all blank characters "[ ⁇ s]+” with "”, and obtain the replaced node configuration information; Determine whether the table field entity class is used as a parameter in the replaced node configuration information; if the table field entity class is used as a parameter in the replaced node configuration information, loop through the parameter list in turn to determine the parameter set and the parameter that belong to the user.
  • Mapping relationship collection obtain the field name and field type from the parameter collection passed in by the user and the parameter mapping relationship collection; obtain the field type from the corresponding collection according to the obtained field name.
  • the specific implementation process is: if the field is a string type, add single quotes (") to the field, if the field is a date type, convert the field to the date format stored in the target data table and add single quotes ("), if the field is a valid large number with more than 16 digits, pass the large number
  • the built-in conversion string method converts the field into a string type and adds single quotes (") to get the table creation statement; if the replaced node configuration information does not use the table field entity class as a parameter, get it from JavaBean Entity class batch parameters, you can get the table creation statement.
  • the table creation statement is also a SQL statement.
  • the data synchronization module of the interceptor determines the data synchronization mode of each target standby database system. Among them, the initial data synchronization mode of each target standby database system defaults to the real-time synchronization mode.
  • the data synchronization module of the interceptor checks whether the target data volume reaches the set preset threshold value. When the data synchronization mode is the real-time synchronization mode, if the target data volume is less than the preset threshold value, the data synchronization mode is kept as the real-time synchronization mode.
  • the target data volume is greater than or equal to the preset threshold, and the data synchronization method is updated from the real-time synchronization method to the asynchronous synchronization method.
  • the data synchronization method is an asynchronous synchronization method
  • the data synchronization method can be realized through two parameters of the table name and the data synchronization method when recording. Further, in the process of the asynchronous and synchronous manner, the format shown in Table 2 may be used to implement a specific asynchronous and synchronous manner.
  • the table_name parameter is used to indicate the table name of the target data table
  • the dcn_no parameter is used to indicate the number of the target backup system that receives the target operation data
  • the sql parameter is used to record the SQL that needs to be synchronized when the process_type is SQL Script, otherwise it is empty
  • id_hash is used to record the ID and Hash value of the storage target operation file converted when the target operation file is uploaded to the file server when the process_type is FILE
  • process_type is used to identify the specific execution type of the asynchronous and synchronous mode, It is identified by FILE representing the asynchronous file synchronization method and SQL representing the asynchronous data synchronization method
  • create_time is used to represent the current time when the asynchronous synchronization method is generated, and this event can be used as a logical sequence for subsequent synchronization
  • sys_seq is used to represent the asynchronous synchronization method The corresponding current serial number is used by the operation and maintenance personnel to use the
  • the interceptor fills the determined target operation statement and the table creation statement into the real-time request message, and sends the real-time
  • the request message is published to the real-time message queue corresponding to the system number corresponding to the target standby database system 1, and the real-time request message is sent to the target standby database system 1 in the form of a queue message.
  • the target standby database system 1 After receiving the real-time request message, the target standby database system 1 performs the following judgments on the real-time request message: judge whether there is a target data table with a table structure corresponding to the table-building statement in the target standby database system 1; if the target standby database system 1 There is no matching target data table in the real-time request message, execute the table creation statement in the real-time request message to create the target data table, and then execute the target operation statement in the real-time request message to obtain the update result of the target operation statement, and The update result is filled in the response message and sent to the main operating database system; if there is a matching target data table in the target standby database system 1, further check whether the field name, field type, and field length in the table creation statement are in the target standby database system 1 The field names, field types, and field lengths of the target data table are consistent; if the field names, field types, and field lengths are all consistent, first cache the target data table in the target standby database system 1, and then execute the
  • the synchronization result processing module of the main operation database system interceptor receives the response message sent by the target standby database system 1, if the response message indicates that the target standby database system 1 has successfully executed synchronously (that is, the aforementioned execution of the target operation statement is successful), the target The data synchronization operation of standby database system 1 is completed.
  • the response message indicates that the target standby database system 1 fails to execute synchronously (that is, the aforementioned execution of the target operand statement is abnormal)
  • the standby database system subsystem that has been successfully executed before, finally records the target operation statement of this synchronization and the system number record corresponding to the target standby database system 1 according to Table 2, and updates the process_type field in Table 2 to SQL.
  • the response message indicates that the target standby database system 1 fails to execute synchronously, the abnormal information needs to be persisted.
  • the information structure of the persistent abnormal information can be shown in Table 3, and some content identifiers in Table 3 are the same as those in Table 2. I won’t go into details here.
  • the route_sys_name in Table 3 is used to identify the system name of the standby database where the abnormal execution occurs, which is convenient for the operation and maintenance personnel to locate the system log; remark is used to indicate the remark, which is mainly used to record the cause of the execution failure and serve as an alarm Critical log; urgent_type is used to identify the urgent type, where H indicates high priority, L indicates low priority, and D has completed processing.
  • the interceptor's data delivery exception monitoring and feedback processing module determines that urgent_type is an exception information record with high priority, that is, H, for high priority
  • the urgent_type can trigger voice communication, such as reminding the relevant person in charge, so that the relevant person in charge can confirm whether the inconsistency of the upstream and downstream fields can be adjusted. After the adjustment is consistent, the urgent_type can be changed to D and processed.
  • the interceptor's data delivery exception monitoring and feedback processing module determines that the urgent_type is an exception information record with low priority L. For the low priority urgent_type, you can send a prompt message such as a text message or voice information to remind the relevant person in charge, so that the relevant person in charge can centrally arrange time for processing, and the relevant person in charge changes urgent_type to D after processing.
  • the data of the interceptor is sent to the exception monitoring and feedback processing module It is also necessary to perform a data rollback operation on the target standby database system 2 and the target standby database system 3.
  • the main operating library system determines the system numbers of target standby database system 2 and target standby database system 3, assembles the SQL regression statement to be executed into a rollback notification message, and publishes it to the data rollback queue for sending to the corresponding target standby database. Database system 2 and target standby database system 3.
  • target standby database system 2 and the target standby database system 3 After the target standby database system 2 and the target standby database system 3 receive the rollback notification message, they will perform corresponding data rollback: for example, when the target operation statement is Insert type, the newly added and successful data will be deleted; if the target operation statement is Update Type, find out the backup data before updating through the update condition, and restore the data; if the target operation statement is the Delete type, find out the backup data before deleting through the condition to restore.
  • the data synchronization module of the interceptor determines that the data synchronization mode of the target standby database system 1 is an asynchronous data synchronization mode
  • the data synchronization module of the interceptor of the main operation library system fills the target operation statement into the asynchronous request message, and sends the asynchronous request
  • the message is published to the asynchronous message queue corresponding to the system number corresponding to the target standby database system 1, and the target operation data is sent to the target standby database system 1 according to the preset asynchronous time period, for example, every 30 minutes.
  • the implementation process after the target backup system 1 receives the asynchronous request message is the same as the processing steps for the target backup system 1 to receive the real-time request message, and will not be described in detail here.
  • the data synchronization module of the interceptor determines that the data synchronization method of the target standby database system 1 is an asynchronous file synchronization method
  • the data synchronization module of the interceptor of the main operating library system first creates a file in the local system, with the name of the target data table, the current Date and random production number to name the created file; write the target operation statement into the created file; upload the file including the target operation statement to the file server, and the file server will return the storage for the file including the target operation statement
  • the unique identifier of the location that is, for the id_hash field in Table 2 and Table 3.
  • the data synchronization module of the interceptor fills the returned unique identifier into the asynchronous request message, and publishes the asynchronous request message to the asynchronous message queue corresponding to the system number corresponding to the target backup system 1, and transfers the target operation data according to the preset Set the asynchronous time period, for example, to send the messages in the asynchronous message queue to the target standby database system 1 every 30 minutes.
  • the processing steps of the text are the same, and will not be described in detail here.
  • the specific implementation process of writing the target operation statement into the created file can be writing all the statements in the target operation statement into the created file, or grouping the operation statements in the target operation statement according to a certain number, Generate at least one file to achieve asynchronous synchronization.
  • the asynchronous processing result of the asynchronous synchronous mode is basically the same as the result processing of the synchronous mode, the difference is that the data synchronous mode is updated to real-time synchronous update after receiving the return message of successful data synchronization.
  • the threshold setting module of the main operation library system interceptor is based on Spring’s AOP annotation @CollectionReccateTime(), to collect and execute data synchronization successfully, the time-consuming period between the detection of the user’s operation request and the detection of the successful synchronization and the current synchronization
  • the amount of target data included, data collection and observation of these two values of the three types of data operations, respectively, can obtain the data time-consuming record results shown in Table 4, so that the relevant person in charge can understand the data shown in Table 4
  • time-consuming corresponding to an operation type time-consuming parsing request + ⁇ (time-consuming data acquisition + time-consuming processing data) + time-consuming assembling and returning results, ⁇ (time-consuming data acquisition + time-consuming processing data) corresponds to the operation type The amount of data and the time-consuming operation statement.
  • each new emergency type For high-priority abnormal information the relevant person in charge can be reminded by immediately triggering a phone call reminder. If the relevant person in charge handles the high-priority abnormal information, change the emergency type in the abnormal information to processed. If the relevant person in charge The high-priority exception information is not processed, and the emergency type in the exception record information is kept as high priority, and the trigger logic is put into the delay queue, and the virtual phone outbound platform is triggered again after a certain delay, for example, 5 minutes.
  • an abnormal information scanning operation can be triggered after the data synchronization is completed, that is, a regular polling method is used to scan the records with an urgent type of low priority in the abnormal information records , converting the scanned exception information records with the urgent type of low priority into a request message format and sending them to the text information platform to realize the text information reminder until the urgent type in the abnormal information records is changed to processed.
  • the text information platform may be, for example, a short message platform.
  • the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node
  • the data synchronization method and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
  • the embodiments of the present application provide a data synchronization system, which can be applied to the data synchronization methods provided in the embodiments corresponding to FIGS. 1 to 7.
  • the data synchronization system 3 It may include: a first storage node 31 and at least one second storage node 32, wherein:
  • the first storage node 31 is used to store the target data table, and execute the data synchronization program to achieve the following steps: if a target operation statement belonging to the target operation type for the target data table is detected, determine the associated relationship with the target data table At least one second storage node; wherein, the target operation statement is used to change the content in the target data table; determine the data synchronization mode of each second storage node; based on each data synchronization mode, send the target operation statement to the corresponding second A storage node, so as to realize the synchronous update of the target data table in the first storage node and the second storage node;
  • the second storage node 32 is configured to receive the target operation statement; use the target operation statement to perform an update operation on the target data table corresponding to the target operation statement in the second storage node to obtain an update result.
  • the first storage node 31 executes the step based on each data synchronization method, when sending the target operation statement to the corresponding second storage node, it can be implemented through the following steps:
  • each data synchronization method is a real-time synchronization method, determine the table creation statement corresponding to the target data table;
  • the target data table is generated.
  • the execution step of the first storage node 31 is also used to perform the following steps before sending the target operation statement to the corresponding second storage node based on each data synchronization method:
  • the target operation statement is sent to the corresponding second storage node.
  • the first storage node 31 when the first storage node 31 performs the step of sending the target operation statement to the corresponding second storage node based on the target data volume and each data synchronization method, it can be implemented through the following steps:
  • each data synchronization method is a real-time synchronization method, and the target data volume is less than a preset threshold, determine the table creation statement corresponding to the target data table;
  • the second request message includes a target operation statement
  • the table creation statement included in the second request message is used to receive the second request message at the second storage node After the second request message, when it is detected that the target data table does not exist, the target data table is generated.
  • the first storage node 31 when the first storage node 31 performs the step of determining the table creation statement corresponding to the target data table, it may be implemented through the following steps:
  • target field information includes table field entity information, traverse the target field information to get the target field name;
  • the statement corresponding to the target operation statement is obtained from the target field storage area to obtain the table creation statement.
  • the first storage node 31 is further configured to perform the following steps:
  • each data synchronization method is a real-time synchronization method, and the target data volume is greater than or equal to a preset threshold, update the corresponding data synchronization method to an asynchronous synchronization method.
  • the first storage node 31 is further configured to perform the following steps:
  • each data synchronization method is an asynchronous synchronization method, and the target data volume is greater than or equal to a preset threshold, generate a target operation file based on the target operation statement;
  • the acquisition instruction is used to instruct to acquire the target operation file from the instruction information of the file server, and obtain the target operation statement to perform the corresponding update operation;
  • the execution step of the first storage node 31 is based on each data synchronization method, and after sending the target operation statement to the corresponding second storage node, it is also used to perform the following steps:
  • the update result is the operation result of the second storage node executing the target operation statement
  • the data synchronization mode of the corresponding second storage node is updated.
  • the first storage node 31 executes the step of updating the data synchronization mode of the corresponding second storage node based on the update result, it can be implemented through the following steps:
  • the update data synchronization method is real-time synchronization method
  • the update data synchronization method is an asynchronous synchronization method
  • the updated data synchronization method is a real-time synchronization method.
  • the first storage node 31 after the first storage node 31 performs the step of receiving the update result sent by the corresponding second storage node, it is also used to perform the following steps:
  • the first storage node 31 after the first storage node 31 performs the step of receiving the update result sent by the corresponding second storage node, it is also used to perform the following steps:
  • the first storage node 31 is further configured to perform the following steps:
  • the preset threshold is updated based on at least one data processing consumption time period.
  • the first storage node 31 executes the step and detects a target operation statement belonging to the target operation type for the target data table and determines at least one second storage node that has an association relationship with the target data table, it may Do this by following these steps:
  • At least one second storage node that has an association relationship with the target data table is determined.
  • the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node
  • the data synchronization method and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
  • the embodiments of the present application provide a computer-readable storage medium, referred to as a storage medium for short, where one or more programs are stored in the computer-readable storage medium, and the one or more programs can be used by one or more
  • the processor executes to implement the implementation process of the data synchronization method provided in the embodiments corresponding to FIGS. 1 to 7 , which will not be repeated here.
  • An embodiment of the present application provides a data synchronization method, system, and storage medium.
  • the method includes: if a target operation statement belonging to the target operation type is detected for the target data table, determining at least one The second storage node; wherein, the target operation statement is used to change the content in the target data table; determine the data synchronization mode of each of the second storage nodes; based on each of the data synchronization modes, send the The target operation statement is sent to the corresponding second storage node to realize the synchronous update of the target data table in the first storage node and the second storage node, which solves the problem of data synchronization efficiency in the current distributed storage system and effectively guarantees It improves the consistency of data in the distributed storage system and improves the efficiency of data synchronization in the distributed storage system.

Abstract

Disclosed in the present application is a data synchronization method. The method comprises: if a target operation statement of a target operation type addressing a target data table is detected, determining at least one second storage node which has a correlation with the target data table, wherein the target operation statement is used for changing the content in the target data table; determining a data synchronization mode of each second storage node; and on the basis of each data synchronization mode, sending the target operation statement to the corresponding second storage node, so as to realize a synchronous update on the target data table in the first storage node and the second storage node. Further disclosed in the present application are a data synchronization system and a storage medium.

Description

一种数据同步方法、系统及存储介质A data synchronization method, system and storage medium
相关申请的交叉引用Cross References to Related Applications
本申请基于申请号为202111552168.X、申请日为2021年12月17日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is based on a Chinese patent application with application number 202111552168.X and a filing date of December 17, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated by reference into this application.
技术领域technical field
本申请涉及计算机技术领域,尤其涉及一种数据同步方法、系统及存储介质。The present application relates to the field of computer technology, in particular to a data synchronization method, system and storage medium.
背景技术Background technique
随着计算机技术的飞速发展,越来越多的技术应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性和实时性要求,也对技术提出了更高的要求。随着用户的需求的不断增长,为了保障用户的使用体验,分布式存储系统得到了广泛应用。在分布式存储系统应用场景下,对某一存储系统中的数据需进行改动操作,例如增删改等时,需要将其对应的其他系统中的副本数据也要进行相应的改动,以保证数据一致。With the rapid development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually transforming into financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, more and more technical requirements high demands. With the increasing demands of users, distributed storage systems have been widely used in order to ensure user experience. In the application scenario of a distributed storage system, when the data in a certain storage system needs to be modified, such as adding, deleting, modifying, etc., it is necessary to make corresponding changes to the corresponding copy data in other systems to ensure data consistency. .
目前,针对某一存储系统中的数据需进行改动操作时,对其他系统中的副本数据也要进行相应的改动时,常用的方式为同时发送改动请求至其他系统。但这种实现过程中,每一其他系统均需要维护一份相同的代码,但是由于业务系统迭代速度较快,各其他系统的维护人员通常是不统一的,如此导致系统共同维护的代码不一致,从而出现不能及时响应改动请求,导致分布式存储系统中的数据不一致,造成数据同步效率较低。At present, when the data in a storage system needs to be modified, and the copy data in other systems needs to be modified accordingly, the common method is to send modification requests to other systems at the same time. However, in this implementation process, each other system needs to maintain a copy of the same code. However, due to the fast iteration speed of the business system, the maintainers of each other system are usually not uniform, which leads to the inconsistency of the code jointly maintained by the system. As a result, it is impossible to respond to the modification request in time, resulting in data inconsistency in the distributed storage system, resulting in low data synchronization efficiency.
发明内容Contents of the invention
为解决上述技术问题,本申请实施例期望提供一种数据同步方法、系统及存储介质,解决了目前分布式存储系统数据同步效率的问题,有效保证了分布式存储系统中数据的一致性,提高了分布式存储系统中数据同步效率。In order to solve the above technical problems, the embodiment of the present application expects to provide a data synchronization method, system and storage medium, which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves It improves the efficiency of data synchronization in distributed storage systems.
本申请的技术方案是这样实现的:The technical scheme of the present application is realized like this:
第一方面,一种数据同步方法,所述方法应用于第一存储节点,所述方法包括:In a first aspect, a data synchronization method is applied to a first storage node, and the method includes:
若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与所述目标数据表具有关联关系的至少一个第二存储节点;其中,所述目标操作语句用于改变所述目标数据表中的内容;If a target operation statement belonging to the target operation type for the target data table is detected, at least one second storage node having an association relationship with the target data table is determined; wherein the target operation statement is used to change the target data table content in
确定每一所述第二存储节点的数据同步方式;determining a data synchronization mode for each of the second storage nodes;
基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点,以实现第一存储节点和第二存储节点中针对所述目标数据表的同步更新。Based on each of the data synchronization modes, the target operation statement is sent to the corresponding second storage node, so as to realize synchronous update of the target data table in the first storage node and the second storage node.
第二方面,一种数据同步系统,所述系统包括:第一存储节点和至少一个第二存储节点;其中:In a second aspect, a data synchronization system, the system includes: a first storage node and at least one second storage node; wherein:
所述第一存储节点,用于若检测到针对目标数据表的属于目标操作类型的目标 操作语句,确定与所述目标数据表具有关联关系的至少一个第二存储节点;其中,所述目标操作语句用于改变所述目标数据表中的内容;确定每一所述第二存储节点的数据同步方式;基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点;The first storage node is configured to determine at least one second storage node associated with the target data table if a target operation statement belonging to the target operation type is detected for the target data table; wherein the target operation The statement is used to change the content in the target data table; determine the data synchronization mode of each of the second storage nodes; based on each of the data synchronization modes, send the target operation statement to the corresponding second storage node node;
所述第二存储节点,用于接收所述目标操作语句;采用所述目标操作语句,对所述第二存储节点中与所述目标操作语句对应的所述目标数据表执行更新操作,得到更新结果。The second storage node is configured to receive the target operation statement; use the target operation statement to perform an update operation on the target data table corresponding to the target operation statement in the second storage node, to obtain an updated result.
第三方面,一种存储介质,所述存储介质上存储有数据同步程序,所述数据同步程序被处理器执行时实现如上述任一项所述的数据同步方法的步骤。In a third aspect, a storage medium stores a data synchronization program, and when the data synchronization program is executed by a processor, the steps of the data synchronization method described in any one of the foregoing are implemented.
本申请实施例中,若检测到针对目标数据表的属于目标操作类型的目标操作语句,第一存储节点确定与目标数据表具有关联关系的至少一个第二存储节点,确定每一第二存储节点的数据同步方式,并基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,以使第二存储节点执行目标操作语句,实现与第一存储节点针对目标数据表的同步更新操作,解决了目前分布式存储系统数据同步效率的问题,有效保证了分布式存储系统中数据的一致性,提高了分布式存储系统中数据同步效率。In the embodiment of the present application, if a target operation statement belonging to the target operation type is detected for the target data table, the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node The data synchronization method, and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
附图说明Description of drawings
图1为本申请实施例提供的一种数据同步方法的流程示意图;FIG. 1 is a schematic flow diagram of a data synchronization method provided in an embodiment of the present application;
图2为本申请实施例提供的另一种数据同步方法的流程示意图;FIG. 2 is a schematic flow chart of another data synchronization method provided by the embodiment of the present application;
图3为本申请实施例提供的又一种数据同步方法的流程示意图;FIG. 3 is a schematic flow diagram of another data synchronization method provided by the embodiment of the present application;
图4为本申请另一实施例提供的一种数据同步方法的流程示意图;FIG. 4 is a schematic flowchart of a data synchronization method provided by another embodiment of the present application;
图5为本申请另一实施例提供的另一种数据同步方法的流程示意图;FIG. 5 is a schematic flowchart of another data synchronization method provided by another embodiment of the present application;
图6为本申请另一实施例提供的又一种数据同步方法的流程示意图;FIG. 6 is a schematic flowchart of another data synchronization method provided by another embodiment of the present application;
图7为本申请又一实施例提供的一种数据同步方法的流程示意图;FIG. 7 is a schematic flowchart of a data synchronization method provided in another embodiment of the present application;
图8为本申请实施例提供的一种应用场景示意图;FIG. 8 is a schematic diagram of an application scenario provided by an embodiment of the present application;
图9为本申请实施例提供的一种告警提示实现流程示意图。FIG. 9 is a schematic diagram of an implementation flow of an alarm prompt provided by an embodiment of the present application.
图10为本申请实施例提供的一种数据同步系统的结构示意图。FIG. 10 is a schematic structural diagram of a data synchronization system provided by an embodiment of the present application.
具体实施方式Detailed ways
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述,所描述的实施例不应视为对本申请的限制,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the application clearer, the application will be further described in detail below in conjunction with the accompanying drawings. All other embodiments obtained under the premise of creative labor belong to the scope of protection of this application.
除非另有定义,本文所使用的所有的技术和科学术语与属于本申请的技术领域的技术人员通常理解的含义相同。本文中所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
本申请的实施例提供一种数据同步方法,参照图1所示,方法应用于第一存储节点,该方法包括以下步骤:The embodiment of the present application provides a data synchronization method, as shown in FIG. 1, the method is applied to the first storage node, and the method includes the following steps:
步骤101、若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与目标数据表具有关联关系的至少一个第二存储节点。Step 101: If a target operation statement belonging to the target operation type is detected for the target data table, determine at least one second storage node that has an association relationship with the target data table.
其中,目标操作语句用于改变目标数据表中的内容。Among them, the target operation statement is used to change the content in the target data table.
在本申请实施例中,第一存储节点为用户对其存储的目标数据表进行内容改动的分布式存储节点。目标操作类型主要为用于对数据表中的内容进行改动的操作类型。与目标数据表具有关联关系的至少一个第二存储节点指的是存储由目标数据表的存储节点。In the embodiment of the present application, the first storage node is a distributed storage node where the user modifies the content of the target data table stored therein. The target operation type is mainly an operation type used to modify the content in the data table. The at least one second storage node that has an association relationship with the target data table refers to a storage node that stores the target data table.
步骤102、确定每一第二存储节点的数据同步方式。 Step 102. Determine the data synchronization mode of each second storage node.
在本申请实施例中,针对不同的第二存储节点配置有不同的数据同步方式,在同步过程中,可以根据实际同步情况对每一第二存储节点的数据同步方式进行调整。数据同步方式至少包括实时同步方式和异步同步方式。In this embodiment of the present application, different data synchronization modes are configured for different second storage nodes. During the synchronization process, the data synchronization mode of each second storage node may be adjusted according to actual synchronization conditions. Data synchronization methods include at least real-time synchronization methods and asynchronous synchronization methods.
步骤103、基于每一数据同步方式,发送目标操作语句至对应的第二存储节点。 Step 103, based on each data synchronization mode, send the target operation statement to the corresponding second storage node.
其中,基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,以实现第一存储节点和第二存储节点中针对目标数据表的同步更新。Wherein, based on each data synchronization mode, the target operation statement is sent to the corresponding second storage node, so as to realize the synchronous update of the target data table in the first storage node and the second storage node.
在本申请实施例中,第一存储节点确定每一第二存储节点的数据同步方式后,基于每一第二存储节点的数据同步方式,将目标操作语句发送至对应的第二存储节点,以便第二存储节点获取到目标操作语句后,可以直接执行目标操作语句,进而实现对第二存储节点中的目标数据表进行相应的数据内容进行调整更新。In this embodiment of the application, after the first storage node determines the data synchronization mode of each second storage node, based on the data synchronization mode of each second storage node, the target operation statement is sent to the corresponding second storage node, so that After the second storage node obtains the target operation statement, it can directly execute the target operation statement, and then adjust and update the corresponding data content of the target data table in the second storage node.
本申请实施例中,若检测到针对目标数据表的属于目标操作类型的目标操作语句,第一存储节点确定与目标数据表具有关联关系的至少一个第二存储节点,确定每一第二存储节点的数据同步方式,并基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,以使第二存储节点执行目标操作语句,实现与第一存储节点针对目标数据表的同步更新操作,解决了目前分布式存储系统数据同步效率的问题,有效保证了分布式存储系统中数据的一致性,提高了分布式存储系统中数据同步效率。In the embodiment of the present application, if a target operation statement belonging to the target operation type is detected for the target data table, the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node The data synchronization method, and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
基于前述实施例,本申请的实施例提供一种数据同步方法,该方法应用于第一存储节点,该方法包括以下步骤:Based on the foregoing embodiments, embodiments of the present application provide a data synchronization method, which is applied to a first storage node, and the method includes the following steps:
步骤201、若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与目标数据表具有关联关系的至少一个第二存储节点。Step 201: If a target operation statement belonging to the target operation type is detected for the target data table, determine at least one second storage node that has an association relationship with the target data table.
其中,目标操作语句用于改变目标数据表中的内容。Among them, the target operation statement is used to change the content in the target data table.
在本申请实施例中,目标操作语句为第一存储节点从用户对第一存储节点的目标数据表进行相应的操作指令时,第一存储节点的数据服务层响应操作指令操作语句中属于目标操作类型的语句,其可以由存储节点中的数据库进行直接响应。目标操作类型至少包括以下类型:插入(Insert)、删(Delete)和改(Update),确定得 到的目标操作语句属于以上目标操作类型中的至少一种。在确定与目标操作表具有关联关系的至少一个第二存储节点时,可以是从预先存储的数据表与存储节点之间的关系中确定得到的,例如,确定得到目标数据表后,可以确定得到目标数据表的标识信息,从预先存储的数据表与存储节点之间的关系中确定具有目标数据表的标识信息的存储节点,即可得到至少一个第二存储节点。目标操作语句例如可以是对存储节点中数据库可以直接进行响应操作的结构化查询语言(Structured Query Language,SQL)类型的语句,例如可以是针对目标数据表的Insert SQL语句、针对目标数据表的Delete SQL语句和针对目标数据表的Update语句等。In this embodiment of the application, the target operation statement is that when the first storage node performs a corresponding operation instruction on the target data table of the first storage node from the user, the data service layer of the first storage node responds to the operation instruction and the operation statement belongs to the target operation A statement of type that can be responded to directly by the database in the storage node. The target operation type includes at least the following types: insert (Insert), delete (Delete) and change (Update), and it is determined that the obtained target operation statement belongs to at least one of the above target operation types. When determining at least one second storage node that has an association relationship with the target operation table, it may be determined from the relationship between the pre-stored data table and the storage node. For example, after the target data table is determined, it may be determined to obtain For the identification information of the target data table, at least one second storage node can be obtained by determining the storage node having the identification information of the target data table from the pre-stored relationship between the data table and the storage node. The target operation statement can be, for example, a structured query language (Structured Query Language, SQL) type statement that can directly perform response operations on the database in the storage node, for example, it can be an Insert SQL statement for the target data table, or a Delete statement for the target data table. SQL statements and Update statements for the target data table, etc.
步骤202、确定每一第二存储节点的数据同步方式。 Step 202. Determine the data synchronization mode of each second storage node.
在本申请实施例中,确定每一第二存储节点的配置参数,得到每一第二存储节点的数据同步方式,进而可以得到至少一个第二存储节点的数据同步方式。In the embodiment of the present application, the configuration parameters of each second storage node are determined to obtain the data synchronization mode of each second storage node, and then the data synchronization mode of at least one second storage node can be obtained.
步骤203、基于每一数据同步方式,发送目标操作语句至对应的第二存储节点。 Step 203, based on each data synchronization mode, send the target operation statement to the corresponding second storage node.
其中,目标操作语句用于对对应的第二存储节点中的目标数据表进行更新操作,以实现第一存储节点和第二存储节点中针对目标数据表的同步更新。Wherein, the target operation statement is used to update the target data table in the corresponding second storage node, so as to implement synchronous update of the target data table in the first storage node and the second storage node.
在本申请实施例中,第二存储节点的数据同步方式为实时同步方式时,可以采用实时同步方式将目标操作语句发送至对应的第二存储节点,在第二存储节点的数据同步方式为异步同步方式时,可以按照预设异步时间周期,采用异步同步方式将目标操作语句发送至第二存储节点。In this embodiment of the application, when the data synchronization mode of the second storage node is real-time synchronization mode, the target operation statement can be sent to the corresponding second storage node in real-time synchronization mode, and the data synchronization mode of the second storage node is asynchronous In the synchronous mode, the target operation statement may be sent to the second storage node in an asynchronous and synchronous manner according to a preset asynchronous time period.
基于前述实施例,在本申请其他实施例中,步骤203可以由步骤203a~203c来实现:Based on the foregoing embodiments, in other embodiments of the present application, step 203 may be implemented by steps 203a-203c:
步骤203a、若每一数据同步方式为实时同步方式,确定目标数据表对应的建表语句。Step 203a, if each data synchronization mode is a real-time synchronization mode, determine the table creation statement corresponding to the target data table.
在本申请实施例中,在第二存储节点的数据同步方式为实时同步方式时,对第二存储节点的节点配置信息进行读取,从节点配置信息中获取得到目标数据表对应的建表语句。In the embodiment of the present application, when the data synchronization mode of the second storage node is the real-time synchronization mode, the node configuration information of the second storage node is read, and the table creation statement corresponding to the target data table is obtained from the node configuration information .
步骤203b、基于建表语句和目标操作语句,生成第一请求报文。Step 203b: Generate a first request message based on the table creation statement and the target operation statement.
在本申请实施例中,将建表语句和目标操作语句分别填充到请求报文中,得到第一请求报文。In the embodiment of the present application, the table creation statement and the target operation statement are respectively filled into the request message to obtain the first request message.
步骤203c、通过实时同步方式发送第一请求报文至对应的第二存储节点。Step 203c, sending the first request message to the corresponding second storage node in a real-time synchronous manner.
其中,第一请求报文包括目标操作语句,第一请求报文中包括的建表语句用于在第二存储节点接收到第一请求报文后,检测到目标数据表不存在时,生成目标数据表。Wherein, the first request message includes the target operation statement, and the table creation statement included in the first request message is used to generate the target data table when the second storage node detects that the target data table does not exist after receiving the first request message. data sheet.
在本申请实施例中,通过实时同步方式将第一请求报文实时发送至对应的第二存储节点中,实现将目标操作语句发送至第二存储节点。In the embodiment of the present application, the first request message is sent to the corresponding second storage node in real time in a real-time synchronous manner, so as to realize sending the target operation statement to the second storage node.
基于前述实施例,在本申请其他实施例中,参照图2所示,第一存储节点执行步骤203之前,还用于执行步骤204:Based on the foregoing embodiments, in other embodiments of the present application, referring to FIG. 2 , the first storage node is also used to perform step 204 before performing step 203:
步骤204、确定目标操作语句对应的目标数据量。 Step 204, determining the target data volume corresponding to the target operation statement.
在本申请实施例中,第一存储节点确定目标操作语句对应的数据表内容包括的数据量,确定目标数据表包括的字段个数后,计算目标操作语句对应的数据表内容包括的数据量与字段个数之间的商,即可得到目标数据量。In the embodiment of the present application, the first storage node determines the amount of data included in the content of the data table corresponding to the target operation statement, and after determining the number of fields included in the target data table, calculates the difference between the amount of data included in the content of the data table corresponding to the target operation statement and The quotient between the number of fields can get the target data volume.
对应的,步骤203可以由步骤203d来实现:Correspondingly, step 203 can be realized by step 203d:
步骤203d、基于目标数据量和每一数据同步方式,发送目标操作语句至对应的第二存储节点。 Step 203d, based on the target data amount and each data synchronization mode, send the target operation statement to the corresponding second storage node.
在本申请实施例中,第二存储节点的默认数据同步方式可以为实时同步方式。在不同的数据同步方式下,根据目标数据量的不同,可以采用不同的预处理方式对目标操作语句进行预处理,以提高数据同步方法的实现效率,提高目标操作语句发送至对应的第二存储节点的发送效率。In this embodiment of the present application, the default data synchronization mode of the second storage node may be a real-time synchronization mode. In different data synchronization methods, depending on the amount of target data, different preprocessing methods can be used to preprocess the target operation statement to improve the implementation efficiency of the data synchronization method and improve the ability of the target operation statement to be sent to the corresponding second storage. Node sending efficiency.
基于前述实施例,在本申请其他实施例中,步骤203d可以由步骤a11~a13来实现:Based on the foregoing embodiments, in other embodiments of the present application, step 203d may be implemented by steps a11-a13:
步骤a11、若每一数据同步方式为实时同步方式,且目标数据量小于预设阈值,确定目标数据表对应的建表语句。Step a11, if each data synchronization method is a real-time synchronization method, and the target data volume is less than a preset threshold, determine a table creation statement corresponding to the target data table.
在本申请实施例中,预设阈值可以是根据大量实验得到的经验值,也可以是用户根据实际需求进行设置得到的经验值,在使用过程中,预设阈值还可以根据目标操作语句的响应时长进行动态调整。预设阈值对数据同步方法的实现过程的性能不造成影响。In this embodiment of the application, the preset threshold can be an empirical value obtained from a large number of experiments, or an empirical value set by the user according to actual needs. During use, the preset threshold can also be based on the response of the target operation statement The duration is dynamically adjusted. The preset threshold has no impact on the performance of the implementation process of the data synchronization method.
步骤a12、基于建表语句和目标操作语句,生成第二请求报文。Step a12, generating a second request message based on the table creation statement and the target operation statement.
步骤a13、通过实时同步方式发送第二请求报文至对应的第二存储节点。Step a13, sending the second request message to the corresponding second storage node in a real-time synchronous manner.
其中,第二请求报文包括目标操作语句,第二请求报文中包括的建表语句用于在第二存储节点接收到第二请求报文后,检测到目标数据表不存在时,生成目标数据表。Wherein, the second request message includes the target operation statement, and the table creation statement included in the second request message is used to generate the target data table when the second storage node detects that the target data table does not exist after receiving the second request message. data sheet.
这样,在第二存储节点对应的数据同步方式为实时同步方式的情况下,若目标操作语句的目标数据量小于预设阈值,直接将目标操作语句和建表语句生成第二请求报文。In this way, when the data synchronization mode corresponding to the second storage node is the real-time synchronization mode, if the target data volume of the target operation statement is less than the preset threshold, the target operation statement and the table creation statement are directly generated into the second request message.
基于前述实施例,在本申请其他实施例中,步骤203a或步骤a11中的步骤“确定目标数据表对应的建表语句”可以通过步骤b11~b17来实现:Based on the foregoing embodiments, in other embodiments of the present application, the step "determine the table creation statement corresponding to the target data table" in step 203a or step a11 can be realized through steps b11-b17:
步骤b11、确定目标操作语句对应的调用信息。Step b11, determining the call information corresponding to the target operation statement.
在本申请实施例中,调用信息为数据服务层响应目标操作语句的数据信息。In this embodiment of the application, the call information is the data information of the data service layer responding to the target operation statement.
步骤b12、从调用信息中,确定用于定义目标数据表的结构的参考字段信息。Step b12, from the call information, determine the reference field information used to define the structure of the target data table.
在本申请实施例中,从调用信息中,确定对应的节点配置信息,从节点配置信息中可以解析得到目标数据表的结构对应的参考字段信息。In the embodiment of the present application, the corresponding node configuration information is determined from the call information, and the reference field information corresponding to the structure of the target data table can be obtained by parsing the node configuration information.
步骤b13、采用目标字符替换参考字段信息中的参考字符,得到目标字段信息。Step b13, replacing the reference character in the reference field information with the target character to obtain the target field information.
在本申请实施例中,目标字符例如可以是SQL语句中的“*%*”和空白字符“”, 对应的参考字符为“?”和“[\\s]+”,这样,替换处理后得到目标字段信息。In this embodiment of the application, the target character can be, for example, "*%*" and the blank character "" in the SQL statement, and the corresponding reference characters are "?" and "[\\s]+". In this way, after the replacement process Get the target field information.
其中,第一存储节点执行步骤b13之后,可以选择执行步骤b14~b16,或步骤b17,其中,若目标字段信息包括表字段实体信息,选择执行步骤b14~b16,若目标字段信息不包括表字段实体信息,选择执行步骤b17。Wherein, after the first storage node executes step b13, it can choose to execute steps b14~b16, or step b17, wherein, if the target field information includes table field entity information, choose to execute steps b14~b16, if the target field information does not include table fields Entity information, choose to execute step b17.
步骤b14、若目标字段信息包括表字段实体信息,遍历目标字段信息,得到目标字段名。Step b14, if the target field information includes table field entity information, traverse the target field information to obtain the target field name.
步骤b15、获取目标字段名对应的参考字段类型。Step b15, obtaining the reference field type corresponding to the target field name.
在本申请实施例中,根据目标字段名,从表字段实体信息中获取对应的参考字段类型。In this embodiment of the application, according to the target field name, the corresponding reference field type is obtained from the table field entity information.
步骤b16、采用目标语句规则对参考字段类型进行处理,得到建表语句。Step b16, using the target statement rule to process the reference field type to obtain a table creation statement.
在本申请实施例中,目标语句规则为SQL语句格式要求,例如若字段为字符串类型,给字段添加单引号("),若字段为日期类型,将字段转换为目标数据表中存储的日期格式并添加单引号("),若字段为超过16位有效大数,通过大数自带的转化字符串方法将字段转为字符串类型并添加单引号("),这样,可以得到建表语句。In the embodiment of this application, the target statement rule is the SQL statement format requirement, for example, if the field is a string type, add single quotes (") to the field, if the field is a date type, convert the field to the date stored in the target data table Format and add single quotes ("). If the field is a valid large number with more than 16 digits, use the conversion string method that comes with the large number to convert the field to a string type and add single quotes ("). In this way, you can get the table statement.
步骤b17、若目标字段信息不包括表字段实体信息,从目标字段存储区域获取目标操作语句对应的语句,得到建表语句。Step b17, if the target field information does not include the table field entity information, obtain the statement corresponding to the target operation statement from the target field storage area to obtain the table creation statement.
在本申请实施例中,目标字段存储区域例如可以是JavaBean。In this embodiment of the application, the target field storage area may be, for example, JavaBean.
基于前述实施例,在本申请其他实施例中,参照图3所示,第一存储节点执行步骤204之后,还用于执行步骤205:Based on the foregoing embodiments, in other embodiments of the present application, referring to FIG. 3 , after the first storage node performs step 204, it is also used to perform step 205:
步骤205、若每一数据同步方式为实时同步方式,且目标数据量大于或等于预设阈值,更新对应的数据同步方式为异步同步方式。 Step 205. If each data synchronization method is a real-time synchronization method, and the target data volume is greater than or equal to a preset threshold, update the corresponding data synchronization method to an asynchronous synchronization method.
在本申请实施例中,在第二存储节点的数据同步方式为实时同步方式的情况下,若目标数据量大于或等于预设阈值时,若直接通过实时同步方式将目标操作语句发送至第二存储节点,会严重影响第二存储节点的运行性能,因此,将第二存储节点的数据同步方式调整更新为异步同步方式。In this embodiment of the application, when the data synchronization mode of the second storage node is real-time synchronization mode, if the target data volume is greater than or equal to the preset threshold, if the target operation statement is directly sent to the second The storage node will seriously affect the operation performance of the second storage node. Therefore, the data synchronization mode of the second storage node is adjusted and updated to an asynchronous synchronization mode.
基于前述实施例,在本申请其他实施例中,步骤203或步骤203d还可以由步骤c11~c16来实现:Based on the foregoing embodiments, in other embodiments of the present application, step 203 or step 203d can also be implemented by steps c11-c16:
步骤c11、若每一数据同步方式为异步同步方式,且目标数据量大于或等于预设阈值,基于目标操作语句,生成目标操作文件。Step c11. If each data synchronization method is an asynchronous synchronization method, and the target data volume is greater than or equal to a preset threshold, generate a target operation file based on the target operation statement.
在本申请实施例中,在第二存储节点的数据同步方式为异步同步方式的情况下,若目标数据量大于或等于预设阈值,创建一个文件,并将目标操作语句放入创建的文件中,得到目标操作文件。其中,该文件可以采用目标数据表的标识信息进行命名,进一步的,由于对目标数据表的更新操作可能是持续的,为了区分不同时间段对应的目标操作语句,采用除目标数据表的标识信息对文件进行命名外,还可以包括当前时间以及随机生成的编号,即采用目标数据表的标识信息、当前时间以及随机生成的编号对存储有目标操作语句的文件进行命名,得到目标操作文件。In this embodiment of the application, when the data synchronization method of the second storage node is asynchronous synchronization method, if the target data volume is greater than or equal to the preset threshold, create a file and put the target operation statement into the created file , to get the target operation file. Wherein, the file can be named using the identification information of the target data table. Further, since the update operation of the target data table may be continuous, in order to distinguish the target operation statements corresponding to different time periods, the identification information of the target data table is used In addition to naming the file, it can also include the current time and a randomly generated number, that is, use the identification information of the target data table, the current time, and the randomly generated number to name the file storing the target operation statement to obtain the target operation file.
若每一数据同步方式为异步同步方式,且目标数据量小于预设阈值时,采用异步同步方式,直接将目标操作语句发送至对应的第二存储节点。示例性的,在第二存储节点的数据同步方式为异步同步方式的情况下,若目标操作语句的目标数据量小于预设阈值,第一存储节点每隔预设异步时间周期,发送目标操作语句至第二存储节点,以使第二存储节点执行目标操作语句,实现针对目标数据表与第一存储节点中的目标数据表的同步更新操作。If each data synchronization method is an asynchronous synchronization method and the target data volume is less than a preset threshold, the asynchronous synchronization method is used to directly send the target operation statement to the corresponding second storage node. Exemplarily, when the data synchronization method of the second storage node is an asynchronous synchronization method, if the target data volume of the target operation statement is less than the preset threshold, the first storage node sends the target operation statement every preset asynchronous time period to the second storage node, so that the second storage node executes the target operation statement, and implements a synchronous update operation on the target data table and the target data table in the first storage node.
步骤c12、发送目标操作文件至文件服务器。Step c12, sending the target operation file to the file server.
在本申请实施例中,文件服务器是第一存储节点和至少一个第二存储节点之间的一个用于存储文件的服务器。In this embodiment of the present application, the file server is a server between the first storage node and at least one second storage node for storing files.
步骤c13、接收文件服务器发送的用于指示目标操作文件存储位置的指示信息。Step c13, receiving indication information sent by the file server for indicating the storage location of the target operation file.
在本申请实施例中,指示信息可以是文件服务器接收到目标操作文件后,生成的用于标识目标操作文件的存储文件的身份标识信息(Identity Document,ID)和对应的哈希值(Hash)。对应的,生成的用于标识目标操作文件的存储文件的ID和对应的Hash可以是通过上传的帧率(Frames Per Second,FPS)确定得到的。In the embodiment of the present application, the indication information may be the identity information (Identity Document, ID) and the corresponding hash value (Hash) generated by the file server to identify the storage file of the target operation file after receiving the target operation file . Correspondingly, the ID of the generated storage file used to identify the target operation file and the corresponding Hash can be obtained by determining the uploaded frame rate (Frames Per Second, FPS).
步骤c14、存储指示信息。Step c14, storing the indication information.
步骤c15、按照预设异步时间周期,生成获取指令。Step c15, generating an acquisition instruction according to a preset asynchronous time period.
其中,获取指令用于指示从文件服务器的指示信息处获取目标操作文件,得到目标操作语句以执行对应的更新操作。Wherein, the obtaining instruction is used to instruct to obtain the target operation file from the instruction information of the file server, and obtain the target operation statement to execute the corresponding update operation.
在本申请实施例中,预设异步时间周期可以是根据实际情况设定的一个时间周期经验值,也可以是根据大量实验得到的时间经验值。预设异步时间周期例如可以是每隔5分钟、每隔30分钟或每天6:00等。In the embodiment of the present application, the preset asynchronous time period may be an empirical value of a time period set according to actual conditions, or may be an empirical value of time obtained from a large number of experiments. The preset asynchronous time period may be, for example, every 5 minutes, every 30 minutes, or 6:00 every day.
步骤c16、发送获取指令至对应的第二存储节点。Step c16, sending an acquisition instruction to the corresponding second storage node.
在本申请实施例中,第一存储节点每隔预设异步时间周期,生成获取指令后就立即发送获取指令至对应的第二存储节点,以使第二存储节点从文件服务器中获取指示信息所指示的存储位置处的目标操作文件,以便第二存储节点执行目标操作文件中对应的目标操作语句。In this embodiment of the application, the first storage node sends the acquisition instruction to the corresponding second storage node immediately after generating the acquisition instruction every preset asynchronous time period, so that the second storage node acquires the instruction information from the file server. The target operation file at the indicated storage location, so that the second storage node executes the corresponding target operation statement in the target operation file.
在一些应用场景中,第一存储节点接收到指示信息后,生成获取指令,每隔预设异步时间周期才发送获取指令至对应的第二存储节点,实现第一存储节点与至少一个第二存储节点之间针对目标数据表的异步同步方式。In some application scenarios, after the first storage node receives the indication information, it generates an acquisition instruction, and sends the acquisition instruction to the corresponding second storage node every preset asynchronous time period, realizing the first storage node and at least one second storage node. The asynchronous synchronization method for the target data table between nodes.
需说明的是,步骤c11~c16也可以在步骤205之后执行,即在第二存储节点对应的数据同步方式从实时同步方式更新为异步同步方式后,继续选择执行步骤c11~c16。It should be noted that steps c11-c16 may also be executed after step 205, that is, after the data synchronization mode corresponding to the second storage node is updated from real-time synchronization mode to asynchronous synchronization mode, continue to select and execute steps c11-c16.
基于前述实施例,在本申请其他实施例中,参照图4所示,第一存储节点执行步骤203之后,还用于执行步骤206~207:Based on the foregoing embodiments, in other embodiments of the present application, as shown in FIG. 4 , after the first storage node performs step 203, it is also used to perform steps 206-207:
步骤206、接收对应的第二存储节点发送的更新结果。Step 206: Receive the update result sent by the corresponding second storage node.
其中,更新结果为第二存储节点执行目标操作语句的操作结果。Wherein, the update result is an operation result of executing the target operation statement by the second storage node.
在本申请实施例中,更新结果可以是第二存储节点采用响应报文的形式发送至第一存储节点的。In this embodiment of the present application, the update result may be sent by the second storage node to the first storage node in the form of a response message.
在数据同步方式为实时同步方式的情况下,第二存储节点接收到第二请求报文后,对第二请求报文进行解析,得到目标操作语句和建表语句;根据目标操作语句,判断第二存储节点中是否具有目标操作语句中对应的目标数据表;若第二存储节点中不存在目标数据表,第二存储节点执行解析得到的建表语句,创建得到对应的目标数据表,然后针对目标数据表执行目标操作语句,得到操作结果,即更新结果;若第二存储节点中存在目标数据表,第二存储节点判断存在的目标数据表中的字段信息否与建表语句中的字段信息一致,其中,字段信息至少包括字段名称、字段类型和字段长度等信息内容;若目标数据表中的字段信息与建表语句中的字段信息一致,第二存储节点将目标数据表进行缓存后,针对目标数据表执行目标操作语句,更新目标数据表中的内容,得到更新结果,其中,在针对目标数据表执行目标操作语句前进行缓存的目的是其他第二存储节点出现目标操作语句执行异常的情况时,可以利用缓存的目标数据表来实现回滚操作;若目标数据表中的字段信息与建表语句中的字段信息不一致,第二存储节点获取第二存储节点中的目标数据表的建表语句,第二存储节点基于第二存储节点中的目标数据表的建表语句和目标操作语句执行失败,得到更新结果。When the data synchronization mode is the real-time synchronization mode, after the second storage node receives the second request message, it analyzes the second request message to obtain the target operation statement and the table creation statement; Whether there is a target data table corresponding to the target operation statement in the second storage node; if the target data table does not exist in the second storage node, the second storage node executes the parsed table creation statement to create the corresponding target data table, and then The target data table executes the target operation statement to obtain the operation result, that is, the update result; if the target data table exists in the second storage node, the second storage node judges whether the field information in the existing target data table is consistent with the field information in the table creation statement Consistent, where the field information includes at least field name, field type and field length and other information content; if the field information in the target data table is consistent with the field information in the table creation statement, after the second storage node caches the target data table, Execute the target operation statement for the target data table, update the content in the target data table, and obtain the update result, wherein the purpose of caching before executing the target operation statement for the target data table is that other second storage nodes have abnormal execution of the target operation statement In some cases, the cached target data table can be used to implement the rollback operation; if the field information in the target data table is inconsistent with the field information in the table creation statement, the second storage node obtains the target data table in the second storage node. For the table statement, the second storage node fails to execute the table creation statement and the target operation statement based on the target data table in the second storage node, and obtains an update result.
在数据同步方式为异步同步方式的情况下,若第二存储节点每个预设异步时间周期接收到的是目标操作语句后,第二存储节点对目标操作语句的执行过程与实时同步方式的情况下第二存储节点对目标操作语句的执行过程一致,此处不做具体限定。When the data synchronization method is asynchronous synchronization method, if the second storage node receives the target operation statement every preset asynchronous time period, the execution process of the target operation statement by the second storage node is the same as that of the real-time synchronization method The execution process of the target operation statement by the second storage node is the same, which is not specifically limited here.
在数据同步方式为异步同步方式的情况下,若第二存储节点每隔预设异步时间周期接收到的是目标操作文件时,第二存储节点对目标操作文件进行解析,从目标操作文件中按照目标操作语句的时间顺序,每次依次获取预设数量条操作语句进行执行,对应的执行过程与实时同步方式的情况下第二存储节点对目标操作语句的执行过程一致,此处不做具体限定。When the data synchronization method is asynchronous synchronization method, if the second storage node receives the target operation file every preset asynchronous time period, the second storage node analyzes the target operation file, and obtains the target operation file according to The chronological order of the target operation statements, each time a preset number of operation statements are obtained sequentially for execution, the corresponding execution process is consistent with the execution process of the second storage node for the target operation statements in the case of real-time synchronization, and no specific limitation is made here .
步骤207、基于更新结果,更新对应的第二存储节点的数据同步方式。 Step 207, based on the update result, update the data synchronization mode of the corresponding second storage node.
在本申请实施例中,在不同的数据同步方式下,不同的更新结果,对应的更新对应的第二存储节点的数据同步方式的更新方式不同。In the embodiment of the present application, under different data synchronization modes and different update results, the corresponding update modes of the data synchronization mode of the corresponding second storage node are different.
基于前述实施例,在本申请其他实施例中,步骤207可以由步骤207a或步骤207b来实现:Based on the foregoing embodiments, in other embodiments of the present application, step 207 may be implemented by step 207a or step 207b:
步骤207a、在数据同步方式为实时同步方式的情况下,若更新结果表示第二存储节点执行目标操作语句异常,更新数据同步方式为异步同步方式。Step 207a, if the data synchronization mode is the real-time synchronization mode, if the update result indicates that the execution of the target operation statement by the second storage node is abnormal, update the data synchronization mode to the asynchronous synchronization mode.
在本申请实施例中,在数据同步方式为实时同步方式的情况下,若更新结果表示第二存储节点执行目标操作语句成功,无需更新对应的第二存储节点的数据同步方式,继续保持对应的第二存储节点的数据同步方式为实时同步方式。In this embodiment of the application, when the data synchronization mode is real-time synchronization mode, if the update result indicates that the second storage node successfully executes the target operation statement, there is no need to update the data synchronization mode of the corresponding second storage node, and the corresponding The data synchronization mode of the second storage node is a real-time synchronization mode.
步骤207b、在数据同步方式为异步同步方式的情况下,若更新结果表示第二存储节点执行目标操作语句成功,更新数据同步方式为实时同步方式。Step 207b. If the data synchronization mode is an asynchronous synchronization mode, if the update result indicates that the second storage node executes the target operation statement successfully, update the data synchronization mode to a real-time synchronization mode.
在本申请实施例中,在数据同步方式为异步同步方式的情况下,若更新结果表示第二存储节点执行目标操作语句失败,不更新数据同步方式,继续保持对应的第二存储节点的数据同步方式为异步同步方式。In this embodiment of the application, when the data synchronization method is asynchronous synchronization method, if the update result indicates that the second storage node fails to execute the target operation statement, the data synchronization method will not be updated, and the data synchronization of the corresponding second storage node will continue to be maintained The method is asynchronous and synchronous.
基于前述实施例,在本申请其他实施例中,参照图5所示,第一存储节点执行步骤206之后,还用于执行步骤208~209:Based on the foregoing embodiments, in other embodiments of the present application, referring to FIG. 5 , after the first storage node performs step 206, it is also used to perform steps 208-209:
步骤208、若更新结果表示第二存储节点执行目标操作语句异常,确定更新结果对应的异常优先级。Step 208: If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, determine an exception priority corresponding to the update result.
在本申请实施例中,在更新结果表示第二存储节点执行目标操作语句成功的情况下,本次同步过程结束。在更新结果表示第二存储节点执行目标操作语句异常的情况下,根据更新结果内容,确定更新结果对应的异常优先级。In the embodiment of the present application, when the update result indicates that the second storage node successfully executes the target operation statement, the current synchronization process ends. If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, an exception priority corresponding to the update result is determined according to the content of the update result.
步骤209、执行异常优先级对应的告警操作。 Step 209, perform an alarm operation corresponding to the abnormal priority.
在本申请实施例中,异常优先级假设包括表示级别从高到低分别表示为:一级、二级、……、n级。假设异常优先级总共包括三级时,一级表示最高级优先级,对应的,告警操作例如可以是与相关负责人的通信设备建立语音通信连接,提醒及时处理该异常情况,二级表示次高级优先级,对应的告警操作例如可以是与相关负责人的通信设备建立通信连接,通过发送提示信息的形式提醒相关负责人有空的时候处理该异常情况,三标表示最低级优先级,对应的告警操作例如可以是生成提示信息,并记录,以便相关负责人查阅。In the embodiment of the present application, the exception priority assumption includes indicating levels from high to low as: first level, second level, . . . , n level. Assuming that the abnormal priority includes three levels in total, the first level represents the highest priority. Correspondingly, the alarm operation can be, for example, establishing a voice communication connection with the communication device of the relevant person in charge, reminding to deal with the abnormal situation in time, and the second level represents the second highest level. Priority, the corresponding alarm operation can be, for example, to establish a communication connection with the communication device of the relevant person in charge, and remind the relevant person in charge to deal with the abnormal situation when he is free by sending a prompt message. The three marks indicate the lowest priority, and the corresponding The alarm operation may be, for example, generating prompt information and recording it for reference by relevant persons in charge.
基于前述实施例,在本申请其他实施例中,参照图6所示,第一存储节点执行步骤206之后,还用于执行步骤210~211:Based on the foregoing embodiments, in other embodiments of the present application, as shown in FIG. 6 , after the first storage node performs step 206, it is also used to perform steps 210-211:
步骤210、若更新结果表示第二存储节点执行目标操作语句异常,从至少一个第二存储节点中,确定更新结果表示第二存储节点执行目标操作语句成功的第二存储节点,得到至少一个第三存储节点。 Step 210, if the update result indicates that the second storage node executes the target operation statement abnormally, determine the second storage node whose update result indicates that the second storage node successfully executes the target operation statement from at least one second storage node, and obtain at least one third Storage nodes.
在本申请实施例中,在更新结果表示第二存储节点执行目标操作语句异常的情况下,表示对第二存储节点的同步操作未执行成功,因此,针对目标数据表的此次同步不成功,此时,从与目标数据表具有关联关系的至少一个第二存储节点中,确定出更新结果表示执行目标操作语句成功的第二存储节点,得到至少一个第三存储节点。In the embodiment of the present application, when the update result indicates that the execution of the target operation statement by the second storage node is abnormal, it means that the synchronization operation on the second storage node has not been successfully executed. Therefore, the synchronization of the target data table is not successful. At this time, from at least one second storage node associated with the target data table, determine the second storage node whose update result indicates that the target operation statement is executed successfully, and obtain at least one third storage node.
步骤211、发送数据回滚控制指令至至少一个第三存储节点。 Step 211, sending a data rollback control instruction to at least one third storage node.
其中,数据回滚控制指令用于指示第三存储节点回滚至执行目标操作语句前的数据。Wherein, the data rollback control instruction is used to instruct the third storage node to roll back to the data before executing the target operation statement.
在本申请实施例中,第一存储节点将数据回滚指令发送至至少一个第三存储节点,以使至少一个第三存储节点响应数据回滚指令,采用执行目标操作语句前缓存的目标数据表替换执行目标操作语句后的目标数据表,实现数据回滚操作。In the embodiment of the present application, the first storage node sends the data rollback instruction to at least one third storage node, so that at least one third storage node responds to the data rollback instruction and adopts the target data table cached before executing the target operation statement Replace the target data table after executing the target operation statement to realize the data rollback operation.
基于前述实施例,在本申请其他实施例中,参照图7所示,第一存储节点执行步骤206之后,还用于执行步骤212~213:Based on the foregoing embodiments, in other embodiments of the present application, as shown in FIG. 7 , after the first storage node performs step 206, it is also used to perform steps 212-213:
步骤212、在每一第二存储节点发送的更新结果表示第二存储节点执行目标操作语句成功的情况下,统计每一第二存储节点的数据处理消耗时长,得到至少一个数据处理消耗时长。Step 212 : When the update result sent by each second storage node indicates that the second storage node successfully executes the target operation statement, count the data processing consumption time of each second storage node to obtain at least one data processing consumption time.
步骤213、基于至少一个数据处理消耗时长,更新预设阈值。 Step 213, based on at least one data processing consumption time, update the preset threshold.
在本申请实施例中,第一存储节点对至少一个数据处理消耗时长进行分析,确定当前预设阈值是否合理,若不合理,根据指示一个处理消耗时长进行分析,确定新的阈值来更新预设阈值,若合理,则无需更新预设阈值。在一些应用场景下,得到至少一个数据处理消耗时长后,也可以将至少一个数据处理消耗时长发送给相关负责人,以便相关负责人对至少一个数据处理消耗时长进行分析,对预设阈值进行重新设置。In the embodiment of the present application, the first storage node analyzes at least one data processing consumption time to determine whether the current preset threshold is reasonable, and if not, analyzes according to a processing consumption time indicated to determine a new threshold to update the preset Threshold, if reasonable, there is no need to update the preset threshold. In some application scenarios, after obtaining at least one data processing consumption time, you can also send at least one data processing consumption time to the relevant person in charge, so that the relevant person in charge can analyze at least one data processing consumption time and reset the preset threshold. set up.
基于前述实施例,在本申请其他实施例中,步骤201可以由步骤201a~201d来实现:Based on the foregoing embodiments, in other embodiments of the present application, step 201 may be implemented by steps 201a-201d:
步骤201a、获取数据服务层中的映射器声明参数和参数类型参数。Step 201a, obtaining mapper declaration parameters and parameter type parameters in the data service layer.
步骤201b、采用目标语句规则对映射器声明参数和参数类型参数进行处理,得到参考操作语句。Step 201b: Process the mapper declaration parameters and parameter type parameters by using the target statement rules to obtain a reference operation statement.
在本申请实施例中,采用目标语句规则即SQL语句规则对映射器声明参数和参数类型参数进行解析处理,并对解析后得到的内容进行拼接,即可得到SQL语句。In the embodiment of the present application, the target statement rule, that is, the SQL statement rule, is used to analyze the mapper declaration parameters and parameter type parameters, and splicing the parsed content to obtain the SQL statement.
步骤201c、若参考操作语句的操作类型为目标操作类型,确定目标操作语句为参考操作语句。Step 201c, if the operation type of the reference operation statement is the target operation type, determine the target operation statement as the reference operation statement.
在本申请实施例中,对参考操作语句进行分析,若确定参考操作语句为目标操作类型,即为Insert、Delete或Update时,将参考操作语句确定为目标操作语句。In the embodiment of the present application, the reference operation statement is analyzed, and if it is determined that the reference operation statement is the target operation type, that is, Insert, Delete or Update, the reference operation statement is determined as the target operation statement.
步骤201d、确定与目标数据表具有关联关系的至少一个第二存储节点。Step 201d, determining at least one second storage node that has an association relationship with the target data table.
基于前述实施例,本申请实施例提供一种数据同步系统的结构示意图,参照图8所示,包括:主操作库系统、目标备库系统1、目标备库系统2和目标备库系统3。其中,主操作库系统、目标备库系统1、目标备库系统2和目标备库系统3中均包括:业务逻辑应用层、数据服务层、拦截器和主操作数据库(Database,DB)。其中,拦截器包括:数据同步模块、同步结果处理模块、数据下发异常监控和反馈处理模块、和阈值设定模块。需说明的是,图8中仅完整示意出主操作系统库的结构组成,目标备库系统1、目标备库系统2和目标备库系统3的结构组成与主操作系统库的结构组成相同,且主操作库系统与前述第一存储节点对应,目标备库系统1、目标备库系统2和目标备库系统3与前述至少一个第二存储节点对应,第一存储节点和第二存储节点之间角色功能可以相互替换。Based on the aforementioned embodiments, this embodiment of the present application provides a schematic structural diagram of a data synchronization system, as shown in FIG. Among them, the main operation database system, the target standby database system 1, the target standby database system 2 and the target standby database system 3 all include: a business logic application layer, a data service layer, an interceptor and a main operation database (Database, DB). Among them, the interceptor includes: a data synchronization module, a synchronization result processing module, a data delivery exception monitoring and feedback processing module, and a threshold setting module. It should be noted that in FIG. 8 only the structural composition of the main operating system library is completely shown, and the structural composition of the target standby database system 1, the target standby database system 2, and the target standby database system 3 is the same as that of the main operating system library. And the main operation library system corresponds to the aforementioned first storage node, the target backup library system 1, the target backup library system 2 and the target backup library system 3 correspond to the aforementioned at least one second storage node, and the first storage node and the second storage node The functions of the roles can be replaced with each other.
基于图8所示的数据同步系统的结构示意图,本申请实施例提供一种数据同步方法,具体实现过程如下所示:Based on the schematic structural diagram of the data synchronization system shown in FIG. 8, the embodiment of the present application provides a data synchronization method, and the specific implementation process is as follows:
主操作库系统的业务逻辑层接收到用户发送的用于请求对主操作数据库中的目标数据表进行更新操作的操作请求后,业务逻辑层将操作请求发送至数据服务层,数据服务层中对应的数据操作语句对操作请求进行响应,实现对目标数据表的操作。主操作库系统中的拦截器对数据服务层中对应的数据操作语句进行拦截,对拦截到的数据操作语句进行分析,确定得到针对目标数据表的属于目标操作类型例如Insert类型、Delete类型和Update类型等的目标操作语句。主操作库系统中的拦截器确定得到目标操作语句后,确定与目标数据表具有关联关系的至少一个第二存储节点为目标备库系统1、目标备库系统2和目标备库系统3,并确定目标备库系统1、目标备库系统2和目标备库系统3对应的数据同步方式,采用目标备库系统1、目标备库系统2和目标备库系统3各自对应的数据同步方式将目标操作语句实现同步过程,并接收目标备库系统1、目标备库系统2和目标备库系统3发送的更新结果。主操作库系统还可以根据目标备库系统1、目标备库系统2和目标备库系统3发送的更新结果对目标备库系统1、目标备库系统2和目标备库系统3的数据同步方式进行更新,并调整预设阈值等,如此实现一个完整的闭环反馈系统,保证了有效的同步策略。After the business logic layer of the main operation database system receives the operation request sent by the user for updating the target data table in the main operation database, the business logic layer sends the operation request to the data service layer, and the corresponding The data operation statement responds to the operation request and realizes the operation on the target data table. The interceptor in the main operation library system intercepts the corresponding data operation statement in the data service layer, analyzes the intercepted data operation statement, and determines the target operation type for the target data table, such as Insert type, Delete type and Update Target action statement of type etc. After the interceptor in the main operation library system determines that the target operation statement is obtained, at least one second storage node that has an association relationship with the target data table is determined as the target standby database system 1, the target standby database system 2, and the target standby database system 3, and Determine the data synchronization methods corresponding to target backup system 1, target backup system 2, and target backup system 3, and use the data synchronization methods corresponding to target backup system 1, target backup system 2, and target backup system 3 to synchronize the target The operation statement implements the synchronization process, and receives the update results sent by the target standby database system 1, the target standby database system 2, and the target standby database system 3. The main operating database system can also synchronize the data of the target standby database system 1, the target standby database system 2 and the target standby database system 3 according to the update results sent by the target standby database system 1, the target standby database system 2 and the target standby database system 3 Update and adjust preset thresholds, etc., so as to realize a complete closed-loop feedback system and ensure an effective synchronization strategy.
确定与目标数据表具有关联关系的至少一个第二存储节点,可以从预先存储的数据表与存储节点之间的关系中确定得到。预先存储的数据表与存储节点之间的关系可以从对应的框架脚本包括的注解中确定得到,示例性的,可以从Spring框架的面向切面编程(Aspect Oriented Programming,AOP)包括的注解确定得到,注解中标识有对应的数据表需要下发且指定下发的目标备库系统。预先存储的数据表与存储节点之间的关系例如可以采用列表的形式进行表示,如表1所示,DcnRouter为目标数据表的标识信息,SysName为具有目标数据表的系统的系统名称信息,DcnNo为具有目标数据表的系统的系统编号信息,ServiceId为具有目标数据表的系统之间进行信息发送时对应的映射关系。Determining at least one second storage node that has an association relationship with the target data table may be determined from a pre-stored relationship between the data table and the storage node. The relationship between the pre-stored data table and the storage node can be determined from the annotations included in the corresponding framework script, for example, it can be determined from the annotations included in the Spring framework's aspect-oriented programming (Aspect Oriented Programming, AOP), The comment identifies the corresponding data table that needs to be delivered and specifies the target backup system for delivery. The relationship between the pre-stored data table and the storage node can be expressed in the form of a list, for example, as shown in Table 1, DcnRouter is the identification information of the target data table, SysName is the system name information of the system with the target data table, DcnNo is the system number information of the system with the target data table, and ServiceId is the corresponding mapping relationship when information is sent between the systems with the target data table.
表1Table 1
Figure PCTCN2022120536-appb-000001
Figure PCTCN2022120536-appb-000001
主操作库系统中的拦截器例如可以是持久层框架例如MyBatis提供的插件 (plugin)功能。主操作库系统和目标备库系统之间可以采用远程调用方式来实现。The interceptor in the main operating library system can be, for example, a plugin function provided by a persistence layer framework such as MyBatis. Remote call can be used between the main operating library system and the target standby library system.
拦截器获取目标操作语句的过程例如可以是:拦截器获取数据服务层响应操作请求的数据操作语句中的参数,从参数中解析出映射器(mapper)声明(MappedStatement)中包括的命令类型例如SqlCommandTypeSql。根据命令类型例如SqlCommandTypeSql确定得到Insert类型、Delete类型和Update类型等的目标操作语句。The process for the interceptor to obtain the target operation statement can be, for example: the interceptor obtains the parameters in the data operation statement of the data service layer in response to the operation request, and parses out the command type included in the mapper (mapper) statement (MappedStatement) such as SqlCommandTypeSql from the parameters . According to the command type such as SqlCommandTypeSql, the target operation statement of Insert type, Delete type and Update type is determined.
确定与目标数据表具有关联关系的至少一个第二存储节点,还可以是拦截器根据拦截到的映射语句标识例如MappedStatementId获取到类名,根据类名映射出类对象信息,根据类对象信息判断该类是否有添加注解以及注解的参数,若添加有注解以及注解的参数,可以确定得到与目标数据表具有关联关系的至少一个第二存储节点。Determining at least one second storage node that has an association relationship with the target data table can also be that the interceptor obtains the class name according to the intercepted mapping statement identifier such as MappedStatementId, maps the class object information according to the class name, and judges the class object information according to the class object information. Whether there are annotations and annotation parameters added to the class, if annotations and annotation parameters are added, it can be determined to obtain at least one second storage node that has an association relationship with the target data table.
拦截器根据命令类型例如SqlCommandTypeSql确定得到Insert类型、Delete类型和Update类型等的目标操作语句的具体过程可以为:拦截器对数据服务层中的MappedStatement和参数类型(ParamObject)获取boundSQL。根据MappedStatement和ParamObject这两个参数进行解析,并拼接成可直接执行的目标操作类型的SQL语句,得到目标操作语句。进一步的,根据boundSQL的参数列表中的数据量除以表结构的字段个数,得到SQL语句中所需要执行的目标数据量。The specific process for the interceptor to determine the target operation statements of the Insert type, Delete type, and Update type according to the command type such as SqlCommandTypeSql can be: the interceptor obtains boundSQL for the MappedStatement and parameter type (ParamObject) in the data service layer. According to the two parameters of MappedStatement and ParamObject, it is parsed and spliced into SQL statements of the target operation type that can be directly executed to obtain the target operation statement. Further, according to the amount of data in the parameter list of boundSQL divided by the number of fields in the table structure, the target data amount to be executed in the SQL statement is obtained.
拦截器解析数据服务层响应操作请求的数据操作语句中的节点配置信息,由于节点配置信息包括定义该目标数据表结构的每个字段信息,因此可以对节点配置信息中的每个字段信息进行遍历,并拼接出该目标数据表的建表语句。具体实现过程可以为:替换节点配置信息中的所有占位符"?"为"*%*",替换所有空白字符"[\\s]+"为"",得到替换后的节点配置信息;判断替换后的节点配置信息中是否使用表字段实体类作为参数;若替换后的节点配置信息中使用表字段实体类作为参数,依次循环参数列表,确定得到属于用户传入的参数集合和属于参数映射关系集合;从属于用户传入的参数集合和属于参数映射关系集合中获取字段名和字段类型;根据获取到的字段名从对应的集合中获取字段类型,具体实现过程为:若字段为字符串类型,给字段添加单引号("),若字段为日期类型,将字段转换为目标数据表中存储的日期格式并添加单引号("),若字段为超过16位有效大数,通过大数自带的转化字符串方法将字段转为字符串类型并添加单引号("),即可得到建表语句;若替换后的节点配置信息中未使用表字段实体类作为参数,从JavaBean中获取实体类批量参数,即可得到建表语句。其中,建表语句也为SQL语句。The interceptor parses the node configuration information in the data operation statement that the data service layer responds to the operation request. Since the node configuration information includes each field information that defines the structure of the target data table, each field information in the node configuration information can be traversed , and splicing out the table creation statement of the target data table. The specific implementation process can be: replace all placeholders "?" in the node configuration information with "*%*", replace all blank characters "[\\s]+" with "", and obtain the replaced node configuration information; Determine whether the table field entity class is used as a parameter in the replaced node configuration information; if the table field entity class is used as a parameter in the replaced node configuration information, loop through the parameter list in turn to determine the parameter set and the parameter that belong to the user. Mapping relationship collection; obtain the field name and field type from the parameter collection passed in by the user and the parameter mapping relationship collection; obtain the field type from the corresponding collection according to the obtained field name. The specific implementation process is: if the field is a string type, add single quotes (") to the field, if the field is a date type, convert the field to the date format stored in the target data table and add single quotes ("), if the field is a valid large number with more than 16 digits, pass the large number The built-in conversion string method converts the field into a string type and adds single quotes (") to get the table creation statement; if the replaced node configuration information does not use the table field entity class as a parameter, get it from JavaBean Entity class batch parameters, you can get the table creation statement. Among them, the table creation statement is also a SQL statement.
拦截器的数据同步模块确定每一目标备库系统的数据同步方式。其中,每一目标备库系统的初始的数据同步方式默认为实时同步方式。拦截器的数据同步模块校验目标数据量是否达到所设定的预设阈值,在数据同步方式为实时同步方式时,若目标数据量小于预设阈值,保持数据同步方式为实时同步方式,若目标数据量大于或等于预设阈值,将数据同步方式从实时同步方式更新为异步同步方式。在数据同 步方式为异步同步方式时,若目标数据量小于预设阈值,确定数据同步方式具体为异步数据同步方式,若目标数据量大于或等于预设阈值,确定数据同步方式具体为异步文件同步方式。其中,数据同步方式在记录时,可以通过表名和数据同步方式两个参数来实现。进一步的,在异步同步方式过程中,可以采用表2所示格式来实现具体的异步同步方式。在表2中,table_name参数用于表示目标数据表的表名;dcn_no参数用于表示接收目标操作数据的目标备库系统的编号;sql参数用于在process_type为SQL时,记录需要执行同步的SQL脚本,否则为空;id_hash用于在process_type为FILE时,记录通过目标操作文件上传至文件服务器时转换得到的存储目标操作文件的ID和Hash值;process_type用于标识异步同步方式的具体执行类型,用表示异步文件同步方式的FILE和表示异步数据同步方式的SQL进行标识;create_time用于表示生成异步同步方式的当前时间,该事件可以用于作为后续同步的逻辑顺序;sys_seq用于表示异步同步方式对应的当前流水号,用于在监控到异常后运维人员使用该流水号查找整个流程的调用链从而快速定位问题,执行处理方案,评估影响范围。The data synchronization module of the interceptor determines the data synchronization mode of each target standby database system. Among them, the initial data synchronization mode of each target standby database system defaults to the real-time synchronization mode. The data synchronization module of the interceptor checks whether the target data volume reaches the set preset threshold value. When the data synchronization mode is the real-time synchronization mode, if the target data volume is less than the preset threshold value, the data synchronization mode is kept as the real-time synchronization mode. The target data volume is greater than or equal to the preset threshold, and the data synchronization method is updated from the real-time synchronization method to the asynchronous synchronization method. When the data synchronization method is an asynchronous synchronization method, if the target data volume is less than the preset threshold, determine that the data synchronization method is specifically asynchronous data synchronization mode; if the target data volume is greater than or equal to the preset threshold value, determine that the data synchronization method is specifically asynchronous file synchronization Way. Among them, the data synchronization method can be realized through two parameters of the table name and the data synchronization method when recording. Further, in the process of the asynchronous and synchronous manner, the format shown in Table 2 may be used to implement a specific asynchronous and synchronous manner. In Table 2, the table_name parameter is used to indicate the table name of the target data table; the dcn_no parameter is used to indicate the number of the target backup system that receives the target operation data; the sql parameter is used to record the SQL that needs to be synchronized when the process_type is SQL Script, otherwise it is empty; id_hash is used to record the ID and Hash value of the storage target operation file converted when the target operation file is uploaded to the file server when the process_type is FILE; process_type is used to identify the specific execution type of the asynchronous and synchronous mode, It is identified by FILE representing the asynchronous file synchronization method and SQL representing the asynchronous data synchronization method; create_time is used to represent the current time when the asynchronous synchronization method is generated, and this event can be used as a logical sequence for subsequent synchronization; sys_seq is used to represent the asynchronous synchronization method The corresponding current serial number is used by the operation and maintenance personnel to use the serial number to find the call chain of the entire process after monitoring the abnormality, so as to quickly locate the problem, execute the processing plan, and evaluate the scope of impact.
表2Table 2
table_nametable_name sqlsql id_hashid_hash dcn_nodcn_no process_typeprocess_type create_timecreate_time sys_seqsys_seq
示例性的,若拦截器的数据同步模块确定目标备库系统1的数据同步方式为实时同步方式,拦截器将确定得到的目标操作语句和建表语句填充到实时请求报文中,并将实时请求报文发布到目标备库系统1对应的系统编号对应的实时消息队列中,通过队列消息的形式将实时请求报文发送至目标备库系统1。目标备库系统1接收到实时请求报文后,对实时请求报文进行以下判断:判断目标备库系统1中是否存在与建表语句对应的表结构的目标数据表;若目标备库系统1中不存在匹配的目标数据表,执行实时请求报文中的建表语句,创建得到目标数据表,然后再执行实时请求报文中的目标操作语句,得到执行目标操作语句的更新结果,并将更新结果填充到响应报文发送至主操作库系统;若目标备库系统1中存在匹配的目标数据表,进一步检查建表语句中的字段名称、字段类型和字段长度是否目标备库系统1中的目标数据表的字段名称、字段类型和字段长度均一致;若字段名称、字段类型和字段长度均一致,首先将目标备库系统1中的目标数据表进行缓存,然后执行目标操作语句,得到更新结果,并将更新结果填充到响应报文发送至主操作库系统;若字段名称、字段类型和字段长度中至少一个不一致,通过特定语句例如dataSource获取目标备库系统1中的目标数据表的表结构信息,得到目标备库系统1中的目标数据表的建表语句,将执行不通过、目标备库系统1中目标数据表的建表语句和具体导致返回不通过的原因填充到响应报文,并发送至主操作库系统。Exemplarily, if the data synchronization module of the interceptor determines that the data synchronization mode of the target backup system 1 is a real-time synchronization mode, the interceptor fills the determined target operation statement and the table creation statement into the real-time request message, and sends the real-time The request message is published to the real-time message queue corresponding to the system number corresponding to the target standby database system 1, and the real-time request message is sent to the target standby database system 1 in the form of a queue message. After receiving the real-time request message, the target standby database system 1 performs the following judgments on the real-time request message: judge whether there is a target data table with a table structure corresponding to the table-building statement in the target standby database system 1; if the target standby database system 1 There is no matching target data table in the real-time request message, execute the table creation statement in the real-time request message to create the target data table, and then execute the target operation statement in the real-time request message to obtain the update result of the target operation statement, and The update result is filled in the response message and sent to the main operating database system; if there is a matching target data table in the target standby database system 1, further check whether the field name, field type, and field length in the table creation statement are in the target standby database system 1 The field names, field types, and field lengths of the target data table are consistent; if the field names, field types, and field lengths are all consistent, first cache the target data table in the target standby database system 1, and then execute the target operation statement to obtain Update the result, and fill the update result into the response message and send it to the main operating library system; if at least one of the field name, field type, and field length is inconsistent, obtain the target data table in the target standby database system 1 through a specific statement such as dataSource Table structure information, get the table creation statement of the target data table in the target standby database system 1, and fill in the response report with the table creation statement of the target data table in the target standby database system 1 and the specific reason for the failed execution. file and send it to the main operating library system.
主操作库系统拦截器的同步结果处理模块接收到目标备库系统1发送的响应报文后,若响应报文指示目标备库系统1同步执行成功(即前述执行目标操作语句成 功),针对目标备库系统1的数据同步操作完成。若响应报文指示目标备库系统1同步执行失败(即前述执行目标操作数语句异常),首先将目标备库系统对应的数据同步方式更新为异步同步方式;然后通过当前更新结果所属系统编号找到前面已经执行成功的备库系统子系统,最后将本次同步的目标操作语句以及目标备库系统1对应的系统编号记录按照表2进行记录,并更新表2中的process_type字段为SQL。同时,在响应报文指示目标备库系统1同步执行失败时,还需持久化异常信息,持久化异常信息的信息结构可以如表3所示,表3中部分内容标识与表2中相同,此处不再详细赘述,表3中route_sys_name用于标识执行出现异常的备库所属系统名,方便运维人员定位系统日志;remark用于表示备注,主要用来记录执行失败的原因,作为告警的关键日志;urgent_type用于标识紧急类型,其中,用H表示高优先级,L表示低优先级,D已完成处理。After the synchronization result processing module of the main operation database system interceptor receives the response message sent by the target standby database system 1, if the response message indicates that the target standby database system 1 has successfully executed synchronously (that is, the aforementioned execution of the target operation statement is successful), the target The data synchronization operation of standby database system 1 is completed. If the response message indicates that the target standby database system 1 fails to execute synchronously (that is, the aforementioned execution of the target operand statement is abnormal), first update the data synchronization mode corresponding to the target standby database system to asynchronous synchronization mode; then find out through the system number of the current update result The standby database system subsystem that has been successfully executed before, finally records the target operation statement of this synchronization and the system number record corresponding to the target standby database system 1 according to Table 2, and updates the process_type field in Table 2 to SQL. At the same time, when the response message indicates that the target standby database system 1 fails to execute synchronously, the abnormal information needs to be persisted. The information structure of the persistent abnormal information can be shown in Table 3, and some content identifiers in Table 3 are the same as those in Table 2. I won’t go into details here. The route_sys_name in Table 3 is used to identify the system name of the standby database where the abnormal execution occurs, which is convenient for the operation and maintenance personnel to locate the system log; remark is used to indicate the remark, which is mainly used to record the cause of the execution failure and serve as an alarm Critical log; urgent_type is used to identify the urgent type, where H indicates high priority, L indicates low priority, and D has completed processing.
表3table 3
table_nametable_name sqlsql id_hashid_hash dcn_nodcn_no route_sys_nameroute_sys_name remarkremark create_timecreate_time urgent_typeurgent_type
其中,若同步失败原因是字段名称、字段类型和字段长度中至少一个不一致,拦截器的数据下发异常监控和反馈处理模块确定urgent_type为高优先级即H的异常信息记录,针对于高优先级的urgent_type,可以触发语音通信例如提醒相关负责人,以使相关负责人确认上下游字段不一致是否能够调整一致,在调整一致后可以将urgent_type修改为D已处理。若失败原因是同步过程中导致的失败,拦截器的数据下发异常监控和反馈处理模块确定urgent_type为低优先级L的异常信息记录,针对低优先级的urgent_type,可以通过发送提示消息例如文本信息或语音信息的方式来提示相关负责人,以使相关负责人可以集中安排时间做处理,相关负责人处理后将urgent_type修改为D。Among them, if the reason for the synchronization failure is that at least one of the field name, field type, and field length is inconsistent, the interceptor's data delivery exception monitoring and feedback processing module determines that urgent_type is an exception information record with high priority, that is, H, for high priority The urgent_type can trigger voice communication, such as reminding the relevant person in charge, so that the relevant person in charge can confirm whether the inconsistency of the upstream and downstream fields can be adjusted. After the adjustment is consistent, the urgent_type can be changed to D and processed. If the cause of the failure is the failure caused during the synchronization process, the interceptor's data delivery exception monitoring and feedback processing module determines that the urgent_type is an exception information record with low priority L. For the low priority urgent_type, you can send a prompt message such as a text message or voice information to remind the relevant person in charge, so that the relevant person in charge can centrally arrange time for processing, and the relevant person in charge changes urgent_type to D after processing.
在目标备库系统1同步失败,目标备库系统2和目标备库系统3已同步成功的前提下,由于目标备库系统1同步失败,因此,拦截器的数据下发异常监控和反馈处理模块还需要对目标备库系统2和目标备库系统3做数据回滚操作。主操作库系统确定目标备库系统2和目标备库系统3的系统编号,将待执行的SQL回归语句组装成回滚通知报文,并发布至数据回滚队列中进行发送给对应的目标备库系统2和目标备库系统3。目标备库系统2和目标备库系统3接收到回滚通知报文后,进行相应的数据回滚:例如目标操作语句为Insert类型时,将新增成功的数据删除;若目标操作语句为Update类型,通过更新条件查出更新之前的备份数据,对数据进行恢复;若目标操作语句为Delete类型,通过条件查出删除之前的备份数据来做恢复。On the premise that the synchronization of the target backup system 1 fails, and the synchronization of the target backup system 2 and the target backup system 3 is successful, since the synchronization of the target backup system 1 fails, the data of the interceptor is sent to the exception monitoring and feedback processing module It is also necessary to perform a data rollback operation on the target standby database system 2 and the target standby database system 3. The main operating library system determines the system numbers of target standby database system 2 and target standby database system 3, assembles the SQL regression statement to be executed into a rollback notification message, and publishes it to the data rollback queue for sending to the corresponding target standby database. Database system 2 and target standby database system 3. After the target standby database system 2 and the target standby database system 3 receive the rollback notification message, they will perform corresponding data rollback: for example, when the target operation statement is Insert type, the newly added and successful data will be deleted; if the target operation statement is Update Type, find out the backup data before updating through the update condition, and restore the data; if the target operation statement is the Delete type, find out the backup data before deleting through the condition to restore.
在拦截器的数据同步模块确定目标备库系统1的数据同步方式为异步数据同步方式时,主操作库系统拦截器的数据同步模块将目标操作语句填充到异步请求报文中,并将异步请求报文发布到目标备库系统1对应的系统编号对应的异步消息队列中,将目标操作数据按照预设异步时间周期例如每隔30分钟将异步消息队列中的消 息发送至目标备库系统1,目标备库系统1接收到异步请求报文后的实现过程与目标备库系统1接收到实时请求报文的处理步骤相同,此处不再详细赘述。When the data synchronization module of the interceptor determines that the data synchronization mode of the target standby database system 1 is an asynchronous data synchronization mode, the data synchronization module of the interceptor of the main operation library system fills the target operation statement into the asynchronous request message, and sends the asynchronous request The message is published to the asynchronous message queue corresponding to the system number corresponding to the target standby database system 1, and the target operation data is sent to the target standby database system 1 according to the preset asynchronous time period, for example, every 30 minutes. The implementation process after the target backup system 1 receives the asynchronous request message is the same as the processing steps for the target backup system 1 to receive the real-time request message, and will not be described in detail here.
在拦截器的数据同步模块确定目标备库系统1的数据同步方式为异步文件同步方式时,主操作库系统拦截器的数据同步模块先在本地系统创建一个文件,以目标数据表表名、当前日期和随机生产的编号对创建的文件进行命名;将目标操作语句写入到创建的文件中;将包括目标操作语句的文件上传到文件服务器,文件服务器会返回针对包括目标操作语句的文件的存储位置的唯一标识,即针对表2和表3中的id_hash字段。然后拦截器的数据同步模块将返回的唯一标识填充至异步请求报文中,并将异步请求报文发布到目标备库系统1对应的系统编号对应的异步消息队列中,将目标操作数据按照预设异步时间周期例如每隔30分钟将异步消息队列中的消息发送至目标备库系统1,目标备库系统1接收到异步请求报文后的实现过程与目标备库系统1接收到实时请求报文的处理步骤相同,此处不再详细赘述。将目标操作语句写入到创建的文件中的具体实现过程可以是将目标操作语句中的全部语句写入到创建的文件中,也可以是将目标操作语句中的操作语句按照一定数量进行分组,生成至少一个文件,来实现异步同步。When the data synchronization module of the interceptor determines that the data synchronization method of the target standby database system 1 is an asynchronous file synchronization method, the data synchronization module of the interceptor of the main operating library system first creates a file in the local system, with the name of the target data table, the current Date and random production number to name the created file; write the target operation statement into the created file; upload the file including the target operation statement to the file server, and the file server will return the storage for the file including the target operation statement The unique identifier of the location, that is, for the id_hash field in Table 2 and Table 3. Then the data synchronization module of the interceptor fills the returned unique identifier into the asynchronous request message, and publishes the asynchronous request message to the asynchronous message queue corresponding to the system number corresponding to the target backup system 1, and transfers the target operation data according to the preset Set the asynchronous time period, for example, to send the messages in the asynchronous message queue to the target standby database system 1 every 30 minutes. The processing steps of the text are the same, and will not be described in detail here. The specific implementation process of writing the target operation statement into the created file can be writing all the statements in the target operation statement into the created file, or grouping the operation statements in the target operation statement according to a certain number, Generate at least one file to achieve asynchronous synchronization.
针对异步同步方式的异步处理结果的与实施同步方式的结果处理基本一致,差别在于接收到数据同步成功的返回报文后将数据同步方式更新为实时同步更新。The asynchronous processing result of the asynchronous synchronous mode is basically the same as the result processing of the synchronous mode, the difference is that the data synchronous mode is updated to real-time synchronous update after receiving the return message of successful data synchronization.
主操作库系统拦截器的阈值设定模块基于Spring的AOP的注解@CollectionReccateTime(),来采集执行数据同步成功时,检测到用户的操作请求至检测到同步成功期间的耗时时长和本次同步所包含的目标数据量,对三种数据操作类型的这两个值分别做数据采集和观察,可以得到如表4所示的数据耗时记录结果,以使相关负责人对表4所示的统计结果观察不同操作类型的不同数据量耗时来做预设阈值的调整,并将调整后的预设阈值通过动态配置项下发到主操作库系统,以实现后续的同步过程。The threshold setting module of the main operation library system interceptor is based on Spring’s AOP annotation @CollectionReccateTime(), to collect and execute data synchronization successfully, the time-consuming period between the detection of the user’s operation request and the detection of the successful synchronization and the current synchronization The amount of target data included, data collection and observation of these two values of the three types of data operations, respectively, can obtain the data time-consuming record results shown in Table 4, so that the relevant person in charge can understand the data shown in Table 4 According to the statistical results, it takes time to adjust the preset threshold by observing the different data volumes of different types of operations, and the adjusted preset threshold is sent to the main operation library system through the dynamic configuration item to realize the subsequent synchronization process.
表4Table 4
op_typeop_type data_countdata_count timeouttimeout
其中,op_type用于标识操作类型,data_count用于标识对应的操作类型的数据量,timeout用于标识该操作类型的耗时。一种操作类型对应的耗时=解析请求耗时+∑(获取数据耗时+处理数据耗时)+组装返回结果耗时,∑(获取数据耗时+处理数据耗时)为该操作类型对应的数据量个操作语句的耗时。Among them, op_type is used to identify the operation type, data_count is used to identify the data volume of the corresponding operation type, and timeout is used to identify the time-consuming of the operation type. Time-consuming corresponding to an operation type = time-consuming parsing request + ∑ (time-consuming data acquisition + time-consuming processing data) + time-consuming assembling and returning results, ∑ (time-consuming data acquisition + time-consuming processing data) corresponds to the operation type The amount of data and the time-consuming operation statement.
主操作库系统中的数据下发异常监控和反馈处理模块中,实现异常告警的过程可以是基于文本信息平台和虚拟电话外呼平台来实现的,参照图9所示,每新增一条紧急类型为高优先级的异常信息,均可以采用立即触发电话提醒方式提醒相关负责人,若相关负责人对高优先级的异常信息进行处理,变更异常信息中的紧急类型为已处理,若相关负责人对高优先级的异常信息未进行处理,保持异常记录信息中 的紧急类型为高优先级,将触发逻辑放入延时队列中,延时一定时长例如5分钟后再次触发虚拟电话外呼平台,实现电话提醒方式提醒相关负责人,直至异常信息记录中的紧急类型变更为已处理。而针对紧急类型为低优先级的记录,可在数据同步结束后,触发一次异常信息扫描操作,也就是说,采用定时轮询的方式对异常信息记录中紧急类型为低优先级的记录进行扫描,将扫描到的异常信息记录中紧急类型为低优先级的记录转换成请求报文格式发送到文本信息平台,实现文本信息提醒方式,直至异常信息记录中的紧急类型变更为已处理。其中,文本信息平台例如可以是短信平台。In the data delivery exception monitoring and feedback processing module in the main operation library system, the process of realizing the abnormal alarm can be realized based on the text information platform and the virtual phone outbound platform. Referring to Figure 9, each new emergency type For high-priority abnormal information, the relevant person in charge can be reminded by immediately triggering a phone call reminder. If the relevant person in charge handles the high-priority abnormal information, change the emergency type in the abnormal information to processed. If the relevant person in charge The high-priority exception information is not processed, and the emergency type in the exception record information is kept as high priority, and the trigger logic is put into the delay queue, and the virtual phone outbound platform is triggered again after a certain delay, for example, 5 minutes. Realize the telephone reminder method to remind the relevant person in charge until the emergency type in the exception information record is changed to processed. For records with an urgent type of low priority, an abnormal information scanning operation can be triggered after the data synchronization is completed, that is, a regular polling method is used to scan the records with an urgent type of low priority in the abnormal information records , converting the scanned exception information records with the urgent type of low priority into a request message format and sending them to the text information platform to realize the text information reminder until the urgent type in the abnormal information records is changed to processed. Wherein, the text information platform may be, for example, a short message platform.
本实施例中与其它实施例中相同步骤和相同内容的说明,可以参照其它实施例中的描述,此处不再赘述。For descriptions of the same steps and content in this embodiment as in other embodiments, reference may be made to the descriptions in other embodiments, and details are not repeated here.
本申请实施例中,若检测到针对目标数据表的属于目标操作类型的目标操作语句,第一存储节点确定与目标数据表具有关联关系的至少一个第二存储节点,确定每一第二存储节点的数据同步方式,并基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,以使第二存储节点执行目标操作语句,实现与第一存储节点针对目标数据表的同步更新操作,解决了目前分布式存储系统数据同步效率的问题,有效保证了分布式存储系统中数据的一致性,提高了分布式存储系统中数据同步效率。In the embodiment of the present application, if a target operation statement belonging to the target operation type is detected for the target data table, the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node The data synchronization method, and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
基于前述实施例,本申请的实施例提供一种数据同步系统,该数据同步系统可以应用于图1~7对应的实施例提供的数据同步方法中,参照图10所示,该数据同步系统3可以包括:第一存储节点31和至少一个第二存储节点32,其中:Based on the foregoing embodiments, the embodiments of the present application provide a data synchronization system, which can be applied to the data synchronization methods provided in the embodiments corresponding to FIGS. 1 to 7. Referring to FIG. 10, the data synchronization system 3 It may include: a first storage node 31 and at least one second storage node 32, wherein:
第一存储节点31,用于存储目标数据表,并执行数据同步程序,以实现以下步骤:若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与目标数据表具有关联关系的至少一个第二存储节点;其中,目标操作语句用于改变目标数据表中的内容;确定每一第二存储节点的数据同步方式;基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,以实现第一存储节点和第二存储节点中针对目标数据表的同步更新;The first storage node 31 is used to store the target data table, and execute the data synchronization program to achieve the following steps: if a target operation statement belonging to the target operation type for the target data table is detected, determine the associated relationship with the target data table At least one second storage node; wherein, the target operation statement is used to change the content in the target data table; determine the data synchronization mode of each second storage node; based on each data synchronization mode, send the target operation statement to the corresponding second A storage node, so as to realize the synchronous update of the target data table in the first storage node and the second storage node;
第二存储节点32,用于接收目标操作语句;采用目标操作语句,对第二存储节点中与目标操作语句对应的目标数据表执行更新操作,得到更新结果。The second storage node 32 is configured to receive the target operation statement; use the target operation statement to perform an update operation on the target data table corresponding to the target operation statement in the second storage node to obtain an update result.
在本申请其他实施例中,第一存储节点31执行步骤基于每一数据同步方式,发送目标操作语句至对应的第二存储节点时,可以通过以下步骤来实现:In other embodiments of the present application, when the first storage node 31 executes the step based on each data synchronization method, when sending the target operation statement to the corresponding second storage node, it can be implemented through the following steps:
若每一数据同步方式为实时同步方式,确定目标数据表对应的建表语句;If each data synchronization method is a real-time synchronization method, determine the table creation statement corresponding to the target data table;
基于建表语句和目标操作语句,生成第一请求报文;Generate a first request message based on the table creation statement and the target operation statement;
通过实时同步方式发送第一请求报文至对应的第二存储节点;其中,第一请求报文包括目标操作语句,第一请求报文中包括的建表语句用于在第二存储节点接收到第一请求报文后,检测到目标数据表不存在时,生成目标数据表。Send the first request message to the corresponding second storage node in a real-time synchronous manner; wherein, the first request message includes a target operation statement, and the table creation statement included in the first request message is used for receiving at the second storage node After the first request message, when it is detected that the target data table does not exist, the target data table is generated.
在本申请其他实施例中,第一存储节点31执行步骤基于每一数据同步方式,发送目标操作语句至对应的第二存储节点之前,还用于执行以下步骤:In other embodiments of the present application, the execution step of the first storage node 31 is also used to perform the following steps before sending the target operation statement to the corresponding second storage node based on each data synchronization method:
确定目标操作语句对应的目标数据量;Determine the target data volume corresponding to the target operation statement;
对应的,基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,包括:Correspondingly, based on each data synchronization mode, send the target operation statement to the corresponding second storage node, including:
基于目标数据量和每一数据同步方式,发送目标操作语句至对应的第二存储节点。Based on the target data amount and each data synchronization mode, the target operation statement is sent to the corresponding second storage node.
在本申请其他实施例中,第一存储节点31执行步骤基于目标数据量和每一数据同步方式,发送目标操作语句至对应的第二存储节点时,可以通过以下步骤来实现:In other embodiments of the present application, when the first storage node 31 performs the step of sending the target operation statement to the corresponding second storage node based on the target data volume and each data synchronization method, it can be implemented through the following steps:
若每一数据同步方式为实时同步方式,且目标数据量小于预设阈值,确定目标数据表对应的建表语句;If each data synchronization method is a real-time synchronization method, and the target data volume is less than a preset threshold, determine the table creation statement corresponding to the target data table;
基于建表语句和目标操作语句,生成第二请求报文;Generate a second request message based on the table creation statement and the target operation statement;
通过实时同步方式发送第二请求报文至对应的第二存储节点;其中,第二请求报文包括目标操作语句,第二请求报文中包括的建表语句用于在第二存储节点接收到第二请求报文后,检测到目标数据表不存在时,生成目标数据表。Send the second request message to the corresponding second storage node in a real-time synchronous manner; wherein, the second request message includes a target operation statement, and the table creation statement included in the second request message is used to receive the second request message at the second storage node After the second request message, when it is detected that the target data table does not exist, the target data table is generated.
在本申请其他实施例中,第一存储节点31执行步骤确定目标数据表对应的建表语句时,可以通过以下步骤来实现:In other embodiments of the present application, when the first storage node 31 performs the step of determining the table creation statement corresponding to the target data table, it may be implemented through the following steps:
确定目标操作语句对应的调用信息;Determine the call information corresponding to the target operation statement;
从调用信息中,确定用于定义目标数据表的结构的参考字段信息;From the call information, determine reference field information for defining the structure of the target data table;
采用目标字符替换参考字段信息中的参考字符,得到目标字段信息;Using the target character to replace the reference character in the reference field information to obtain the target field information;
若目标字段信息包括表字段实体信息,遍历目标字段信息,得到目标字段名;If the target field information includes table field entity information, traverse the target field information to get the target field name;
获取目标字段名对应的参考字段类型;Obtain the reference field type corresponding to the target field name;
采用目标语句规则对参考字段类型进行处理,得到建表语句;Use the target statement rule to process the reference field type to obtain the table creation statement;
若目标字段信息不包括表字段实体信息,从目标字段存储区域获取目标操作语句对应的语句,得到建表语句。If the target field information does not include the table field entity information, the statement corresponding to the target operation statement is obtained from the target field storage area to obtain the table creation statement.
在本申请其他实施例中,第一存储节点31还用于执行以下步骤:In other embodiments of the present application, the first storage node 31 is further configured to perform the following steps:
若每一数据同步方式为实时同步方式,且目标数据量大于或等于预设阈值,更新对应的数据同步方式为异步同步方式。If each data synchronization method is a real-time synchronization method, and the target data volume is greater than or equal to a preset threshold, update the corresponding data synchronization method to an asynchronous synchronization method.
在本申请其他实施例中,第一存储节点31还用于执行以下步骤:In other embodiments of the present application, the first storage node 31 is further configured to perform the following steps:
若每一数据同步方式为异步同步方式,且目标数据量大于或等于预设阈值,基于目标操作语句,生成目标操作文件;If each data synchronization method is an asynchronous synchronization method, and the target data volume is greater than or equal to a preset threshold, generate a target operation file based on the target operation statement;
发送目标操作文件至文件服务器;Send the target operation file to the file server;
接收文件服务器发送的用于指示目标操作文件存储位置的指示信息;receiving instruction information sent by the file server for indicating the storage location of the target operation file;
存储指示信息;store instructions;
按照预设异步时间周期,生成获取指令;其中,获取指令用于指示从文件服务 器的指示信息处获取目标操作文件,得到目标操作语句以执行对应的更新操作;Generate an acquisition instruction according to the preset asynchronous time period; wherein, the acquisition instruction is used to instruct to acquire the target operation file from the instruction information of the file server, and obtain the target operation statement to perform the corresponding update operation;
发送获取指令至对应的第二存储节点。Sending the acquisition instruction to the corresponding second storage node.
在本申请其他实施例中,第一存储节点31执行步骤基于每一数据同步方式,发送目标操作语句至对应的第二存储节点之后,还用于执行以下步骤:In other embodiments of the present application, the execution step of the first storage node 31 is based on each data synchronization method, and after sending the target operation statement to the corresponding second storage node, it is also used to perform the following steps:
接收对应的第二存储节点发送的更新结果;其中,更新结果为第二存储节点执行目标操作语句的操作结果;receiving the update result sent by the corresponding second storage node; wherein, the update result is the operation result of the second storage node executing the target operation statement;
基于更新结果,更新对应的第二存储节点的数据同步方式。Based on the update result, the data synchronization mode of the corresponding second storage node is updated.
在本申请其他实施例中,第一存储节点31执行步骤基于更新结果,更新对应的第二存储节点的数据同步方式时,可以通过以下步骤来实现:In other embodiments of the present application, when the first storage node 31 executes the step of updating the data synchronization mode of the corresponding second storage node based on the update result, it can be implemented through the following steps:
在数据同步方式为实时同步方式的情况下,若更新结果表示第二存储节点执行目标操作语句异常,更新数据同步方式为异步同步方式;When the data synchronization method is real-time synchronization method, if the update result indicates that the target operation statement executed by the second storage node is abnormal, the update data synchronization method is an asynchronous synchronization method;
在数据同步方式为异步同步方式的情况下,若更新结果表示第二存储节点执行目标操作语句成功,更新数据同步方式为实时同步方式。When the data synchronization method is an asynchronous synchronization method, if the update result indicates that the second storage node successfully executes the target operation statement, the updated data synchronization method is a real-time synchronization method.
在本申请其他实施例中,第一存储节点31执行步骤接收对应的第二存储节点发送的更新结果之后,还用于执行以下步骤:In other embodiments of the present application, after the first storage node 31 performs the step of receiving the update result sent by the corresponding second storage node, it is also used to perform the following steps:
若更新结果表示第二存储节点执行目标操作语句异常,确定更新结果对应的异常优先级;If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, determine the exception priority corresponding to the update result;
执行异常优先级对应的告警操作。Execute the alarm operation corresponding to the abnormal priority.
在本申请其他实施例中,第一存储节点31执行步骤接收对应的第二存储节点发送的更新结果之后,还用于执行以下步骤:In other embodiments of the present application, after the first storage node 31 performs the step of receiving the update result sent by the corresponding second storage node, it is also used to perform the following steps:
若更新结果表示第二存储节点执行目标操作语句异常,从至少一个第二存储节点中,确定更新结果表示第二存储节点执行目标操作语句成功的第二存储节点,得到至少一个第三存储节点;If the update result indicates that the second storage node executes the target operation statement abnormally, from at least one second storage node, determine the second storage node whose update result indicates that the second storage node successfully executes the target operation statement, and obtain at least one third storage node;
发送数据回滚控制指令至至少一个第三存储节点;其中,数据回滚控制指令用于指示第三存储节点回滚至执行目标操作语句前的数据。Sending a data rollback control command to at least one third storage node; wherein, the data rollback control command is used to instruct the third storage node to roll back to the data before executing the target operation statement.
在本申请其他实施例中,第一存储节点31还用于执行以下步骤:In other embodiments of the present application, the first storage node 31 is further configured to perform the following steps:
在每一第二存储节点发送的更新结果表示第二存储节点执行目标操作语句成功的情况下,统计每一第二存储节点的数据处理消耗时长,得到至少一个数据处理消耗时长;In the case that the update result sent by each second storage node indicates that the second storage node successfully executes the target operation statement, counting the data processing consumption time of each second storage node to obtain at least one data processing consumption time;
基于至少一个数据处理消耗时长,更新预设阈值。The preset threshold is updated based on at least one data processing consumption time period.
在本申请其他实施例中,第一存储节点31执行步骤若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与目标数据表具有关联关系的至少一个第二存储节点时,可以通过以下步骤来实现:In other embodiments of the present application, if the first storage node 31 executes the step and detects a target operation statement belonging to the target operation type for the target data table and determines at least one second storage node that has an association relationship with the target data table, it may Do this by following these steps:
获取数据服务层中的映射器声明参数和参数类型参数;Obtain mapper declaration parameters and parameter type parameters in the data service layer;
采用目标语句规则对映射器声明参数和参数类型参数进行处理,得到参考操作 语句;Process the mapper declaration parameters and parameter type parameters using the target statement rules to obtain the reference operation statement;
若参考操作语句的操作类型为目标操作类型,确定目标操作语句为参考操作语句;If the operation type of the reference operation statement is the target operation type, determine that the target operation statement is the reference operation statement;
确定与目标数据表具有关联关系的至少一个第二存储节点。At least one second storage node that has an association relationship with the target data table is determined.
需要说明的是,本申请实施例中一个或多个程序被处理器执行时,可以实现图1~7对应的实施例提供的方法,此处不再赘述。It should be noted that, when one or more programs in the embodiments of the present application are executed by the processor, the methods provided in the embodiments corresponding to FIGS. 1 to 7 can be implemented, which will not be repeated here.
本申请实施例中,若检测到针对目标数据表的属于目标操作类型的目标操作语句,第一存储节点确定与目标数据表具有关联关系的至少一个第二存储节点,确定每一第二存储节点的数据同步方式,并基于每一数据同步方式,发送目标操作语句至对应的第二存储节点,以使第二存储节点执行目标操作语句,实现与第一存储节点针对目标数据表的同步更新操作,解决了目前分布式存储系统数据同步效率的问题,有效保证了分布式存储系统中数据的一致性,提高了分布式存储系统中数据同步效率。In the embodiment of the present application, if a target operation statement belonging to the target operation type is detected for the target data table, the first storage node determines at least one second storage node that has an association relationship with the target data table, and determines that each second storage node The data synchronization method, and based on each data synchronization method, send the target operation statement to the corresponding second storage node, so that the second storage node executes the target operation statement, and realizes the synchronous update operation of the target data table with the first storage node , which solves the problem of data synchronization efficiency in the current distributed storage system, effectively ensures the consistency of data in the distributed storage system, and improves the data synchronization efficiency in the distributed storage system.
基于前述实施例,本申请的实施例提供一种计算机可读存储介质,简称为存储介质,该计算机可读存储介质存储有一个或者多个程序,该一个或者多个程序可被一个或者多个处理器执行,以实现如图1~7对应的实施例提供的数据同步方法实现过程,此处不再赘述。Based on the foregoing embodiments, the embodiments of the present application provide a computer-readable storage medium, referred to as a storage medium for short, where one or more programs are stored in the computer-readable storage medium, and the one or more programs can be used by one or more The processor executes to implement the implementation process of the data synchronization method provided in the embodiments corresponding to FIGS. 1 to 7 , which will not be repeated here.
以上,仅为本申请的实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和范围之内所作的任何修改、等同替换和改进等,均包含在本申请的保护范围之内。The above are only examples of the present application, and are not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
工业实用性Industrial Applicability
本申请实施例提供一种数据同步方法、系统及存储介质,该方法包括:若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与所述目标数据表具有关联关系的至少一个第二存储节点;其中,所述目标操作语句用于改变所述目标数据表中的内容;确定每一所述第二存储节点的数据同步方式;基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点,以实现第一存储节点和第二存储节点中针对所述目标数据表的同步更新,解决了目前分布式存储系统数据同步效率的问题,有效保证了分布式存储系统中数据的一致性,提高了分布式存储系统中数据同步效率。An embodiment of the present application provides a data synchronization method, system, and storage medium. The method includes: if a target operation statement belonging to the target operation type is detected for the target data table, determining at least one The second storage node; wherein, the target operation statement is used to change the content in the target data table; determine the data synchronization mode of each of the second storage nodes; based on each of the data synchronization modes, send the The target operation statement is sent to the corresponding second storage node to realize the synchronous update of the target data table in the first storage node and the second storage node, which solves the problem of data synchronization efficiency in the current distributed storage system and effectively guarantees It improves the consistency of data in the distributed storage system and improves the efficiency of data synchronization in the distributed storage system.

Claims (15)

  1. 一种数据同步方法,所述方法应用于第一存储节点,所述方法包括:A method for synchronizing data, the method being applied to a first storage node, the method comprising:
    若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与所述目标数据表具有关联关系的至少一个第二存储节点;其中,所述目标操作语句用于改变所述目标数据表中的内容;If a target operation statement belonging to the target operation type for the target data table is detected, at least one second storage node having an association relationship with the target data table is determined; wherein the target operation statement is used to change the target data table content in
    确定每一所述第二存储节点的数据同步方式;determining a data synchronization mode for each of the second storage nodes;
    基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点,以实现第一存储节点和第二存储节点中针对所述目标数据表的同步更新。Based on each of the data synchronization modes, the target operation statement is sent to the corresponding second storage node, so as to realize synchronous update of the target data table in the first storage node and the second storage node.
  2. 根据权利要求1所述的方法,其中,所述基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点,包括:The method according to claim 1, wherein the sending the target operation statement to the corresponding second storage node based on each of the data synchronization methods includes:
    若每一所述数据同步方式为实时同步方式,确定所述目标数据表对应的建表语句;If each of the data synchronization methods is a real-time synchronization method, determine the table creation statement corresponding to the target data table;
    基于所述建表语句和所述目标操作语句,生成第一请求报文;Generate a first request message based on the table creation statement and the target operation statement;
    通过所述实时同步方式发送所述第一请求报文至对应的所述第二存储节点;其中,所述第一请求报文包括所述目标操作语句,所述第一请求报文中包括的所述建表语句用于在所述第二存储节点接收到所述第一请求报文后,检测到所述目标数据表不存在时,生成所述目标数据表。Send the first request message to the corresponding second storage node through the real-time synchronization method; wherein, the first request message includes the target operation statement, and the first request message includes The table creation statement is used to generate the target data table when the second storage node detects that the target data table does not exist after receiving the first request message.
  3. 根据权利要求1或2所述的方法,其中,所述基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点之前,所述方法还包括:The method according to claim 1 or 2, wherein, before sending the target operation statement to the corresponding second storage node based on each of the data synchronization methods, the method further comprises:
    确定所述目标操作语句对应的目标数据量;determining the target data volume corresponding to the target operation statement;
    对应的,所述基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点,包括:Correspondingly, the sending the target operation statement to the corresponding second storage node based on each data synchronization mode includes:
    基于所述目标数据量和每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点。Based on the target data volume and each of the data synchronization modes, sending the target operation statement to the corresponding second storage node.
  4. 根据权利要求3所述的方法,其中,所述基于所述目标数据量和每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点,包括:The method according to claim 3, wherein the sending the target operation statement to the corresponding second storage node based on the target data volume and each of the data synchronization methods includes:
    若每一所述数据同步方式为所述实时同步方式,且所述目标数据量小于预设阈值,确定所述目标数据表对应的建表语句;If each of the data synchronization methods is the real-time synchronization method, and the target data volume is less than a preset threshold, determine the table creation statement corresponding to the target data table;
    基于所述建表语句和所述目标操作语句,生成第二请求报文;Generate a second request message based on the table creation statement and the target operation statement;
    通过所述实时同步方式发送所述第二请求报文至对应的所述第二存储节点;其中,所述第二请求报文包括所述目标操作语句,所述第二请求报文中包括的所述建表语句用于在所述第二存储节点接收到所述第二请求报文后,检测到所述目标数据表不存在时,生成所述目标数据表。Send the second request message to the corresponding second storage node through the real-time synchronization method; wherein, the second request message includes the target operation statement, and the second request message includes The table creation statement is used to generate the target data table when the second storage node detects that the target data table does not exist after receiving the second request message.
  5. 根据权利要求2或4所述的方法,其中,所述确定所述目标数据表对应的建表语句,包括:The method according to claim 2 or 4, wherein said determining the table creation statement corresponding to the target data table comprises:
    确定所述目标操作语句对应的调用信息;determining the invocation information corresponding to the target operation statement;
    从所述调用信息中,确定用于定义所述目标数据表的结构的参考字段信息;From the call information, determine reference field information for defining the structure of the target data table;
    采用目标字符替换所述参考字段信息中的参考字符,得到目标字段信息;replacing the reference character in the reference field information with the target character to obtain the target field information;
    若所述目标字段信息包括表字段实体信息,遍历所述目标字段信息,得到目标字段名;If the target field information includes table field entity information, traverse the target field information to obtain the target field name;
    获取所述目标字段名对应的参考字段类型;Obtain the reference field type corresponding to the target field name;
    采用目标语句规则对所述参考字段类型进行处理,得到所述建表语句;Processing the reference field type by using target statement rules to obtain the table creation statement;
    若所述目标字段信息不包括所述表字段实体信息,从目标字段存储区域获取所述目标操作语句对应的语句,得到所述建表语句。If the target field information does not include the table field entity information, obtain the statement corresponding to the target operation statement from the target field storage area to obtain the table creation statement.
  6. 根据权利要求4所述的方法,其中,所述方法还包括:The method according to claim 4, wherein the method further comprises:
    若每一所述数据同步方式为所述实时同步方式,且所述目标数据量大于或等于所述预设阈值,更新对应的所述数据同步方式为异步同步方式。If each of the data synchronization methods is the real-time synchronization method, and the target data volume is greater than or equal to the preset threshold, update the corresponding data synchronization method to be an asynchronous synchronization method.
  7. 根据权利要求2或6所述的方法,其中,所述方法还包括:The method according to claim 2 or 6, wherein the method further comprises:
    若每一所述数据同步方式为异步同步方式,且目标数据量大于或等于所述预设阈值,基于所述目标操作语句,生成目标操作文件;If each of the data synchronization methods is an asynchronous synchronization method, and the target data volume is greater than or equal to the preset threshold, generate a target operation file based on the target operation statement;
    发送所述目标操作文件至文件服务器;sending the target operation file to a file server;
    接收所述文件服务器发送的用于指示所述目标操作文件存储位置的指示信息;receiving indication information sent by the file server for indicating the storage location of the target operation file;
    存储所述指示信息;storing the instruction information;
    按照预设异步时间周期,生成获取指令;其中,所述获取指令用于指示从所述文件服务器的所述指示信息处获取所述目标操作文件,得到所述目标操作语句以执行对应的所述更新操作;Generate an acquisition instruction according to a preset asynchronous time period; wherein, the acquisition instruction is used to instruct to acquire the target operation file from the instruction information of the file server, and obtain the target operation statement to execute the corresponding update operation;
    发送所述获取指令至所述对应的所述第二存储节点。sending the acquiring instruction to the corresponding second storage node.
  8. 根据权利要求1所述的方法,其中,所述基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点之后,所述方法还包括:The method according to claim 1, wherein, after sending the target operation statement to the corresponding second storage node based on each of the data synchronization methods, the method further comprises:
    接收对应的所述第二存储节点发送的更新结果;其中,所述更新结果为所述第二存储节点执行所述目标操作语句的操作结果;receiving an update result sent by the corresponding second storage node; wherein the update result is an operation result of the second storage node executing the target operation statement;
    基于所述更新结果,更新对应的所述第二存储节点的所述数据同步方式。Based on the update result, update the data synchronization mode of the corresponding second storage node.
  9. 根据权利要求8所述的方法,其中,所述基于所述更新结果,更新对应的所述第二存储节点的所述数据同步方式,包括:The method according to claim 8, wherein, based on the update result, updating the corresponding data synchronization mode of the second storage node comprises:
    在所述数据同步方式为实时同步方式的情况下,若所述更新结果表示所述第二存储节点执行所述目标操作语句异常,更新所述数据同步方式为异步同步方式;When the data synchronization method is a real-time synchronization method, if the update result indicates that the execution of the target operation statement by the second storage node is abnormal, update the data synchronization method to an asynchronous synchronization method;
    在所述数据同步方式为所述异步同步方式的情况下,若所述更新结果表示所述第二存储节点执行所述目标操作语句成功,更新所述数据同步方式为所述实时同步方式。When the data synchronization method is the asynchronous synchronization method, if the update result indicates that the second storage node successfully executes the target operation statement, update the data synchronization method to the real-time synchronization method.
  10. 根据权利要求8所述的方法,其中,所述接收对应的所述第二存储节点发送的更新结果之后,所述方法还包括:The method according to claim 8, wherein, after receiving the update result sent by the corresponding second storage node, the method further comprises:
    若所述更新结果表示所述第二存储节点执行所述目标操作语句异常,确定所述 更新结果对应的异常优先级;If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, determine the exception priority corresponding to the update result;
    执行所述异常优先级对应的告警操作。Execute the alarm operation corresponding to the abnormal priority.
  11. 根据权利要求8所述的方法,其中,所述接收对应的所述第二存储节点发送的更新结果之后,所述方法还包括:The method according to claim 8, wherein, after receiving the update result sent by the corresponding second storage node, the method further comprises:
    若所述更新结果表示所述第二存储节点执行所述目标操作语句异常,从至少一个所述第二存储节点中,确定所述更新结果表示所述第二存储节点执行所述目标操作语句成功的第二存储节点,得到至少一个第三存储节点;If the update result indicates that the execution of the target operation statement by the second storage node is abnormal, determine from at least one of the second storage nodes that the update result indicates that the second storage node successfully executes the target operation statement the second storage node to obtain at least one third storage node;
    发送数据回滚控制指令至所述至少一个第三存储节点;其中,所述数据回滚控制指令用于指示所述第三存储节点回滚至执行所述目标操作语句前的数据。Sending a data rollback control instruction to the at least one third storage node; wherein the data rollback control instruction is used to instruct the third storage node to roll back to the data before executing the target operation statement.
  12. 根据权利要求8所述的方法,其中,所述方法还包括:The method according to claim 8, wherein the method further comprises:
    在每一所述第二存储节点发送的所述更新结果表示所述第二存储节点执行所述目标操作语句成功的情况下,统计每一所述第二存储节点的数据处理消耗时长,得到至少一个所述数据处理消耗时长;In the case that the update result sent by each of the second storage nodes indicates that the second storage node successfully executes the target operation statement, the data processing consumption time of each of the second storage nodes is counted to obtain at least The duration of the data processing;
    基于至少一个所述数据处理消耗时长,更新预设阈值。The preset threshold is updated based on at least one of the data processing consumption time.
  13. 根据权利要求1所述的方法,其中,所述若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与所述目标数据表具有关联关系的至少一个第二存储节点,包括:The method according to claim 1, wherein if the target operation statement belonging to the target operation type for the target data table is detected, determining at least one second storage node having an association relationship with the target data table includes:
    获取数据服务层中的映射器声明参数和参数类型参数;Obtain mapper declaration parameters and parameter type parameters in the data service layer;
    采用目标语句规则对映射器声明参数和参数类型参数进行处理,得到参考操作语句;Process the mapper declaration parameters and parameter type parameters by using the target statement rules to obtain the reference operation statement;
    若参考操作语句的操作类型为所述目标操作类型,确定所述目标操作语句为所述参考操作语句;If the operation type of the reference operation statement is the target operation type, determine that the target operation statement is the reference operation statement;
    确定与所述目标数据表具有关联关系的至少一个所述第二存储节点。Determine at least one second storage node that has an association relationship with the target data table.
  14. 一种数据同步系统,所述系统包括:第一存储节点和至少一个第二存储节点;其中:A data synchronization system, the system comprising: a first storage node and at least one second storage node; wherein:
    所述第一存储节点,用于若检测到针对目标数据表的属于目标操作类型的目标操作语句,确定与所述目标数据表具有关联关系的至少一个第二存储节点;其中,所述目标操作语句用于改变所述目标数据表中的内容;确定每一所述第二存储节点的数据同步方式;基于每一所述数据同步方式,发送所述目标操作语句至对应的所述第二存储节点;The first storage node is configured to determine at least one second storage node associated with the target data table if a target operation statement belonging to the target operation type is detected for the target data table; wherein the target operation The statement is used to change the content in the target data table; determine the data synchronization mode of each of the second storage nodes; based on each of the data synchronization modes, send the target operation statement to the corresponding second storage node node;
    所述第二存储节点,用于接收所述目标操作语句;采用所述目标操作语句,对所述第二存储节点中与所述目标操作语句对应的所述目标数据表执行更新操作,得到更新结果。The second storage node is configured to receive the target operation statement; use the target operation statement to perform an update operation on the target data table corresponding to the target operation statement in the second storage node, to obtain an updated result.
  15. 一种存储介质,所述存储介质上存储有数据同步程序,所述数据同步程序被处理器执行时实现如权利要求1至13任一项所述的数据同步方法的步骤。A storage medium, on which a data synchronization program is stored, and when the data synchronization program is executed by a processor, the steps of the data synchronization method according to any one of claims 1 to 13 are realized.
PCT/CN2022/120536 2021-12-17 2022-09-22 Data synchronization method and system, and storage medium WO2023109238A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111552168.XA CN114385754A (en) 2021-12-17 2021-12-17 Data synchronization method, system and storage medium
CN202111552168.X 2021-12-17

Publications (1)

Publication Number Publication Date
WO2023109238A1 true WO2023109238A1 (en) 2023-06-22

Family

ID=81197795

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/120536 WO2023109238A1 (en) 2021-12-17 2022-09-22 Data synchronization method and system, and storage medium

Country Status (2)

Country Link
CN (1) CN114385754A (en)
WO (1) WO2023109238A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114385754A (en) * 2021-12-17 2022-04-22 深圳前海微众银行股份有限公司 Data synchronization method, system and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130138612A1 (en) * 2011-11-29 2013-05-30 Microsoft Corporation Provisioning and/or synchronizing using common metadata
CN108833569A (en) * 2018-06-27 2018-11-16 郑州云海信息技术有限公司 A kind of method of data synchronization and relevant apparatus
CN109376160A (en) * 2018-08-21 2019-02-22 平安科技(深圳)有限公司 Method of data synchronization, device, computer equipment and storage medium
CN111708841A (en) * 2020-06-08 2020-09-25 中国工商银行股份有限公司 Database data synchronization method and device
US10924548B1 (en) * 2018-03-15 2021-02-16 Pure Storage, Inc. Symmetric storage using a cloud-based storage system
CN113032412A (en) * 2021-03-03 2021-06-25 北京沃东天骏信息技术有限公司 Data synchronization method and device, electronic equipment and computer readable medium
CN114385754A (en) * 2021-12-17 2022-04-22 深圳前海微众银行股份有限公司 Data synchronization method, system and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130138612A1 (en) * 2011-11-29 2013-05-30 Microsoft Corporation Provisioning and/or synchronizing using common metadata
US10924548B1 (en) * 2018-03-15 2021-02-16 Pure Storage, Inc. Symmetric storage using a cloud-based storage system
CN108833569A (en) * 2018-06-27 2018-11-16 郑州云海信息技术有限公司 A kind of method of data synchronization and relevant apparatus
CN109376160A (en) * 2018-08-21 2019-02-22 平安科技(深圳)有限公司 Method of data synchronization, device, computer equipment and storage medium
CN111708841A (en) * 2020-06-08 2020-09-25 中国工商银行股份有限公司 Database data synchronization method and device
CN113032412A (en) * 2021-03-03 2021-06-25 北京沃东天骏信息技术有限公司 Data synchronization method and device, electronic equipment and computer readable medium
CN114385754A (en) * 2021-12-17 2022-04-22 深圳前海微众银行股份有限公司 Data synchronization method, system and storage medium

Also Published As

Publication number Publication date
CN114385754A (en) 2022-04-22

Similar Documents

Publication Publication Date Title
US11176160B2 (en) SQL interceptor for use with third party data analytics packages
US11394805B1 (en) Automatic discovery of API information
US8396932B2 (en) Apparatus and method for efficiently managing data in a social networking service
US11343103B2 (en) Sending cross-chain authenticatable messages
WO2020140661A1 (en) Data synchronization method and system
US8374966B1 (en) In memory streaming with disk backup and recovery of messages captured from a database redo stream
US8195757B2 (en) Method, apparatus and computer program for controlling retention of publications
US7899991B2 (en) Method and system for an extensible caching framework
US7801852B2 (en) Checkpoint-free in log mining for distributed information sharing
CN108376118A (en) Service delivery system, method, equipment and storage medium
US8074230B2 (en) Method and system for dynamic context based contact service
CN112084258A (en) Data synchronization method and device
CN112507029A (en) Data processing system and data real-time processing method
WO2023109238A1 (en) Data synchronization method and system, and storage medium
WO2021031905A1 (en) Data management method, apparatus, device and system and computer-readable storage medium
CN111526188B (en) System and method for ensuring zero data loss based on Spark Streaming in combination with Kafka
WO2021258340A1 (en) Publishing system, pushing method, application device, receiving apparatus, and service management device
WO2017157111A1 (en) Method, device and system for preventing memory data loss
US7451127B2 (en) Web store events
CN114385760A (en) Method and device for real-time synchronization of incremental data, computer equipment and storage medium
US20230336368A1 (en) Block chain-based data processing method and related apparatus
CN111552719A (en) Data management method, device and system, big data platform and readable storage medium
CN116414628A (en) Transaction request processing method and device in new and old system switching process
CN112800066A (en) Index management method, related device and storage medium
CN109376193B (en) Data exchange system based on self-adaptive rule

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22905991

Country of ref document: EP

Kind code of ref document: A1