Synchronization Method, Device, Equipment and Medium Based on Shared Cluster Database

By acquiring and comparing synchronization messages in a shared cluster database system and updating memory maps to achieve synchronization, the problem of complex synchronization of non-data page resources in the prior art is solved, network messages are simplified and fault recovery complexity is reduced.

CN119046378BActive Publication Date: 2025-05-30SHENZHEN INST OF COMPUTING SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411134865.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-19
Publication Date
2025-05-30
Estimated Expiration
2044-08-19

AI Technical Summary

Technical Problem

In a shared cluster database system, the synchronization of non-data page resources between instances in the prior art depends on network message propagation, resulting in a large number of messages, large sizes, and complex failure recovery.

Method used

By obtaining the synchronization message after the instance is modified in the database instance, reloading the contents of the modified area in the shared file to temporary memory for comparison. If there is a difference, update the memory map to achieve synchronization and avoid propagating the original data.

Benefits of technology

Simplifies network messages, reduces the complexity of consistent recovery after failure, and improves system stability and reliability by completing update synchronization in the instance's own memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046378B_ABST
    Figure CN119046378B_ABST
Patent Text Reader

Abstract

This application is applicable to the field of database technology, and particularly relates to a synchronization method, device, equipment and medium based on a shared cluster database. This method is applied to the database instance of any database in the shared cluster database. When the database instance represents a receiving instance, it obtains the synchronization message sent by the execution instance after modifying the shared file. According to the synchronization message, it reloads the content of the modified storage area in the shared file into the temporary memory, compares the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result. If the comparison result shows a difference, it updates the memory mapping of the database instance according to the different content. In this process, there is no need to propagate the original data, thus simplifying the network message, and the update synchronization can be completed in the instance's own memory. Synchronization can still be performed according to the synchronization message during and after a failure, effectively reducing the complexity of consistency recovery after a failure occurs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application is applicable to the field of database technology, and particularly relates to a synchronization method, device, equipment and medium based on a shared cluster database. Background Art

[0002] In a shared cluster database system, when a certain instance (referred to as the executing instance) modifies the content of non-data page resources and persists it, although the file is shared by the instances, the content in the memory mapping of other instances (referred to as the receiving instances) is in the state before modification. At this time, the modified content needs to be synchronized to the receiving instances to ensure that the non-data page resources on each instance are in a consistent state. Among them, in a shared cluster database system, the operation of synchronizing the modified content of resources different from data pages by a certain instance to the memory mapping of other instances in the cluster system is called non-data page resource synchronization. Such resources include records in configuration parameter files, meta-information data of various database files, etc.

[0003] Currently, the instances notify the receiving instances to perform memory synchronization by means of network interaction. The specific modified content is carried by network messages, so that the instances receiving large network messages can perform memory synchronization. However, this synchronization method has a large number of message types and large message sizes, and is relatively dependent on a good network environment. Especially when a synchronization failure occurs, the process of recovering from the failure state to the consistent state of each instance is relatively complex.

[0004] Therefore, how to simplify network messages during the memory synchronization process of the executing instance to reduce the complexity of consistency recovery after a failure has become an urgent problem to be solved. Summary of the Invention

[0005] In view of this, embodiments of this application provide a synchronization method, device, equipment and medium based on a shared cluster database to solve the problem of how to simplify network messages during the memory synchronization process of the executing instance to reduce the complexity of consistency recovery after a failure.

[0006] In a first aspect, embodiments of this application provide a synchronization method based on a shared cluster database. The synchronization method is applied to a database instance of any database in the shared cluster database, and all databases are connected to a shared file, including:

[0007] When the database instance represents a receiving instance, obtain a synchronization message sent by an executing instance after modifying the shared file;

[0008] According to the synchronization message, reload the content of the modified storage area in the shared file into a temporary memory;

[0009] Compare the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result;

[0010] If the comparison result shows a difference, update the memory mapping of the database instance according to the content of the difference to achieve synchronization.

[0011] In a second aspect, an embodiment of the present application provides a synchronization device based on a shared cluster database. The synchronization device is applied to a database instance of any database in the shared cluster database, and all databases are connected to a shared file, including:

[0012] An acquisition module, configured to acquire a synchronization message sent by an execution instance after modifying the shared file when the database instance represents a receiving instance;

[0013] A reload module, configured to reload the content of the modified storage area in the shared file into a temporary memory according to the synchronization message;

