Data processing method of database cluster, storage medium and equipment

By introducing synchronous standby configuration parameters using the DYNAMIC syntax, the number of synchronous standby databases can be automatically identified and adjusted, solving the synchronization problem when the database cluster dynamically expands and shrinks standby databases, improving the system's automation level, and ensuring the stability of primary database writes.

CN116303787BActive Publication Date: 2026-04-17CETC JINCANG (BEIJING) TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CETC JINCANG (BEIJING) TECH CO LTD
Filing Date
2023-03-15
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

The existing database cluster has issues with the configuration of the synchronous standby database, such as not supporting dynamic expansion and contraction, not being able to automatically adjust when the status of the synchronous standby database changes, and not being able to automatically identify the recovered synchronous standby database as a synchronous standby database, which causes the primary database to be stuck in the write process.

Method used

The system introduces DYNAMIC syntax for configuring synchronous standby databases. By acquiring standby database connection signals, parsing configuration parameters, and matching application names, it automatically identifies synchronous standby databases and dynamically adjusts the number of synchronous standby databases in dynamic synchronization mode to achieve data synchronization between the primary and standby databases.

Benefits of technology

It enables the database cluster to automatically identify the status of the synchronization standby database in dynamic synchronization mode, supports the dynamic expansion and reduction of the standby database, avoids the problem of writes getting stuck in the primary database, and improves the automation level of the database system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116303787B_ABST
    Figure CN116303787B_ABST
Patent Text Reader

Abstract

This invention provides a data processing method, storage medium, and device for a database cluster. The data processing method includes: acquiring a signal indicating that a standby database is connecting to the primary database; reading the synchronization standby database configuration parameters; acquiring the application name of the standby database; matching the application name with the synchronization standby database name in the synchronization standby database configuration parameters; determining whether the standby database is a synchronization standby database based on the matching result; if so, determining whether the database cluster is in dynamic synchronization mode based on the synchronization standby database configuration parameters; when in dynamic synchronization mode, modifying the number of synchronization standby databases in the synchronization standby database configuration parameters; and synchronizing data between the primary and standby databases. This invention's database cluster data synchronization method can automatically identify the status of synchronization standby databases and calculate the number of currently active synchronization standby databases, without requiring adjustments to configuration parameters to adjust the number of synchronization standby databases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of databases, and in particular to a data processing method, storage medium, and device for a database cluster. Background Technology

[0002] Currently, database systems can configure synchronous standby databases using the `synchronous_standby_names` parameter in GUC (Grand Unified Configuration). The configuration format is as follows:

[0003] [FIRST]num_sync(standby_name[,...])

[0004] ANY num_sync(standby_name[,...])

[0005] standby_name[,...]

[0006] Where num_sync is an integer greater than 0, representing the number of synchronous standby databases, and standby_name is the name of the standby database. If this name is consistent with the application_name declared when the standby database connects to the master database, then this standby database will be used as a synchronous standby database (or a candidate synchronous standby database). In addition, standby_name can be a wildcard *, which can match standby databases with any name.

[0007] With the above configuration parameters, the database cluster can be configured as a synchronous cluster. However, the synchronous configuration supported by the above database has the following problems: First, the number of synchronous standby databases, num_sync, needs to be explicitly specified, and the number of num_sync databases cannot be greater than the number of standby_name databases; Second, if standby_name is configured as a wildcard *, the number of standby databases cannot be determined through configuration; Third, if the number of synchronous standby databases needs to be increased or decreased during operation, the value of num_sync needs to be adjusted. If standby_name is not a configured wildcard, standby_name also needs to be added or deleted. Therefore, using the above configuration parameters, the cluster can achieve the following synchronization states: First, configure one or N fixed-number synchronous standby databases, for example: `synchronous_stnadby_names = 'FIRST 1(standby_1, standby_2)'`; Second, if the current synchronous standby database fails, other alternative standby databases in the configuration parameters automatically become synchronous standby databases. For example, in the above configuration, if standby_1 fails, standby_2 automatically becomes the synchronous standby database; Third, if the number of synchronous standby databases is less than the configured `num_sync`, the primary database writes will be blocked until the number of synchronous standby databases is sufficient and data synchronization is completed. For example, in the above configuration, if both standby_1 and standby_2 fail, the primary database writes will be blocked until either standby_1 or standby_2 recovers and data synchronization is completed.

