Double-master-control configuration data synchronization method based on sonic system

By first writing to the ASIC_DB database in the Sonic system and confirming that the service single disk configuration is successful, then synchronizing the main and backup data, the data error diffusion problem caused by the synchronization of the traditional redis database is solved, and more efficient and accurate data synchronization is achieved, improving the stability and reliability of the system.

CN120407683APending Publication Date: 2025-08-01WUHAN ACCELINK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510521239.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-24
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

Using the traditional redis database master-slave synchronization mechanism in Sonic systems may cause data errors to spread, affecting the overall performance of the system.

Method used

The configuration command is first written to the ASIC_DB database of the main control, and then the SAI_API function is called to issue the underlying configuration to the business single disk. Only after confirming that the business single disk is configured successfully will the backup master be notified to synchronize the main data through the message synchronization mechanism to ensure the accuracy and consistency of the data.

Benefits of technology

It avoids invalid and incorrect data synchronization, improves the accuracy and efficiency of data synchronization, and improves the stability and reliability of Sonic system in dual-main configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407683A_ABST
    Figure CN120407683A_ABST
Patent Text Reader

Abstract

The invention provides a method for configuring data synchronization based on double master controllers of a sonic system. The method comprises the following steps: S1, writing an issued configuration command into a CONFIGDB database of a master controller; s2, writing the configuration command into an ASICDB database by an SWSS module of the main master controller, and notifying an SYNCD module; s3, the SYNCD module issues underlying configuration to a service single disk; s4, if a configuration failure message is received, executing S5, otherwise, executing S6; s5, the configuration of the CONFIGDB database is rolled back to the previous configuration, and the step S3 and the step S4 are executed repeatedly; and S6, the standby master controller carries out data synchronization. According to the scheme, the database is written firstly, then the underlying configuration is issued to the service single disk, and the main and standby data synchronization is performed only after the successful configuration of the service single disk is confirmed, so that the stability and the reliability of the Sonic system under the dual-main-control configuration are effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technologies, and in particular to a method for synchronizing dual-master configuration data based on a Sonic system. Background Art

[0002] In order to improve the stability and fault tolerance of the Sonic system, implementing dual-master configuration synchronization is one of the key technologies. However, although the master-slave synchronization mechanism of the traditional redis database is simple and efficient, due to its synchronization method based on data changes, it cannot avoid the propagation of incorrect data. For a system like Sonic that has high requirements for data accuracy and consistency, directly using this mechanism may cause the spread of data errors, thereby affecting the overall performance of the system. Therefore, when using the redis database master-slave synchronization in the Sonic system, an additional mechanism is needed to ensure the correctness and consistency of the data. Through a set of master-backup redis message mechanisms, the correct real-time synchronization of the master-backup redis databases is ensured. Summary of the Invention

[0003] Based on the problems existing in the above-mentioned prior art, the present invention aims to solve the technical problem that when using the redis database to implement dual-master configuration synchronization in the Sonic system in the prior art, it will cause the spread of data errors, thereby affecting the overall performance of the system.

[0004] The present invention provides a method for synchronizing dual-master configuration data based on a Sonic system, which includes the following steps:

[0005] Step S1: The configuration interface of the SONIC system issues a configuration command, and synchronously writes the issued configuration command into the CONFIG_DB database of the active master REDIS database;

[0006] Step S2: The SWSS module of the active master monitors the process in real time. When it detects a change in the CONFIG_DB database of the active master, it writes the configuration command into the ASIC_DB database of the active master and notifies the SYNCD module of the active master;

[0007] Step S3: After the SYNCD module of the active master monitors the message of the change in the ASIC_DB database, it calls the SAI_API function to issue the underlying configuration to the service single board, and the service single board returns a message indicating whether the configuration is successful or failed to the SYNCD module;

[0008] Step S4: The SWSS module of the active master waits for the feedback message of the SYNCD module with a timeout. If it receives a configuration failure message, it executes Step S5; if it receives a configuration success message, it executes Step S6;

[0009] Step S5: The SWSS module of the primary master rolls back the configuration of the CONFIG_DB database to the previous configuration, writes the previous configuration data to the ASIC_DB database at the same time, and notifies the SYNCD module, then repeats steps S3 and S4;

[0010] Step S6: The standby master performs data synchronization.

[0011] According to an embodiment of the present invention, in step S2, when the SWSS module of the primary master monitors the process in real time, it adopts a database listening mechanism. When it detects that the CONFIG_DB database of the primary master has changed, it notifies the SYNCD module of the primary master of the change message through a message queue.