[0014] A comparison module, configured to compare the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result;

[0015] A synchronization module, configured to update the memory mapping of the database instance according to the content of the difference if the comparison result shows a difference to achieve synchronization.

[0016] In a third aspect, an embodiment of the present application provides a computer device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the synchronization method described in the first aspect is implemented.

[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the synchronization method described in the first aspect is implemented.

[0018] The beneficial effects of the embodiments of the present application compared with the prior art are as follows: The synchronization method in the present application is applied to the database instance of any database in the shared cluster database. All databases are connected to the shared file. When the database instance represents the receiving instance, a synchronization message sent by the execution instance after modifying the shared file is obtained. According to the synchronization message, the content of the modified storage area in the shared file is reloaded into the temporary memory, and the content in the temporary memory is compared with the content in the memory mapping corresponding to the database instance to obtain a comparison result. If the comparison result shows a difference, the memory mapping of the database instance is updated according to the different content to achieve synchronization. In this process, there is no need to propagate the original data, thus simplifying the network message, and the update synchronization can be completed in the own memory of the instance. Synchronization can still be performed according to the synchronization message during and after a failure, effectively reducing the complexity of consistency recovery after a failure occurs. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0020] Figure 1 FIG. 1 is a schematic diagram of an application environment of a synchronization method based on a shared cluster database provided in Embodiment 1 of the present application;

[0021] Figure 2 FIG. 2 is a schematic flowchart of a synchronization method based on a shared cluster database provided in Embodiment 2 of the present application;

[0022] Figure 3 FIG. 3 is a schematic flowchart of a synchronization method based on a shared cluster database provided in Embodiment 3 of the present application;

[0023] Figure 4 FIG. 4 is a schematic flowchart of a synchronization method based on a shared cluster database provided in Embodiment 4 of the present application;

[0024] Figure 5 FIG. 5 is a schematic flowchart of a synchronization method based on a shared cluster database provided in Embodiment 5 of the present application;

[0025] Figure 6 FIG. 6 is a schematic flowchart of a synchronization method based on a shared cluster database provided in Embodiment 6 of the present application;

[0026] Figure 7 FIG. 7 is a schematic structural diagram of a synchronization device based on a shared cluster database provided in Embodiment 7 of the present application;

[0027] Figure 8 It is a schematic structural diagram of a computer device provided in Embodiment 8 of the present application. Detailed implementation manners

[0028] In the following description, specific details such as specific system structures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.

[0029] It should be understood that when used in the specification and appended claims of the present application, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.

[0030] It should also be understood that the term "and / or" as used in the specification and appended claims of the present application refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0031] As used in the specification and appended claims of the present application, the term "if" can be interpreted as "when", "once", "in response to determining", or "in response to detecting" depending on the context. Similarly, the phrase "if determined" or "if detected [the described condition or event]" can be interpreted as meaning "once determined", "in response to determining", "once detected [the described condition or event]", or "in response to detecting [the described condition or event]" depending on the context.

[0032] In addition, in the description of the specification and appended claims of the present application, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.

[0033] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that specific features, structures, or characteristics described in connection with that embodiment are included in one or more embodiments of this application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "comprising", "including", "having" and their variants all mean "including but not limited to", unless otherwise specifically emphasized.

[0034] The embodiments of this application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence is the theory, method, technology and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0035] Artificial intelligence basic technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, and mechatronics. Artificial intelligence software technologies mainly include several major directions such as computer vision technology, robotics, biometric technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0036] It should be understood that the magnitudes of the sequence numbers of the steps in the following embodiments do not mean the order of execution is prior or posterior, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of this application.

[0037] To illustrate the technical solutions of this application, specific embodiments will be used for illustration below.

[0038] A synchronization method based on a shared cluster database provided by the first embodiment of this application can be applied in an application environment such as Figure 1 where each database instance corresponds to a database and the memory mapping within the database, and all the databases maintain a shared file through a common protocol, thereby forming all the databases into a shared cluster database. Among them, the databases can be implemented by computer devices including but not limited to palm computers, desktop computers, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, cloud computer devices, personal digital assistants (PDAs), etc.