[0008] Existing technical solutions have several problems: First, they do not support dynamically expanding or shrinking the configuration of synchronous standby databases. For example, if there are currently 3 standby databases in the cluster, the number of standby databases may be expanded or reduced in the future, and a standard configuration scheme cannot be provided. Second, after configuring all standby databases to be synchronous standby databases, if the status of the synchronous standby database changes (failure), it cannot automatically identify and adjust the synchronization function, causing the primary database to be stuck in writes. Third, after a failed standby database recovers, it cannot be automatically identified and automatically turned into a synchronous standby database. Summary of the Invention

[0009] One object of the present invention is to provide a data processing method, storage medium and device for database clusters that can solve the above-mentioned problems.

[0010] A further objective of this invention is to improve the automation level of database systems.

[0011] Specifically, the present invention provides a data synchronization method for a database cluster, the data synchronization method for the database cluster comprising:

[0012] Receive the signal for the standby database to connect to the primary database;

[0013] Read the configuration parameters of the synchronous backup database;

[0014] Get the application name of the backup database;

[0015] Match the application name with the synchronous backup database name in the synchronous backup database configuration parameters;

[0016] Determine whether the backup database is a synchronous backup database based on the matching results;

[0017] If so, determine whether the database cluster is in dynamic synchronization mode based on the configuration parameters of the synchronization standby database;

[0018] When in dynamic synchronization mode, modify the number of synchronous backup databases in the synchronous backup database configuration parameters.

[0019] Data synchronization is performed between the primary and standby databases.

[0020] Furthermore, the steps to determine whether the database cluster is in dynamic synchronization mode include:

[0021] Parse the configuration parameters of the synchronous backup database;

[0022] Attempt to identify the target syntax;

[0023] Upon identifying the target syntax, it is determined that the database cluster is in dynamic synchronization mode.

[0024] Furthermore, after the primary and standby databases synchronize data, the process also includes:

[0025] Received an abnormal signal during the backup database synchronization process;

[0026] The master database's data sending process determines whether it is in dynamic synchronization mode;

[0027] When in dynamic synchronization mode, determine whether the data sending process is a synchronous sending process;

[0028] If the data sending process is a synchronous sending process, determine whether the database cluster is in an abnormal state;

[0029] If the data sending process exits normally and the database cluster is running normally, modify the number of synchronous standby databases in the synchronous standby database configuration parameters.

[0030] Furthermore, data synchronization between the primary and standby databases includes:

[0031] The background process of the standby database ends and commits the currently executing transaction;

[0032] Determine if the sequence number of the currently executing transaction is less than or equal to the smallest sequence number of the synchronized transactions;

[0033] If so, the current transaction has been synchronized to all standby databases within the database cluster.

[0034] Furthermore, if the data sequence number of the current transaction being executed by the background process is greater than the minimum data sequence number of the synchronized transaction, determine whether the current number of synchronized backup databases is zero.

[0035] If not, write the process ID of the background process and the sequence number of the data that needs to wait for the transaction to finish into the wait queue in shared memory, and set the synchronization status of the background process to wait for synchronization.

[0036] Determine whether the synchronization status of the background process is complete.

[0037] If so, then the current transaction has been synchronized.

[0038] Furthermore, if the background process is in a state of incomplete synchronization, the background process will sleep for a preset time.

[0039] Determine if the current number of synchronized backup databases is zero;

[0040] If so, the synchronization status of the background process is set to complete synchronization, and the background process is removed from the waiting queue.

[0041] Furthermore, if the background process is in a state of incomplete synchronization, the background process continues to wait until the data sending process wakes it up.

[0042] Furthermore, the steps for the data sending process to wake up the background process include:

[0043] Acquire the data transmission signal;

[0044] Send data to the backup database;