[0012] According to an embodiment of the present invention, in step S3, after the SYNCD module of the primary master monitors the message of the change in the ASIC_DB database, it calls the SAI_API function to send the underlying configuration to the service single board, which specifically includes the following steps:

[0013] After the SYNCD module of the primary master monitors the message of the change in the ASIC_DB database, it parses the configuration content according to the received message, constructs parameters that conform to the SAI interface specification, and calls the corresponding SAI_API function.

[0014] According to an embodiment of the present invention, in step S3, the SYNCD module obtains the status information after the execution of the SAI interface through a callback function or an asynchronous message mechanism.

[0015] According to an embodiment of the present invention, in step S4, the SWSS module of the primary master waits for the feedback message of the SYNCD module with a timeout, including the following steps:

[0016] The SWSS module sets a timeout to wait for the feedback message of the SYNCD module. If no message is received after the timeout, error handling is performed.

[0017] According to an embodiment of the present invention, in step S5, when the SWSS module of the primary master rolls back the configuration of the CONFIG_DB database to the previous configuration, it includes the following steps:

[0018] The SWSS module of the primary master reads the recorded previous configuration value and rewrites the previous configuration to the CONFIG_DB database of the primary master. ]

[0019] According to an embodiment of the present invention, in step S6, when the standby master performs data synchronization, it specifically includes:

[0020] The SWSS module of the primary master writes this configuration into the CONFIG_DB database of the standby master's REDIS database based on the message synchronization notification mechanism, and the SWSS module of the standby master monitors the process in real time;

[0021] When the SWSS module of the standby master detects a change in the CONFIG_DB database of the standby master, it writes the configuration into the ASIC_DB database of the standby master;

[0022] After the SYNCD module of the standby master monitors the message of the change in the ASIC_DB database, it calls the SAI_API function of the standby master, and the SAI_API function directly returns success without further issuing it to the service single board.

[0023] According to an embodiment of the present invention, in the message synchronization notification mechanism, a message consists of a message id and a message content.

[0024] According to an embodiment of the present invention, the message id is generated by combining a timestamp with a random number to ensure uniqueness, and the message content is the FIELD-VALUE value of the TABLE|KEY corresponding to the configuration data.

[0025] According to an embodiment of the present invention, the SWSS module of the primary master writes this configuration into the CONFIG_DB database of the standby master's REDIS database based on the message synchronization notification mechanism, which specifically includes:

[0026] The primary master publishes the message to a specified channel through the Redis client. After the subscription module of the standby master's redis database receives the message, it first performs a uniqueness verification of the message based on the message id to prevent duplicate processing; then, it parses the message content and accurately synchronizes the KEY-VALUE values of multiple tables therein into the database of the standby master according to the database table structure.

[0027] A method for synchronizing dual-master configuration data based on the sonic system provided by the present invention has the following beneficial effects:

[0028] This solution first writes to the ASIC_DB database of the primary master control, and then calls the SAI_API function to send the underlying configuration to the service single disk. Only after confirming the successful configuration of the service single disk, it notifies the standby master control to perform primary and standby data synchronization based on the message synchronization mechanism. Compared with the traditional Redis primary and standby database synchronization, which only synchronizes based on the changes in the database itself without considering data validity, this solution avoids the system operation risks brought by the synchronization of invalid data, greatly improving the accuracy and efficiency of data synchronization; during the system operation, ensuring the accurate synchronization of configuration data is the key to maintaining the normal operation of the system. This solution effectively improves the stability and reliability of the Sonic system under the dual-master control configuration by avoiding incorrect synchronization, and has strong scenario adaptability and pertinence. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0030] Figure 1 It is a flowchart of a method for synchronizing configuration data based on the dual-master control of the sonic system provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0031] The following descriptions of the embodiments refer to the accompanying drawings to illustrate specific embodiments in which the present invention can be implemented.

[0032] The present invention provides a method for synchronizing configuration data based on the dual-master control of the sonic system. In the Sonic system, after the primary master control receives the configuration data, it will monitor the database and send the data to the actual service single disk. If the service single disk returns a failure, the primary master control will roll back the configuration and resend the previous configuration; if successful, it will write to the standby master control database through redis messages to achieve the synchronization of the primary and standby redis databases. The specific method is as follows:

[0033] The process of the method for synchronizing configuration data based on the dual-master control of the sonic system is as Figure 1 shown. The method for synchronizing configuration data based on the dual-master control of the sonic system includes the following steps:

[0034] Step S1: The configuration interface of the SONIC system issues a configuration command and synchronously writes the issued configuration command to the CONFIG_DB database in the primary master control REDIS database.

[0035] The southbound RESTCONF or northbound CLI configuration interface of the SONIC system can establish a connection with the REDIS database of the active master control through the REDIS database operation interface, so that configuration commands can be written into the corresponding fields of the CONFIG_DB database of the active master control in a specific format. Specifically, the configuration command can be to set the IP address of a certain network interface, and the command format is set_interface_ip(interface_name, ip_address).

[0036] Step S2: The SWSS module of the active master control monitors the process in real time. When it detects that the CONFIG_DB database of the active master control has changed, it writes the configuration command into the ASIC_DB database of the active master control and notifies the SYNCD module of the active master control.

[0037] Specifically, the SWSS module can adopt a database listening mechanism. When it detects that the CONFIG_DB database of the active master control has changed, it writes the configuration command into the ASIC_DB database of the active master control and notifies the SYNCD module of the active master control of the change message through a message queue.

[0038] Step S3: After the SYNCD module of the active master control monitors the message that the ASIC_DB database has changed, it calls the SAI_API function (i.e., the SAI interface) to send the underlying configuration to the service single board, and the service single board returns a message indicating whether the configuration is successful or failed to the SYNCD module.

[0039] The SYNCD module of the active master control parses the configuration content according to the received message, constructs parameters that conform to the SAI interface specification, calls the corresponding SAI interface function, obtains the status information after the SAI interface is executed through a callback function or an asynchronous message mechanism, and sends the underlying configuration to the service single board.

[0040] Step S4: The SWSS module of the active master control waits for the feedback message from the SYNCD module with a timeout. If it receives a configuration failure message, it executes Step S5. If it receives a configuration success message, it executes Step S6.

[0041] The SWSS module sets a timeout to wait for the feedback message from the SYNCD module. If no message is received after the timeout, it performs error handling; if a message is received, it judges the configuration result feedback by the SYNCD module.

[0042] Step S5: The SWSS module of the active master control rolls back the configuration item of the CONFIG_DB database to the previous configuration, and at the same time writes the previous configuration data into the ASIC_DB database. After notifying the SYNCD module, it repeats Steps S3 and S4.

[0043] If the SYNCD module reports a failed configuration, the SWSS module reads the last configured value recorded, rewrites the last configuration to the CONFIG_DB database of the active master control board, and then repeats steps 3 and 4; the primary-secondary data synchronization is not required during this process.

[0044] Step S6: The standby master control board performs data synchronization.

[0045] The SWSS module of the active master control board writes this configuration to the CONFIG_DB database of the REDIS database of the standby master control board based on the message synchronization mechanism, and the SWSS module of the standby master control board monitors the process in real time; when the SWSS module of the standby master control board detects a change in the CONFIG_DB database of the standby master control board, it writes the configuration to the ASIC_DB database of the standby master control board; after the SYNCD module of the standby master control board monitors the message of the change in the ASIC_DB database, it calls the SAI_API function of the standby master control board, and the SAI_API function directly returns success without issuing it to the service single disk.

[0046] The message synchronization notification mechanism is as follows. The notification format consists of a message ID and a message content. The message ID can be generated by combining a timestamp with a random number to ensure uniqueness; the message content is the FILED-VALUE value of the TABLE|KEY corresponding to the configuration data, which constitutes the message content. The active master control board publishes the message to the specified channel through the Redis client. After the Redis database subscription module of the standby master control board receives the message, it first performs uniqueness verification of the message based on the message ID to prevent duplicate processing; then, it parses the message content and synchronizes the KEY-VALUE values of multiple tables in it to the database of the standby master control board accurately according to the database table structure.

[0047] In summary, a method for dual-master control configuration data synchronization based on the sonic system provided by the present invention first writes to the ASIC_DB database of the active master control board and then calls the SAI_API function to issue the underlying configuration to the service single disk. Only after confirming that the service single disk configuration is successful, it notifies the standby master control board to perform primary-secondary data synchronization based on the message synchronization mechanism. Compared with the traditional Redis primary-secondary database synchronization, which only synchronizes based on the changes in the database itself without considering the data validity, it will bring system operation risks due to the synchronization of invalid data. This solution avoids invalid and incorrect data synchronization and greatly improves the accuracy and efficiency of data synchronization; during the system operation, ensuring the accurate synchronization of configuration data is the key to maintaining the normal operation of the system. This solution effectively improves the stability and reliability of the Sonic system under dual-master control by avoiding incorrect synchronization, and has strong scenario adaptability and pertinence.