[0039] See Figure 2, which is a schematic flowchart of a synchronization method based on a shared cluster database provided in the second embodiment of the present application. The above synchronization method is applied to Figure 1 any database in the shared cluster database, specifically for any database instance (such as Figure 1 the database instance B shown). When the database instance A modifies its memory mapping A, in order to maintain the consistency of the memory mapping B of the database instance B, it is necessary to execute the synchronization method of the present application. Of course, if the database instance B modifies the memory mapping B, correspondingly, the database instance A also needs to execute the synchronization method of the present application. As Figure 2 shown, the synchronization method based on the shared cluster database may include the following steps:

[0040] Step S201, when the database instance represents a receiving instance, obtain the synchronization message sent by the executing instance after modifying the shared file.

[0041] In this embodiment, the executing instance is the database instance that modifies its memory mapping, that is, Figure 1 the database instance A in Figure 1 , and the receiving instance is the database instance that receives the synchronization message sent by other instances for synchronization, that is,

[0042] the database instance B in

[0043] Among them, when the database instance is the executing instance, it should, after modifying the memory mapping of this instance, persist the modified content to the shared file, and send a synchronization message to the receiving instance after the persistence is completed to notify the receiving instance to start synchronizing the above-mentioned modified content to achieve the purpose of content consistency.

[0044] Memory mapping maps a file to memory to achieve memory reading of the file, avoid repeated loading, and improve the reading efficiency. Therefore, configuration parameters, meta-information data, etc. are generally stored in the memory mapping. In a shared cluster database, the shared file generally stores non-data page resources, and such resources include records in the configuration parameter file, meta-information data of various database files, etc.

[0045] Among them, after receiving the synchronization message, the receiving instance determines the location of the storage area in the shared file that has been modified according to the synchronization message, so as to obtain the corresponding content at this location, and reload this part of the content into a temporary memory to achieve content comparison in subsequent steps.

[0046] The synchronization message may carry information about the location of the modified content in the shared file. For example, if the modified content is a modification to the log level, then the type of modification is the log type. Therefore, the receiving instance can, based on this log type, determine the storage area of the content corresponding to the log type in the shared file, and then can obtain the content of this storage area and load this part of the content into the temporary memory.

[0047] Step S203: Compare the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result.

[0048] Regarding the temporary memory and the existing memory mapping, the content therein can be directly compared, that is, the latest content is compared with the content in the receiving instance to determine whether there are differences between the two. The comparison result includes two types: no difference and there is a difference. If there is no difference, it can indicate that this synchronization message has been processed and is processed as a duplicate message without the need to perform an update.

[0049] Step S204: If the comparison result shows that there are differences, update the memory mapping of the database instance according to the different content to achieve synchronization.

[0050] Among them, if there are differences, infer the detailed operations of the execution instance according to the different content, execute these operations on the receiving instance and replace and update the memory mapping. After completing the replacement and update, reply to inform the execution instance that the synchronization has been completed. After the execution instance receives the synchronization completion messages from all receiving instances, this modification operation is completed.

[0051] As Figure 1 shown, the atomicity of the modification operation of database instance A is guaranteed by the step of persisting to the shared file. Before this step of persistence is completed, all modifications are in-memory modifications. If database instance A fails and a certain database instance B takes over database instance A, the failure recovery thread reloads the shared file and compares it with the memory mapping. At this time, there are no differences and no synchronization update is required. After the previous database instance A restarts, it is still consistent with other database instances B.

[0052] If database instance A fails after the persistence ends, a synchronization message may or may not have been sent at this time. After a certain database instance B takes over database instance A and reloads the shared file, it compares it with the memory mapping of this instance. If there is no difference, it means that the instance has completed the synchronization update when the failure occurred. It only needs to send a synchronization message to other surviving instances on behalf of the previous database instance A. If there are differences, it means that the takeover instance has not been synchronized. Infer the detailed content of the operations performed by the previous database instance A based on the differences. After performing the inferred operations, synchronize and update the memory mapping, and then send a synchronization message to other surviving instances on behalf of the previous database instance A. Wait for other surviving instances to complete the synchronization update and then the failure recovery ends. At this time, the previous database instance A restarts and loads the latest shared file, and is in a consistent state with all other instances.

[0053] Regardless of whether database instance B fails before or after the persistence of database instance A, it can load the modified shared file when restarting and maintain a consistent state with database instance A and other surviving instances.

[0054] Optionally, after comparing the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result, it further includes:

[0055] If the comparison result shows no difference, determine that the synchronization message is a duplicate message and mark the synchronization message as executed and completed.