[0045] Attempt to obtain the return information from the standby database, which includes the sequence number of the data received by the standby database;

[0046] If the return information is successfully obtained, determine whether the data sending process is a synchronous sending process;

[0047] If so, retrieve the sequence numbers of the synchronized data from all synchronous sending processes in the shared memory;

[0048] Sort the sequence numbers of the synchronized data from all synchronous sending processes and store them in a preset array;

[0049] Get the number of synchronized backup databases;

[0050] Get the value at the corresponding position in the preset array and record it as the minimum data index;

[0051] Iterate through the waiting sequence, wake up background processes whose waiting sequence number is less than or equal to the minimum data sequence number, and remove them from the waiting sequence.

[0052] According to another aspect of the present invention, a machine-readable storage medium is also provided, on which a machine-executable program is stored, which, when executed by a processor, implements any of the above-described data synchronization methods for database clusters.

[0053] According to another aspect of the present invention, a computer device is also provided, including a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein the processor executes the machine-executable program to implement any of the above-described data synchronization methods for a database cluster.

[0054] The data synchronization method for a database cluster of the present invention includes: acquiring a signal indicating that a standby database is connecting to a primary database; reading configuration parameters of the standby database; acquiring the application name of the standby database; matching the application name with the name of the standby database in the configuration parameters; determining whether the standby database is a standby database based on the matching result; if so, determining whether the database cluster is in dynamic synchronization mode based on the configuration parameters; when in dynamic synchronization mode, modifying the number of standby databases in the configuration parameters; and synchronizing data between the primary database and the standby database. The data synchronization method for a database cluster of the present invention can automatically identify the status of the standby database and calculate the number of currently active standby databases, without requiring adjustments to configuration parameters to adjust the number of standby databases.

[0055] The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments of the invention in conjunction with the accompanying drawings. Attached Figure Description

[0056] The following sections will describe some specific embodiments of the invention in detail by way of example and not limitation, with reference to the accompanying drawings. The same reference numerals in the drawings denote the same or similar parts or portions. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:

[0057] Figure 1 This is a flowchart illustrating the steps of a database cluster data synchronization method according to an embodiment of the present invention;

[0058] Figure 2 This is a flowchart illustrating the steps of a database cluster data synchronization method according to another embodiment of the present invention;

[0059] Figure 3 This is a flowchart illustrating the steps of a database cluster data synchronization method according to yet another embodiment of the present invention;

[0060] Figure 4 This is a schematic diagram of the data flow in the data synchronization process of a database cluster data synchronization method according to another embodiment of the present invention;

[0061] Figure 5 This is a flowchart illustrating the steps of a database cluster data synchronization method according to yet another embodiment of the present invention;

[0062] Figure 6 This is a flowchart illustrating the steps of a database cluster data synchronization method according to yet another embodiment of the present invention;

[0063] Figure 7 This is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention; and

[0064] Figure 8 This is a schematic diagram of a computer device according to an embodiment of the present invention. Detailed Implementation

[0065] Figure 1 This is a flowchart illustrating the steps of a data synchronization method for a database cluster according to an embodiment of the present invention. The database cluster in this embodiment includes at least one primary database and at least one standby database. The primary database (master database) refers to a state of the database system, generally referring to a database instance in the primary-standby cluster that provides full read / write services. The standby database (standby database) refers to a state of the database system, generally referring to a database instance in the primary-standby cluster that provides read-only services. Synchronous mode refers to a data synchronization mode where, after data changes in the primary database, it needs to be sent to the standby database via data synchronization. The primary database waits for the standby database to send its own changes and maintain consistency with the primary database before the data change is complete and a success message is returned to the application. The data in the primary and standby databases is consistent at all times. Asynchronous mode refers to a data synchronization mode that differs from synchronous mode. In this mode, after data changes are sent to the primary database, a success message is immediately returned to the application, and the data in the standby database is synchronized subsequently. The data in the primary and standby databases may not be consistent at all times, but they will ultimately remain consistent. A synchronous standby database refers to a standby database in synchronous mode. An asynchronous standby database refers to a standby database in asynchronous mode.