[0048] It should be noted that although the present invention is disclosed above by way of specific embodiments, the above embodiments are not intended to limit the present invention. Those of ordinary skill in the art can make various modifications and refinements without departing from the spirit and scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the scope defined by the claims.

Claims

1. A method for synchronizing dual-master configuration data based on the Sonic system, characterized in that, It includes the following steps: Step S1: The configuration interface of the SONIC system issues a configuration command and synchronously writes the issued configuration command into the CONFIG_DB database of the primary master REDIS database; Step S2: The SWSS module of the primary master monitors the process in real time. When it detects a change in the CONFIG_DB database of the primary master, it writes the configuration command into the ASIC_DB database of the primary master and notifies the SYNCD module of the primary master; Step S3: After the SYNCD module of the primary master monitors the message of the change in the ASIC_DB database, it calls the SAI_API function to issue the underlying configuration to the service single disk, and the service single disk returns a message indicating success or failure of the configuration to the SYNCD module; Step S4: The SWSS module of the primary master waits for the feedback message of the SYNCD module with a timeout. If it receives a configuration failure message, it executes Step S5; if it receives a configuration success message, it executes Step S6; Step S5: The SWSS module of the primary master rolls back the configuration of the CONFIG_DB database to the previous configuration, and at the same time writes the previous configuration data into the ASIC_DB database and notifies the SYNCD module, and repeats Steps S3 and S4; Step S6: The standby master performs data synchronization.

2. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 1, wherein In Step S2, when the SWSS module of the primary master monitors the process in real time, it uses a database listening mechanism. When it detects a change in the CONFIG_DB database of the primary master, it notifies the SYNCD module of the primary master of the change message through a message queue.

3. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 1, wherein, In Step S3, after the SYNCD module of the primary master monitors the message of the change in the ASIC_DB database, it calls the SAI_API function to issue the underlying configuration to the service single disk, which specifically includes the following steps: After the SYNCD module of the primary master monitors the message of the change in the ASIC_DB database, it parses the configuration content according to the received message, constructs parameters that conform to the SAI interface specification, and calls the SAI_API function.

4. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 1, wherein In Step S3, the SYNCD module obtains the status information after the execution of the SAI interface through a callback function or an asynchronous message mechanism.

5. The method according to claim 1, wherein In Step S4, the SWSS module of the primary master waits for the feedback message of the SYNCD module with a timeout, including the following steps: The SWSS module sets a timeout to wait for the feedback message of the SYNCD module. If no message is received after the timeout, error handling is performed.

6. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 1, wherein In Step S5, when the SWSS module of the primary master rolls back the configuration of the CONFIG_DB database to the previous configuration, it includes the following steps: The SWSS module of the primary master reads the recorded previous configuration value and rewrites the previous configuration into the CONFIG_DB database of the primary master.

7. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 1, wherein In Step S6, when the standby master performs data synchronization, it specifically includes: The SWSS module of the primary master writes this configuration into the CONFIG_DB database of the standby master REDIS database based on the message synchronization notification mechanism, and the SWSS module of the standby master monitors the process in real time; When the SWSS module of the standby master controller detects a change in the CONFIG_DB database of the standby master controller, the configuration is written to the ASIC_DB database of the standby master controller; After the SYNCD module of the standby master controller monitors the message of the change in the ASIC_DB database, it calls the SAI_API function of the standby master controller. The SAI_API function directly returns success and does not send it to the service single board.

8. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 7, wherein In the message synchronization notification mechanism, the message consists of a message ID and a message content.

9. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 8, wherein the message ID is generated in a manner combining a timestamp and a random number to ensure uniqueness; the message content is the FIELD-VALUE value of the TABLE|KEY corresponding to the configuration data.

10. The method for synchronizing dual-master configuration data based on the Sonic system according to claim 9, wherein the SWSS module of the active master controller writes the current configuration to the CONFIG_DB database of the standby master controller's REDIS database based on the message synchronization notification mechanism, specifically including: The active master controller publishes the message to a specified channel through the Redis client. After the subscription module of the standby master controller's redis database receives the message, it first performs uniqueness verification of the message according to the message ID to prevent duplicate processing; then, it parses the message content and accurately synchronizes the KEY-VALUE values of multiple tables therein to the database of the standby master controller according to the database table structure.