[0056] Among them, in the case of a failure, there may be multiple synchronization messages sent to the same receiving instance. After the receiving instance receives the synchronization message for the first time, it has already performed the update. Therefore, there is no need to perform the update subsequently, and it can be marked as completed.

[0057] Optionally, after updating the memory mapping of the database instance according to the content of the difference, it further includes:

[0058] Send a synchronization completion message to the execution instance. The execution instance determines that the modification is completed after receiving the synchronization completion messages sent by all receiving instances.

[0059] Among them, after the synchronization is completed, the message of the synchronization completion is sent to the execution instance, so that the execution instance finally determines that the modification is completed and ends the process.

[0060] The synchronization method in the embodiments of this application is applied to the database instance of any database in the shared cluster database. All databases are connected to the shared file. When the database instance represents the receiving instance, it obtains the synchronization message sent by the executing instance after modifying the shared file. According to the synchronization message, it reloads the content of the modified storage area in the shared file into the temporary memory, compares the content in the temporary memory with the content in the memory mapping corresponding to the database instance, and obtains the comparison result. If the comparison result shows a difference, it updates the memory mapping of the database instance according to the different content to achieve synchronization. In this process, there is no need to propagate the original data, thus simplifying the network message, and the update synchronization can be completed in the own memory of the instance. Synchronization can still be performed according to the synchronization message during and after a failure, effectively reducing the complexity of consistency recovery after a failure.

[0061] See Figure 3 , which is a schematic flowchart of a synchronization method based on a shared cluster database provided in Embodiment 3 of this application. For a database instance, it can act as both a receiving instance and an executing instance. When the database instance is an executing instance, as Figure 3 shown, the synchronization method may include the following steps:

[0062] Step S301, when the database instance represents the executing instance, obtain the modified execution statement.

[0063] Step S302, according to the modified execution statement, modify the memory mapping of the database instance and persist the modification to the shared file.

[0064] Step S303, according to the modified execution statement, generate the synchronization message and send the synchronization message to the database instance represented as the receiving instance.

[0065] Among them, for a database, operations such as modification need to use the database language corresponding to the database. For example, SQL language, etc. Based on the modified execution statement, the memory mapping is modified, and the modified content is persisted to the shared file, so that the modified content is recorded in the corresponding storage area of the shared file.

[0066] And the synchronization message generated according to the modified execution statement can, after being obtained by the receiving instance, analyze and infer the storage area of the modified content in the shared file, so as to accurately obtain the modified content.

[0067] In the embodiments of the present application, the database instance can serve as both a receiving instance and an executing instance. When serving as an executing instance, to execute a modification, the memory mapping needs to be modified first, and then it is persisted in the shared file. Only after that can a synchronization message be sent to the receiving instance, enabling these receiving instances to execute according to the steps of the second embodiment above after receiving the synchronization message to complete the synchronization, ensuring that there are modified contents in the shared file and providing a prerequisite for synchronization.

[0068] See Figure 4 , which is a schematic flowchart of a synchronization method based on a shared cluster database provided in the fourth embodiment of the present application. As Figure 4 shown, in step S303 above, generating the synchronization message according to the modification execution statement may include the following steps:

[0069] Step S401, determining the modification type according to the modification execution statement.

[0070] Step S402, generating the synchronization message according to the modification type.

[0071] Among them, in the above modification execution statement, the modification type can be determined. For example, the modification type is the log level. Thus, according to this log level, a corresponding synchronization message can be generated, that is, the synchronization message covers the information of this log level, so that after the receiving instance receives this synchronization message, according to the information of the log level, it can determine the content of the corresponding storage area in the shared file.

[0072] The embodiments of the present application are based on the modification type as a standard, enabling the receiving instance to accurately determine the corresponding modified storage area from the shared file, and then accurately obtain the modified content to implement the subsequent synchronization work, improving the synchronization efficiency.

[0073] See Figure 5 , which is a schematic flowchart of a synchronization method based on a shared cluster database provided in the fifth embodiment of the present application. As Figure 5 shown, on the basis of the above fourth embodiment, in step S202 above, reloading the content of the modified storage area in the shared file into the temporary memory according to the synchronization message includes the following steps:

[0074] Step S501, determining the corresponding modification type according to the synchronization message.

[0075] Step S502, determining the storage area where the modification occurs in the shared file according to the modification type.

[0076] Step S503, reloading the content of the storage area into the temporary memory.

[0077] Among them, after the receiving instance obtains the above synchronization message, it can determine the modification type corresponding to the synchronization message, that is, the modification type corresponding to the corresponding execution instance when performing the modification.