[0066] This embodiment of the database cluster data synchronization method adds a new configuration syntax for the synchronous standby database configuration parameter (synchronous_standby_names): DYNAMIC(standby_name[,...]). In the new DYNAMIC syntax, num_sync is not configured; all names entered by the user subsequently belong to the synchronous standby databases, and the number of synchronous standby databases is automatically calculated based on their status. When each standby database connects to the master database, the master database starts a data sending process to synchronize data with that standby database. In DYNAMIC mode, the number of synchronous standby databases, sync_standby_num, is calculated by the sending process. For example... Figure 1 As shown, the data synchronization method for the database cluster in this embodiment includes:

[0067] Step S102: Obtain the signal for the standby database to connect to the primary database.

[0068] Step S104: Read the synchronous standby database configuration parameter synchronous_standby_names.

[0069] Step S106: Obtain the application name app_name from the backup database.

[0070] Step S108: Match the application name app_name with the synchronous standby name standby_name in the synchronous standby configuration parameter synchronous_standby_names.

[0071] Step S110: Determine whether the standby database is a synchronous standby database based on the matching result. If the application name app_name is equal to any synchronous standby database name standby_name in the synchronous standby database configuration parameter synchronizeous_standby_name, or if the synchronous standby database standby_name is a wildcard *, then this standby database is confirmed as a synchronous standby database, the data sending process is a synchronous sending process, and step S112 is executed. Otherwise, this standby database is determined to be an asynchronous standby database, and the data sending process is an asynchronous sending process.

[0072] Step S112: Determine whether the database cluster is in dynamic synchronization (DYNAMIC) mode based on the configuration parameters of the synchronization standby database. If yes, proceed to step S114. If no, do nothing.

[0073] Step S114: When in dynamic synchronization (DYNAMIC) mode, modify the number of synchronous standby databases in the synchronous standby database configuration parameters, sync_standby_num, and increase the number of synchronous standby databases by one.

[0074] Step S116: The data sending process enters the sending flow, and the primary database and the backup database synchronize data.

[0075] Figure 2 This is a flowchart illustrating the steps of a database cluster data synchronization method according to another embodiment of the present invention. The step of determining whether the database cluster is in dynamic synchronization mode in the data synchronization method of this embodiment includes:

[0076] Step S202 involves parsing the synchronous standby database configuration parameter `synchronous_standby_name`. In other words, this involves performing lexical and syntactic analysis on `synchronous_standby_name`.

[0077] Step S204: Attempt to identify the target grammar. The target grammar is DYNAMIC grammar.

[0078] Step S206: Upon identifying the target syntax, determine that the database cluster is in dynamic synchronization mode. That is, upon identifying DYNAMIC syntax, set the synchronization method `sync_method` to DYNAMIC and the number of standby databases `sync_standby_num` to 0.

[0079] Figure 3 This is a flowchart illustrating the steps of a database cluster data synchronization method according to another embodiment of the present invention. In this embodiment, synchronization may be interrupted if the database cluster is shut down or the backup database connection is lost; in this case, the data sending process will enter an exit process. Figure 3 As shown, the data synchronization method for a database cluster in this embodiment further includes the following steps after the primary database and the backup database perform data synchronization:

[0080] Step S302: Obtain an abnormal signal during the standby database synchronization process. This abnormal signal may be due to database shutdown, standby database connection loss, etc.

[0081] In step S304, the master database's data sending process determines whether it is in dynamic synchronization mode. If yes, proceed to step S306. If not, the data sending process exits directly.

[0082] Step S306: Determine whether the data sending process is a synchronous sending process. If yes, proceed to step S308. If no, the data sending process exits directly.

[0083] Step S308: Determine if the database cluster is in an abnormal state. This abnormal state may include a parent process that has died, a crash recovery state, or an abnormal shutdown state. If not, proceed to step S310. If so, the data sending process exits directly.

[0084] Step S310: If the data sending process exits normally and the database cluster is in normal operation, modify the synchronous standby database configuration parameters to reduce the synchronous standby database number by one.