[0078] According to the modification type, a storage area in the shared file can be further determined. This storage area is the location where the execution instance persists the modified content to the shared file, so that the receiving instance can accurately obtain the content in this storage area, and then reload this content into a temporary memory.

[0079] Combining the embodiments of the present application with the above Embodiment 4 can accurately and quickly obtain the modified content from the shared file to provide comparison content for subsequent synchronization, improving the synchronization efficiency.

[0080] See Figure 6 , which is a schematic flowchart of a synchronization method based on a shared cluster database provided by Embodiment 6 of the present application. As Figure 6 shown, after obtaining the synchronization message sent by the execution instance after modifying the shared file in the above step S201, the following steps may further be included:

[0081] Step S601, when detecting that the execution instance fails, detect whether the current receiving instance hosts the execution instance.

[0082] Step S602, if it is detected that the current receiving instance hosts the execution instance, send the synchronization message to the remaining database instances in the shared cluster database that are characterized as receiving instances.

[0083] Among them, for the situation where the execution instance fails, if the receiving instance hosts the execution instance, the receiving instance needs to send a synchronization message to other receiving instances, thereby avoiding the interruption of memory synchronization in case of failure and providing an effective security guarantee for the consistency of the shared cluster database.

[0084] In a shared cluster database composed of three database instances, adjust the level of the running logs of all instances from the INFO level to the DEBUG level. Instance 1 is the execution instance, and Instance 2 and Instance 3 are receiving instances.

[0085] Execute ALTER SYSTEM SET RUN_LOG_LEVEL = 'DEBUG' SCOPE = BOTH (that is, the modification execution statement) on Instance 1. First, modify the level of the running log thread and the log level in the memory mapping from INFO to DEBUG. Instance 1 starts to record logs above the DEBUG level, and then persist the modification of the memory mapping to the configuration file. After the modification is completed, send a synchronization update message to Instance 2 and Instance 3.

[0086] After Instance 2 receives the synchronization message, it first reloads the configuration file into the temporary memory. After comparing the temporary memory with the memory mapping of this instance, it is found that the log level in the memory mapping is INFO, while the log level in the temporary memory is DEBUG. It is inferred that Instance 1 has modified the log level from INFO to DEBUG. Then, it modifies the log level of the running log thread to DEBUG. At this time, Instance 2 also starts to record logs above the DEBUG level. After the modification is completed, it updates the log level in the memory mapping to DEBUG and sends a synchronization completion message to Instance 1.

[0087] Suppose that when Instance 2 sends a synchronization completion message to Instance 1, Instance 1 fails and exits the shared cluster. At this time, Instance 3 has not received the synchronization update message of Instance 1 due to network reasons. After the failure, Instance 3 takes over Instance 1. Instance 3 first reloads the configuration file. After comparing it with the memory mapping, it is found that the log levels are different. It is deduced that the failed instance has modified the log level from INFO to DEBUG. Instance 3 modifies the log level of the running log thread to DEBUG, and Instance 3 starts to record logs above the DEBUG level. Then, it modifies the log level in the memory mapping to DEBUG. After the modification is completed, it sends a synchronization update message to other surviving instances (i.e., Instance 2). After receiving the message, Instance 2 reloads the configuration file and finds no difference, indicating that the previous synchronization has been completed. It sends a synchronization completion to Instance 3. After receiving it, Instance 3 completes the failure recovery. When Instance 1 restarts, it loads the configuration file, and the log level in the configuration file is DEBUG. Therefore, after Instance 1 starts, the log levels of the memory mapping and the running log thread are also DEBUG, which is consistent with Instance 2 and Instance 3.

[0088] This modification operation starts with the log level change operation executed by Instance 1. During the synchronization process, Instance 1 fails. After the failure, Instance 3 takes over and performs the failure recovery. Since the persistent step of Instance 1 has been completed when the failure occurs, when the failure recovery ends and Instance 1 restarts, the log levels of the three instances are all in the modified state. Thus, this modification operation ends.

[0089] Corresponding to the synchronization method based on the shared cluster database in the above embodiments, Figure 7 The structure block diagram of the synchronization device provided in the seventh embodiment of the present application is shown. The above synchronization device is applied to Figure 1 any one of the shared cluster databases in Figure 1The database instance shown in B), when the database instance A modifies its memory mapping A, in order to maintain the consistency of the memory mapping B of the database instance B, the synchronization method of this application needs to be executed. Of course, if the database instance B modifies the memory mapping B, correspondingly, the database instance A also needs to execute the synchronization method of this application. For the sake of convenience of description, only the parts related to the embodiments of this application are shown.

[0090] See Figure 7 , the synchronization device includes:

[0091] An acquisition module 71, configured to acquire a synchronization message sent by an execution instance after modifying the shared file when the database instance represents a receiving instance;

[0092] A reloading module 72, configured to reload the content of the modified storage area in the shared file into the temporary memory according to the synchronization message;

[0093] A comparison module 73, configured to compare the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result;

[0094] A synchronization module 74, configured to, if the comparison result shows a difference, update the memory mapping of the database instance according to the content of the difference to achieve synchronization.

[0095] Optionally, the synchronization device further includes:

[0096] A modification statement module, configured to acquire a modification execution statement when the database instance represents the execution instance;

[0097] A modification module, configured to modify the memory mapping of the database instance according to the modification execution statement and persist the modification to the shared file;

[0098] A first message sending module, configured to generate the synchronization message according to the modification execution statement and send the synchronization message to the database instance characterized as the receiving instance.

[0099] Optionally, the first message sending module includes:

[0100] A modification type recognition unit, configured to determine the modification type according to the modification execution statement;

[0101] A synchronization message generation unit, configured to generate the synchronization message according to the modification type.

[0102] Optionally, the reloading module 72 includes:

[0103] A modification type determination unit, configured to determine a corresponding modification type according to the synchronization message;

[0104] A storage area determination unit, configured to determine a storage area where a modification occurs in the shared file according to the modification type;

[0105] A reloading unit, configured to reload the content of the storage area into a temporary memory.

[0106] Optionally, the synchronization device further includes:

[0107] A duplicate message determination module, configured to, after comparing the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result, if the comparison result shows no difference, determine that the synchronization message is a duplicate message and mark the synchronization message as executed and completed.

[0108] Optionally, the synchronization device further includes:

[0109] A synchronization completion feedback module, configured to send a synchronization completion message to the execution instance after updating the memory mapping of the database instance according to the content of the difference, and the execution instance determines that the modification is completed after receiving the synchronization completion messages sent by all receiving instances.

[0110] Optionally, the synchronization device further includes:

[0111] A hosting determination module, configured to, after obtaining the synchronization message sent by the execution instance after modifying the shared file, detect whether the current receiving instance hosts the execution instance when detecting that the execution instance fails;

[0112] A second message sending module, configured to, if it is detected that the current receiving instance hosts the execution instance, send the synchronization message to the remaining database instances represented as receiving instances in the shared cluster database.

[0113] It should be noted that for the information interaction, execution process, etc. between the above modules, since they are based on the same concept as the method embodiment of the present application, their specific functions and the technical effects brought thereby can be specifically referred to in the method embodiment part, and will not be elaborated here.

[0114] Figure 8 This is a schematic structural diagram of a computer device provided in Embodiment VIII of the present application. As Figure 8 shown, the computer device of this embodiment includes: at least one processor ( Figure 8only one is shown), a memory, and a computer program stored in the memory and executable on at least one processor. When the processor executes the computer program, the steps in any of the above-described embodiments of the synchronization method based on a shared cluster database are implemented.

[0115] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that Figure 8 merely an example of a computer device, and does not constitute a limitation on the computer device. The computer device may include more or fewer components than shown in the figure, or combine certain components, or different components. For example, it may also include a network interface, a display screen, and an input device, etc.

[0116] The so-called processor may be a CPU, and the processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.

[0117] The memory includes a readable storage medium, an internal memory, etc. Among them, the internal memory may be the memory of the computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be the hard disk of the computer device, and in some other embodiments, it may also be an external storage device of the computer device. For example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the computer device. Further, the memory may also include both the internal storage unit of the computer device and the external storage device. The memory is used to store the operating system, application programs, boot loaders, data, and other programs, etc. The other programs such as the program code of the computer program. The memory may also be used to temporarily store the data that has been output or will be output.

[0118] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual applications, the above-mentioned functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiments can be integrated into a processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working processes of the units and modules in the above-mentioned device can refer to the corresponding processes in the foregoing method embodiments and will not be elaborated herein. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, to implement all or part of the processes in the above-mentioned method embodiments of this application, a computer program can be used to instruct the relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.