[0085] Figure 4 This is a schematic diagram illustrating the data flow in the data synchronization process of a database cluster data synchronization method according to another embodiment of the present invention. Changes in the number of standby databases (sync_standby_num) will affect the data synchronization process. For example... Figure 4 As shown, the data synchronization process is a multi-process collaborative process. Each session connection of the customer's business is associated with a background process that handles the business logic of that session. In synchronization mode, the background process waits for data to be sent to the synchronization standby database before it can commit and continue executing the next business logic. Synchronization is performed by the data sending process between the primary and standby databases. Each surviving standby database has a corresponding data sending process, which is responsible for calculating whether all synchronization standby databases have been synchronized and waking up the corresponding background process.

[0086] Figure 5 This is a flowchart illustrating the steps of a database cluster data synchronization method according to another embodiment of the present invention. Figure 5 As shown, the data synchronization method for a database cluster in this embodiment includes the following steps for synchronizing data between the primary and standby databases:

[0087] In step S402, the backup database's background process ends and commits the currently executing transaction. The database background process (backend) corresponding to the application's business logic enters DYNAMIC synchronization mode when a transaction ends and is committed. In some embodiments, it can also be FIRST or ANY synchronization mode.

[0088] Step S404: Determine whether the data sequence number X1 of the currently executing transaction is less than or equal to the smallest data sequence number of the synchronized transactions. If yes, proceed to step S406. If no, proceed to step S408.

[0089] Step S406: The current transaction has been synchronized to all standby databases within the database cluster.

[0090] Step S408: Determine if the current number of standby databases (sync_standby_num) is zero. If yes, confirm that synchronization is complete and the transaction has been successfully committed. If not, proceed to step S410.

[0091] Step S410: Write the process number P1 of the background process and the data sequence number X1 that needs to wait for the transaction to end into the shared memory wait queue, and set the synchronization state sync_state of the background process to wait for synchronization WAIT.

[0092] Step S412: Determine if the synchronization status of the background process is COMPLETE. If yes, proceed to step S414. If no, proceed to step S416.

[0093] Step S414: The current transaction has been synchronized.

[0094] Step S416: Preset sleep time for the background process. The preset sleep time can be set to 300ms to 600ms, preferably 500ms.

[0095] Step S418: Determine if the current number of standby databases (sync_standby_num) is zero. If it is zero, it means there are currently no standby databases, and therefore no synchronization process to wake up the background process.

[0096] Step S420: Set the synchronization state sync_state of the background process to complete synchronization and remove the background process from the waiting queue.

[0097] Continuously check the synchronization status of the background process to see if synchronization is complete, until synchronization is complete.

[0098] In some embodiments, after step S412, if the background process is in a state of incomplete synchronization, the background process continues to wait until the data sending process wakes up the background process.

[0099] Figure 6 This is a flowchart illustrating the steps of a database cluster data synchronization method according to another embodiment of the present invention. Figure 6 As shown, the step of waking up the background process in the data synchronization method of the database cluster in this embodiment includes:

[0100] Step S502: Obtain a data transmission signal. In some embodiments, step S502 includes determining whether there is data to be transmitted; if so, determining to continue transmitting data.

[0101] Step S504: Send data to the backup database.

[0102] Step S506: Attempt to obtain the return information from the standby database. The return information may include the data sequence number Y that the standby database has accepted. If the return information from the standby database is successfully obtained, proceed to step S508.

[0103] Step S508: Determine whether the data sending process is a synchronous sending process. If yes, proceed to step S510. If no, return to step S502.

[0104] Step S510: Obtain the synchronized data sequence number Y value (Ym, Ym+1, ..., Yn) of all synchronous sending processes in the shared memory.

[0105] Step S512: Sort the synchronized data sequence numbers of the synchronous sending process and store them in a preset array. That is, arrange the synchronized data sequence numbers Y values ​​Ym, Ym+1, ..., Yn recorded by the synchronous sending process in descending order and store them in the data Y_List.

[0106] Step S514: Obtain the value of the number of synchronous standby databases, sync_standby_num.

[0107] Step S516: Obtain the value at the corresponding position in the preset array and record it as the minimum data sequence number. That is, obtain the value of the sync_standby_num-th position in the array Y_List. In DYNAMIC mode, the number of synchronous sending processes is equal to the value of sync_standby_num, so it is actually equivalent to obtaining the last position (the smallest value after sorting) in the Y_List array and recording the value as Ymin in the shared memory.

[0108] Step S518: Traverse the waiting sequence, wake up the background processes in the waiting sequence whose waiting sequence number X is less than or equal to the minimum data sequence number Ymin, set the background process synchronization state sync_state to COMPLETE, and remove it from the waiting sequence.

[0109] This embodiment adds the `DYNAMIC(standby_name[,..])` syntax to the database cluster data synchronization method, supporting DYNAMIC synchronization mode. Configuration methods are provided to support scenarios where standby databases are dynamically expanded or reduced. For example: `synchronous_standby_names = 'DYNAMIC(*)'`. DYNAMIC synchronization mode is an intermediate mode between asynchronous and synchronous modes. When a synchronous standby database fails to connect to the primary database, it functions as asynchronous mode; when a synchronous standby database is connected to the primary database, it functions as synchronous mode. In DYNAMIC synchronization mode, the system can automatically identify the status of synchronous standby databases and calculate the number of currently active synchronous standby databases based on the syntax configuration and the current synchronization status of the standby databases, without needing to adjust configuration parameters to adjust the number of synchronous standby databases.

[0110] This embodiment also provides a machine-readable storage medium and a computer device. Figure 7 This is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention. Figure 8 This is a schematic diagram of a computer device according to an embodiment of the present invention.

[0111] The machine-readable storage medium 40 stores a machine-executable program 41 thereon, which, when executed by a processor, implements the data synchronization method of the database cluster in any of the above embodiments.

[0112] Computer device 50 may include memory 520, processor 510, and machine-executable program 41 stored on memory 520 and running on processor 510. When processor 510 executes machine-executable program 41, it implements the data synchronization method of database cluster of any of the above embodiments.

[0113] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-based system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).

[0114] For the purposes of this embodiment, the machine-readable storage medium 40 can be any means capable of containing, storing, communicating, propagating, or transmitting a program for use by or in conjunction with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, the computer-readable medium 40 can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0115] It should be understood that various parts of the present invention can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system.

[0116] Computer device 50 can be, for example, a server, desktop computer, laptop computer, tablet computer, or smartphone. In some examples, computer device 50 can be a cloud computing node. Computer device 50 can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., that perform specific tasks or implement specific abstract data types. Computer device 50 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can reside on local or remote computing system storage media, including storage devices.

[0117] Computer device 50 may include a processor 510 adapted to execute stored instructions and a memory 520 that provides temporary storage space for the operation of said instructions during operation. Processor 510 may be a single-core processor, a multi-core processor, a computing cluster, or any other configuration. Memory 520 may include random access memory (RAM), read-only memory, flash memory, or any other suitable storage system.

[0118] The processor 510 can also be linked via a system interconnect to a display interface suitable for connecting the computer device 50 to a display device. The display device may include a display screen that is a built-in component of the computer device 50. The display device may also include an external computer monitor, television, or projector connected to the computer device 50. Furthermore, a network interface controller (NIC) may be adapted to connect the computer device 50 to a network via a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as an Internet Minicomputer System Interface) to transmit data. The network may be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, etc. Remote devices can connect to the computing device via the network.

[0119] The flowcharts provided in this embodiment are not intended to indicate that the operations of the method will be performed in any particular order, or that all operations of the method are included in every case. Furthermore, the method may include additional operations. Within the scope of the technical concept provided by the method in this embodiment, additional variations can be made to the above method.

[0120] Therefore, those skilled in the art should recognize that although numerous exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications conforming to the principles of the present invention can be directly determined or derived from the disclosure of the present invention without departing from the spirit and scope of the invention. Thus, the scope of the present invention should be understood and construed as covering all such other variations or modifications.

Claims