[0119] All or part of the processes in the above-mentioned method embodiments of this application can also be completed by a computer program product. When the computer program product runs on a computer device, it enables the computer device to execute and implement the steps in the above-mentioned method embodiments.

[0120] In the above embodiments, the descriptions of each embodiment have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0121] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0122] In the embodiments provided in this application, it should be understood that the disclosed device / computer device and method can be implemented in other ways. For example, the device / computer device embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.

[0123] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0124] The above embodiments are only used to illustrate the technical solutions of this application, rather than to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements for some of the technical features. And these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included in the protection scope of this application.

Claims

1. A synchronization method based on a shared cluster database, characterized in that: The synchronization method is applied to a database instance of any database in the shared cluster database, and all databases are connected to a shared file, including: When the database instance represents a receiving instance, obtaining a synchronization message sent by the executing instance after modifying the shared file; Reloading the content of the modified storage area in the shared file into a temporary memory according to the synchronization message; Compare the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result; If the comparison result shows that there is a difference, the memory mapping of the database instance is updated according to the content of the difference to achieve synchronization; The synchronization method further comprises: When the database instance represents the execution instance, obtaining a modification execution statement; According to the modification execution statement, the memory mapping of the database instance is modified, and the modification is persisted to the shared file; generating the synchronization message according to the modified execution statement, and sending the synchronization message to the database instance characterized as the receiving instance; The step of generating the synchronization message according to the modified execution statement includes: Determine the modification type according to the modification execution statement; generating the synchronization message according to the modification type; The step of reloading the content of the modified storage area in the shared file into a temporary memory according to the synchronization message includes: Determine a corresponding modification type according to the synchronization message; According to the modification type, determining in the shared file a storage area where the modification occurs; Reload the content of the storage area into temporary memory.

2. The synchronization method according to claim 1, characterized in that: After comparing the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result, the method further includes: If the comparison result is that there is no difference, the synchronization message is determined to be a duplicate message, and the synchronization message is marked as executed.

3. The synchronization method according to claim 1, characterized in that: After the memory mapping of the database instance is updated according to the difference content, the method further includes: A synchronization completion message is sent to the execution instance, and the execution instance determines that the modification is completed after receiving the synchronization completion messages sent by all the receiving instances.

4. The synchronization method according to any one of claims 1 to 3, characterized in that: After obtaining the synchronization message sent by the execution instance after modifying the shared file, the method further includes: When a failure of the execution instance is detected, detecting whether the current receiving instance hosts the execution instance; If it is detected that the current receiving instance hosts the executing instance, the synchronization message is sent to the remaining database instances in the shared cluster database that are characterized as receiving instances.

5. A synchronization device based on a shared cluster database, characterized in that: The synchronization device is applied to a database instance of any database in the shared cluster database, and all databases are connected to a shared file, including: an acquisition module, configured to acquire, when the database instance represents a receiving instance, a synchronization message sent by the execution instance after modifying the shared file; A reloading module, used for reloading the content of the modified storage area in the shared file into a temporary memory according to the synchronization message; A comparison module, used for comparing the content in the temporary memory with the content in the memory mapping corresponding to the database instance to obtain a comparison result; A synchronization module, configured to update the memory mapping of the database instance according to the content of the difference to achieve synchronization if the comparison result shows that there is a difference; The synchronization device also includes: A modification statement module, used for obtaining a modification execution statement when the database instance represents the execution instance; A modification module, used to modify the memory mapping of the database instance according to the modification execution statement, and persist the modification to the shared file; A first message sending module, configured to generate the synchronization message according to the modified execution statement, and send the synchronization message to the database instance characterized as the receiving instance; The first message sending module includes: A modification type identification unit, used to determine the modification type according to the modification execution statement; A synchronization message generating unit, configured to generate the synchronization message according to the modification type; The reloading module comprises: A modification type determining unit, configured to determine a corresponding modification type according to the synchronization message; a storage area determination unit, configured to determine, in the shared file, a storage area where the modification has occurred, according to the modification type; The reloading unit is used to reload the content of the storage area into the temporary memory.

6. A computer device, characterized in that: The computer device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the synchronization method according to any one of claims 1 to 4 when executing the computer program.

7. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the synchronization method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Data caching method and device, computer equipment and readable storage medium

    CN113722401A

  • Database table synchronization method and device, equipment, storage medium and program product

    CN118467641A