1. A data synchronization method for a database cluster, comprising: Receive the signal for the standby database to connect to the primary database; Read the configuration parameters of the synchronous backup database; Obtain the application name of the backup database; Match the application name with the synchronous backup database name in the synchronous backup database configuration parameters; Determine whether the backup database is a synchronous backup database based on the matching results; If so, determine whether the database cluster is in dynamic synchronization mode based on the synchronous backup database configuration parameters; When in the dynamic synchronization mode, modify the number of synchronization backup databases in the synchronization backup database configuration parameters; The primary database and the backup database synchronize data. The step of determining whether the database cluster is in dynamic synchronization mode includes: The configuration parameters of the synchronous backup database are parsed. Attempt to identify the target syntax; Upon recognition of the target syntax, it is determined that the database cluster is in the dynamic synchronization mode.

2. The data synchronization method for a database cluster according to claim 1, wherein, Following the step of synchronizing data between the primary database and the backup database, the following is also included: An abnormal signal was obtained during the backup database synchronization process; The data sending process of the master database determines whether it is in the dynamic synchronization mode. When in the dynamic synchronization mode, determine whether the data sending process is a synchronous sending process; If the data sending process is a synchronous sending process, determine whether the database cluster is in an abnormal state; If the abnormal state is not present, the data sending process exits normally, and the database cluster is in normal operation, then modify the number of synchronous backup databases in the synchronous backup database configuration parameters.

3. The data synchronization method for a database cluster according to claim 2, wherein, The data synchronization between the primary database and the backup database includes: The background process of the backup database ends and commits the currently executing transaction; Determine whether the data sequence number of the currently executing transaction is less than or equal to the minimum data sequence number of the synchronized transactions; If so, the current transaction has been synchronized to all standby databases within the database cluster.

4. The data synchronization method for a database cluster according to claim 3, wherein, If the data sequence number of the current transaction being executed by the background process is greater than the minimum data sequence number of the synchronized transactions, determine whether the current number of synchronized backup databases is zero. If not, the process ID of the background process and the sequence number of the data that needs to wait for the transaction to end are written into the waiting queue of the shared memory, and the synchronization status of the background process is set to waiting for synchronization. Determine whether the synchronization status of the background process is complete. If so, then the current transaction has been synchronized.

5. The data synchronization method for a database cluster according to claim 4, wherein, If the background process is in a state of incomplete synchronization, the background process will sleep for a preset time. Determine if the current number of synchronized backup databases is zero; If so, the synchronization status of the background process is set to complete synchronization, and the background process is removed from the waiting queue.

6. The data synchronization method for a database cluster according to claim 4, wherein, If the background process is in a state of incomplete synchronization, the background process continues to wait until the data sending process wakes it up.

7. The data synchronization method for a database cluster according to claim 6, wherein, The steps of waking up the background process during the data transmission process include: Acquire the data transmission signal; Send data to the backup database; Attempt to obtain the return information from the backup database, the return information including the data sequence number received by the backup database; If the returned information is successfully obtained, it is determined whether the data sending process is a synchronous sending process; If so, obtain the synchronized data sequence numbers of all synchronous sending processes in the shared memory; Sort the synchronized data sequence numbers of all the synchronous sending processes and store them in a preset array; Obtain the value of the number of synchronized backup databases; Obtain the value located at the corresponding position of the numerical value in the preset array, and record it as the minimum data sequence number; Traverse the waiting sequence, wake up background processes whose waiting sequence number is less than or equal to the minimum value of the data sequence number, and delete them from the waiting sequence.

8. A machine-readable storage medium having a machine-executable program stored thereon, the machine-executable program, when executed by a processor, implementing the data synchronization method for a database cluster according to any one of claims 1 to 7.

9. A computer device comprising a memory, a processor, and a machine-executable program stored in the memory and running on the processor, wherein the processor, when executing the machine-executable program, implements the data synchronization method for a database cluster according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data synchronization method and system, synchronous acquisition method and related device

    CN106302806A

  • Log synchronization method and device, equipment and storage medium

    CN113239120A