Database stream switching methods, devices, equipment, media, and program products
By employing distributed atomic locking, phased verification, and automated coordination of reverse synchronization links, the system resolves data inconsistencies and business interruptions caused by manual operations during database migration, achieving an efficient and reliable database migration process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INDUSTRIAL AND COMMERCIAL BANK OF CHINA
- Filing Date
- 2026-03-02
- Publication Date
- 2026-06-30
AI Technical Summary
During database migration, existing technologies rely on manual operation, leading to inconsistent verification benchmarks, making it difficult to control business continuity and data consistency, and posing a risk of traffic switching failure.
By employing distributed atomic locking operations, phased data consistency verification, and automated coordination of reverse synchronization links, data consistency between the source and target databases is ensured, and a reliable flow cutback and rollback guarantee mechanism is established.
It enables data consistency verification within a limited business tolerance window, significantly shortening business interruption time from hours to minutes or seconds, reducing rollback recovery time and the risk of data loss.
Smart Images

Figure CN122309478A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of cloud computing and big data technology, specifically to a database stream switching method, apparatus, device, medium, and program product. Background Technology
[0002] As enterprises deepen their digital transformation, database system upgrades, migrations, and replacements have become routine for updating information technology infrastructure. Database flow switching typically refers to the process of smoothly transferring business read and write requests from the source database to the target database by adjusting routing strategies or access points during database system maintenance, upgrades, or migrations. It is a key step in achieving seamless database uptime and downtime and system version iteration.
[0003] In critical sectors such as finance, telecommunications, and government, database migration not only involves the transfer of massive amounts of data but also faces severe challenges in ensuring business continuity and verifying data consistency. Currently, the verification and switching processes after database migration generally rely on manual operation, which is not only time-consuming but also involves uncontrollable time gaps between different stages. During this period, the source database may continuously generate incremental data, leading to inconsistencies in the verification baseline. Simultaneously, manual configuration errors and poor process coordination make it difficult to control the entire migration window within the business's tolerance range. In actual production environments, data discrepancies caused by inconsistent verification baselines and business recovery delays due to insufficient rollback mechanisms have become the main causes of database migration failures. Therefore, how to ensure the consistency of database migration verification baselines and establish a reliable migration rollback guarantee mechanism within a limited business tolerance window is a pressing technical challenge that needs to be addressed in this field. Summary of the Invention
[0004] In view of the above problems, embodiments of this application provide a database stream switching method, apparatus, device, medium, and program product.
[0005] According to a first aspect of this application, a database traffic switching method is provided, comprising: in response to receiving a database migration verification instruction, performing a distributed atomic locking operation on a target data object in the source database based on locking configuration parameters obtained from a configuration center; the locking configuration parameters include a list of business accounts to be locked and database connection information; in response to the target data object being locked, calling a data comparison service to perform data consistency verification between the source database and the target database based on data verification parameters obtained from the configuration center, the data consistency verification including comparison of the total number of records and comparison of data content; in response to the data consistency verification passing, calling the application programming interface of a data synchronization engine based on reverse synchronization parameters obtained from the configuration center to establish a data synchronization link from the target database to the source database to support business rollback; the reverse synchronization configuration parameters are used to define the data mapping relationship and synchronization rules between the source database and the target database; in response to the data synchronization link being established, releasing the lock on the target data object, and switching business traffic from the source database to the target database by updating application configuration or load balancing settings.
[0006] According to an embodiment of this application, performing a distributed atomic locking operation on a target data object in the source database includes: traversing multiple database instances of the source database based on locking configuration parameters; and performing a locking operation on the target data object through the native interface of each database instance to ensure that all target data objects are locked within the same time window.
[0007] According to embodiments of this application, performing a locking operation on a target data object through the native interface of each database instance includes: constructing a multi-threaded execution framework and allocating an independent execution thread to each database instance; coordinating each execution thread to trigger a locking command within the same time window through a unified clock synchronization mechanism; collecting the locking feedback status of each database instance in real time and generating a global locking completion signal; and triggering a rollback mechanism to release the target data object in other database instances that have been successfully locked when the locking operation of any database instance fails or times out.
[0008] According to an embodiment of this application, performing data consistency verification on the source database and the corresponding target database includes: obtaining row count comparison configuration parameters and content comparison configuration parameters from the data verification parameters; comparing the total number of records in the corresponding data tables in the source database and the target database based on the row count comparison configuration parameters; in response to the record count comparison passing, comparing the data content of preset key business tables based on the content comparison configuration parameters; and generating a data consistency verification result based on the record count comparison result and the data content comparison result.
[0009] According to an embodiment of this application, comparing the data content of a preset key business table includes: performing a full data comparison on key business tables with an importance level higher than a threshold based on a preset business importance level, and performing an adaptive sampling comparison based on the data change frequency on ordinary business tables with an importance level lower than the threshold.
[0010] According to an embodiment of this application, establishing a data synchronization link from the target database to the source database includes: accessing the management node through a secure connection based on reverse synchronization configuration parameters; on the management node, invoking the data synchronization engine to initialize the incremental data capture process and establishing a data synchronization link from the target database to the source database.
[0011] According to an embodiment of this application, the method further includes: in response to a failure of data consistency verification, maintaining the locked state of the target data object in the source database and triggering an abnormal alarm notification.
[0012] According to a second aspect of this application, a database traffic switching device is provided, comprising: an object locking module, configured to, in response to receiving a database migration verification instruction, perform a distributed atomic locking operation on a target data object in the source database based on locking configuration parameters obtained from a configuration center; the locking configuration parameters include a list of business accounts to be locked and database connection information; a data comparison module, configured to, in response to the target data object completing the locking, call a data comparison service to perform data consistency verification between the source database and the target database based on data verification parameters obtained from the configuration center, the data consistency verification including comparison of the total number of records and comparison of data content; a reverse synchronization module, configured to, in response to the data consistency verification passing, call the application programming interface of a data synchronization engine based on reverse synchronization parameters obtained from the configuration center to establish a data synchronization link from the target database to the source database to support business rollback; the reverse synchronization configuration parameters are used to define the data mapping relationship and synchronization rules between the source database and the target database; and a lock release module, configured to, in response to the completion of the data synchronization link establishment, release the lock on the target data object and switch business traffic from the source database to the target database by updating application configuration or load balancing settings.
[0013] According to a third aspect of this application, an electronic device is provided, comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.
[0014] According to a fourth aspect of this application, a computer-readable storage medium is also provided, on which a computer program or instructions are stored, wherein the computer program or instructions, when executed by a processor, implement the steps of the above-described method.
[0015] According to a fifth aspect of this application, a computer program product is also provided, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method. Attached Figure Description
[0016] The above-mentioned contents, other objects, features and advantages of this application will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0017] Figure 1 The illustrations depict application scenarios of database stream switching methods, apparatus, devices, media, and program products according to embodiments of this application.
[0018] Figure 2 A flowchart illustrating a database flow-switching method according to an embodiment of this application is shown schematically.
[0019] Figure 3 This illustration schematically shows a system architecture diagram for implementing a database stream switching method according to an embodiment of this application;
[0020] Figure 4 A schematic diagram illustrating a platform collaboration flowchart according to an embodiment of this application is shown.
[0021] Figure 5 This schematic diagram illustrates the structural block diagram of a database stream switching device according to an embodiment of the present application;
[0022] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a database stream switching method according to an embodiment of this application. Detailed Implementation
[0023] The embodiments of this application will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of this application. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of this application for ease of explanation. However, it will be apparent that one or more embodiments may be implemented without these specific details. Furthermore, descriptions of well-known structures and technologies are omitted in the following description to avoid unnecessarily obscuring the concepts of this application.
[0024] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of this application. The terms “comprising,” “including,” etc., as used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.
[0025] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0026] like Figure 1 As shown, the distributed system architecture 100 according to the embodiments of this application may include a migration control center 110 and multiple functional nodes N1 to N9.
[0027] The migration control center 110 serves as the central management unit of the entire system, receiving database migration verification instructions and coordinating the execution of corresponding migration verification tasks by various functional nodes. The migration control center 110 interacts with the functional node cluster 100 via a bidirectional communication link to achieve task scheduling, status monitoring, and process control.
[0028] The functional node cluster 100 consists of multiple functional nodes, specifically including: Source database instance group: containing nodes N1, N2, and N3, representing different instances or shards of the source database, used to store business data to be migrated; Target database instance group: containing nodes N4, N5, and N6, representing different instances or shards of the target database, used to receive migration data; Verification and control node N7: responsible for performing data consistency verification tasks, establishing communication with the source database instance group (N1-N3) and the target database instance group (N4-N6) through connection lines to achieve record count comparison and data content comparison; Synchronization management nodes N8 and N9: respectively responsible for maintaining the data synchronization link from the target database to the source database, where N8 is connected to N5 and N7, and N9 is connected to N6, forming an independent synchronization path.
[0029] In this architecture, all nodes collaborate to complete database migration-related tasks. Upon receiving a database migration verification command, the migration control center 110 first schedules the verification management node N7 to perform an atomic operation, locking the target data object in the source database instance group. Subsequently, the verification management node N7 compares the total number of records and the data content between the source and target database instance groups based on preset comparison rules. After successful verification, the migration control center 110 schedules the synchronization management nodes N8 and N9 to establish a data synchronization link, providing assurance for business rollback. Finally, after confirming that the reverse synchronization channel is ready, the migration control center 110 releases the lock in the source database instance group and switches business traffic from the source database instance group to the target database instance group.
[0030] The migration control center 110 may include a cluster of one or more servers. The migration control center 110 can communicate with each functional node N1 to N9 in various ways, including but not limited to wired connection, wireless connection, signaling connection, and Internet connection.
[0031] The method according to the embodiments of this application can be executed by the migration control center 110. Accordingly, the apparatus according to one aspect of the embodiments of this application can be disposed in the migration control center 110. Optionally, the method according to the embodiments of this application can be executed by a specific node (such as the verification and control node N7) among the functional nodes. Accordingly, the apparatus according to the embodiments of this application can be disposed in that specific node.
[0032] In some embodiments, the method according to the present application can be executed by an independent scheduling server that is communicatively connected to the migration control center 110 and the functional node cluster 100. Accordingly, the apparatus provided in the present application can also be located in this independent scheduling server.
[0033] It should be understood that Figure 1 The number of functional nodes and migration control centers shown is merely illustrative. Depending on implementation needs, any number of functional nodes and migration control centers can be included. In critical industries such as finance and telecommunications, this architecture can be deployed in private cloud environments to meet data security and compliance requirements.
[0034] Figure 2 A flowchart illustrating a database flow-switching method according to an embodiment of this application is shown schematically. Figure 2 As shown, the database flow switching method 200 according to the embodiments of this application may include steps S210 to S240.
[0035] In step S210, in response to receiving the database migration verification instruction, a distributed atomic locking operation is performed on the target data object in the source database based on the locking configuration parameters obtained from the configuration center. The locking configuration parameters include a list of business accounts to be locked and database connection information.
[0036] The configuration center is a platform for managing variables, providing open platform applications with a one-stop, secure configuration management service with dynamic activation capabilities. In this article, the configuration center can also be referred to as the dynamic configuration center. The target data object can be one or more logically related database entities, such as a specific business account, a set of related data tables, or a data partition. Distributed atomic operations refer to the execution of the locking operation sequence as an indivisible whole, with an all-or-nothing semantic result: either all target data objects are successfully locked, or no locking occurs at all. This ensures that during subsequent verification, the locked data range is in an absolutely static and consistent snapshot state, eliminating the risk of data access inconsistency due to partial locking. For example, locking can be completed within a single transaction boundary by invoking the database system's transaction control mechanism. For distributed or clustered source databases, a coordinated locking strategy can be adopted, using pre-synchronized timestamps or a distributed transaction coordinator to synchronously send locking instructions to relevant database instances and monitor the execution status of all instances. Only when all target data objects are successfully locked on all relevant instances is the entire locking operation considered complete, thus satisfying approximate atomicity requirements in a distributed environment.
[0037] In step S220, in response to the target data object being locked, the data comparison service is invoked to perform data consistency verification between the source database and the target database based on the data verification parameters obtained from the configuration center. Data consistency verification includes comparing the total number of records and comparing the data content.
[0038] Data validation parameters and lock configuration parameters can be generated by the same configuration center. The core of the data validation process lies in adopting a phased or progressive validation strategy, which balances validation efficiency and validation depth through mandatory validation order and dependencies.
[0039] First, perform data structure-based verification (also known as the rapid verification phase). This phase primarily verifies the macro-level consistency of the data, such as counting and comparing the total number of records (rows) in corresponding tables in the source and target databases. This verification is fast, low-cost, and can efficiently eliminate structural inconsistencies caused by omissions or duplications during data migration.
[0040] Subsequently, the system initiates the second phase of verification only after confirming that the total number of records matches. The second phase is data content-based verification (also known as the precise verification phase). This phase targets pre-defined, critical data tables essential to the business (e.g., user account tables, core transaction record tables), performing precise content comparisons on specified key fields of these tables. Comparison methods may include, but are not limited to, direct value comparison, hash value comparison, or checksum calculation. While this phase is relatively time-consuming, it delves into the semantic level of the data, confirming the precise consistency of the data content.
[0041] Then, the verification results of the two stages are comprehensively evaluated. In the embodiments of this application, the entire data consistency verification is deemed to have passed only when the verification results of both stages show consistency. This mandatory order of structure first and content second can effectively avoid wasting resources performing expensive full content comparisons when there are obvious structural errors, thereby significantly improving the overall verification efficiency while ensuring the reliability of verification.
[0042] In step S230, in response to the successful data consistency verification, based on the reverse synchronization parameters obtained from the configuration center, the application programming interface of the data synchronization engine is invoked to establish a data synchronization link from the target database to the source database to support business rollback. The reverse synchronization configuration parameters are used to define the data mapping relationship and synchronization rules between the source and target databases.
[0043] Establishing a data synchronization link by calling the application programming interface (API) of the data synchronization engine is the key technical guarantee for achieving smooth business switching and secure rollback in this application. Its core function is to continuously maintain data consistency between the source and target databases before, during, and after the formal switch of business traffic from the source database to the target database. In a specific implementation, this link is manifested as a reverse data synchronization channel (i.e., synchronization from the target database to the source database). This channel can adopt an incremental data synchronization mode, continuously capturing all data changes (insertions, updates, deletions) that occur since the channel was established by parsing the transaction logs of the target database, and synchronizing them to the source database in real-time or near real-time. Synchronization filtering rules can be configured to ensure that only business-related incremental data is transmitted, avoiding unnecessary full data transmission, thereby optimizing network bandwidth and synchronization performance. A link health monitoring mechanism can be established to track key indicators such as synchronization latency, data consistency verification results, and connection status in real time, ensuring that the data synchronization link is always in a healthy, usable, and ready state, providing immediate and complete data support for potential business rollback decisions.
[0044] In step S240, in response to the completion of the data synchronization link establishment, the lock on the target data object is released, and the business traffic is switched from the source database to the target database by updating the application configuration or load balancing settings.
[0045] Once the data synchronization link is confirmed to be stably established, the system immediately releases the lock on the target data object in the source database, restoring its normal read and write access permissions. Subsequently, with the real-time guarantee of the data synchronization link, a business traffic switching operation is performed. This switching is achieved by updating application configurations (such as data source connection strings) or load balancing settings (such as weights and routing rules). The switching process can be a one-time redirect or a gradual, canary switch. Since the reverse synchronization link is already ready and operational before the switching action is executed, any new data that may be generated on the source database from the time the lock is released until the switch is completed, as well as all new data generated on the target database after the switch, will be synchronized back to the source database through this link. This ensures that the source database always remains a usable backup that is almost real-time consistent with the target database, thereby reducing the recovery time and recovery point targets for rollback operations (such as switching back from the target database to the source database) to extremely low levels, achieving a smooth switch with controllable risks.
[0046] This application's embodiments construct a parameter-driven, highly automated database migration system with inherent fault tolerance and rollback capabilities through the close coordination of four key steps: atomic locking, phased dual verification, pre-built reverse synchronization links, and orderly switching. This technical solution fundamentally solves the problems of data consistency risks and uncontrollable business interruption durations caused by verification benchmark drift, lack of rollback mechanisms, and discrete operational steps in traditional manual migration processes. Practical verification has shown that this application can reduce the planned business interruption time for critical business database migration from hours in traditional solutions to minutes or even seconds. Simultaneously, through a pre-built real-time reverse synchronization channel, it minimizes the risk of data loss and recovery time in rollback scenarios.
[0047] In business scenarios with high consistency and continuity requirements, such as finance and telecommunications, this application not only ensures the precise consistency of data migration, but also significantly reduces the overall risk of migration operations through built-in automated rollback protection capabilities, achieving dual reinforcement of business continuity and data security, and providing reliable standardized technical support for large-scale, critical database migration.
[0048] Based on the above embodiments, the specific implementation of performing distributed atomic locking operations on target data objects in the source database may include the following steps.
[0049] First, predefined locking configuration parameters are retrieved from the configuration center. These parameters include a list of authorized business accounts to be locked, and connection information for each instance in the source database cluster corresponding to these accounts, such as host address, port, and authentication credentials. Next, based on the locking configuration parameters, the system automatically iterates through the multiple database instances involved in the source database and establishes the necessary connections. Then, by calling the native management interfaces or commands provided by each database instance, the locking operation is performed on the target data object. To achieve atomicity as much as possible in a distributed environment, a coordination mechanism can be used, such as command triggering based on a unified timestamp, so that the locking operation for all instances is completed within a very short time window, thereby minimizing the potential for data inconsistency due to locking asynchrony.
[0050] In some embodiments, performing locking operations through the native interfaces of each database instance may also include more granular coordination and control steps.
[0051] First, a multi-threaded or asynchronous task execution framework can be built, allocating an independent execution unit to each database instance that needs to perform locking operations, thereby achieving parallel processing and improving efficiency. Next, time synchronization can be achieved by connecting to a unified clock source (such as a network time protocol server), coordinating the execution units to trigger locking commands within a pre-agreed, precise time point or time window, which helps to logically synchronize locking actions. Then, the locking operation feedback status returned by each database instance is collected in real time. Only when all instances return success signals does the system generate a global lock completion signal, marking the success of the atomic locking operation. If the locking operation of any instance fails or the response times out, the system will immediately trigger an automatic rollback mechanism. This mechanism sends unlock commands to all successfully locked instances, automatically releasing the locked target data objects, thereby ensuring that the entire system's state can automatically and reliably roll back to the consistency point before the operation, avoiding the system being in an inconsistent intermediate state due to partial success.
[0052] In some embodiments, the specific process for performing data consistency verification between the source database and the target database may include the following steps.
[0053] First, the system retrieves row count comparison configuration parameters and content comparison configuration parameters from the data verification parameters (from the configuration center) using parameter identifiers. As an example, these parameters can define the comparison objects, rules, and thresholds. Next, based on the row count comparison configuration parameters, the system automatically compares the total number of records in all corresponding data tables in the source and target databases to quickly verify the macroscopic structural consistency of the data. Then, in response to only if the total number of records comparison passes (i.e., all comparison tables have the same number of rows), the system initiates data content comparison for preset key business tables based on the content comparison configuration parameters to perform a deeper and more time-consuming microscopic content consistency check. Finally, the system integrates the comparison results from both stages. Only when both the total number of records comparison and the data content comparison are successful is the final data consistency verification result generated. This embodiment, through a mandatory sequential dependency mechanism of first quickly verifying the macroscopic structure and then precisely verifying the microscopic content, significantly improves the execution efficiency and resource utilization of the overall verification process while ensuring the reliability of deep data verification.
[0054] In some embodiments, to further improve verification efficiency and resource utilization, intelligent strategies can be introduced to compare the data content of preset key business tables.
[0055] For example, data tables can be categorized based on a pre-defined business importance level model. This model can be constructed based on factors such as data security level, business impact scope, and regulatory requirements. For critical core tables determined to have an importance level higher than the pre-defined threshold, such as tables directly involving cash flow, customer master data, or core configurations, the system performs a row-by-row comparison of all fields to ensure absolute accuracy in data migration and meet the highest level of data consistency requirements. For ordinary business tables with an importance level lower than the pre-defined threshold, the system adopts an adaptive sampling comparison strategy.
[0056] For example, the strategy can dynamically adjust the sampling ratio based on the frequency of historical data changes in the table. For tables that change frequently, a higher sampling ratio is used to capture more potential inconsistencies; for tables that change very little or are static, a lower sampling ratio is used. This strategy achieves intelligent optimization and allocation of verification resources for massive amounts of non-core data while ensuring the absolute accuracy of core data, thereby completing the verification of large-scale data within a controllable timeframe.
[0057] In some embodiments, the specific process of establishing a data synchronization link from the target database to the source database may include the following steps.
[0058] First, predefined reverse synchronization configuration parameters are retrieved from the configuration center. These parameters explicitly define the data mapping relationship between the source and target databases, synchronization rules (such as synchronization direction and objects), and optional data filtering conditions. Based on this configuration, the system accesses a dedicated management node via an encrypted secure connection. This management node serves as a command forwarding and execution environment, helping to isolate the production database from the upper-level scheduling system and improving security. On the management node, the system calls the application programming interface of a professional data synchronization service engine to initialize an incremental data capture process according to the reverse synchronization configuration parameters. Once this process starts, it signifies the formal establishment of a continuously running incremental data synchronization link from the target database to the source database. This link is responsible for capturing and synchronizing subsequent data changes, ensuring high performance, high reliability, and ease of maintenance by relying on mature data synchronization components.
[0059] In some embodiments, the method further includes a robust exception handling process, reflecting fault-tolerant design principles. Specifically, in response to a data consistency verification failure, the system will maintain a locked state on the target data object in the source database to prevent further data writing and complicating the problem, thus preserving the original state for subsequent problem localization and analysis. Simultaneously, the system immediately triggers multi-level, multi-channel exception alarm notifications. Alarm methods may include, but are not limited to, sending SMS messages to on-duty personnel, pushing emails to relevant teams, and highlighting alarm information on a unified monitoring dashboard, ensuring timely detection of alarm information.
[0060] In some embodiments, all subsequent switching processes (such as establishing synchronization links, unlocking, and switching traffic) can be automatically suspended, and the system enters a state awaiting manual intervention for decision-making. This ensures that in the event of inconsistencies in critical data, subsequent operations that could lead to business failures will not be automatically executed, leaving the final decision-making power to qualified operations and maintenance personnel, thereby maximizing risk control.
[0061] Figure 3 The diagram schematically illustrates a system architecture 300 for implementing the above-described method according to an embodiment of this application. For example... Figure 3 As shown, the system architecture 300 includes five core components: a continuous deployment platform, a function platform, a configuration center, a management and control machine, and a data synchronization service.
[0062] The continuous deployment platform acts as the central coordinator for the entire process, defining each operation during database migration as a pluggable, standardized component and scheduling its execution according to a pre-defined operation chain (e.g., account locking - record count comparison - content comparison - initiating reverse synchronization). The continuous deployment platform automates the connection between each operation step by initiating request calls to the function platform.
[0063] The function platform provides event-triggered computing capabilities in a serverless mode. After receiving execution instructions from the continuous deployment platform, it dynamically selects and executes the corresponding database operation tasks based on the instruction type, such as calling database interfaces or running scripts. This platform eliminates the need for users to manage underlying computing resources, automatically allocating and running the required computing power to ensure stable and reliable execution of all operations.
[0064] The configuration center serves as the system's parameter management hub, centrally storing and managing all configuration information related to migration verification. During system execution, it retrieves necessary dynamic parameters from the configuration center, such as the list of accounts to be locked, data comparison rules, and reverse synchronization task configurations, achieving separation of configuration and code and improving system flexibility and maintainability.
[0065] The control unit, acting as an intermediate node for executing instructions, is responsible for receiving execution scripts or operation commands issued by the function platform and forwarding them to the data synchronization service or other target systems. This component plays a crucial role in ensuring that instructions are accurately and securely transmitted to the execution end.
[0066] Data Replication Service (DRS) can serve as a core component for data replication and synchronization, supporting online migration and real-time synchronization between databases. In this application, the DRS can be used to establish a reverse data synchronization channel from the target database to the source database, providing immediate data assurance for business rollback.
[0067] The components collaborate through clearly defined interaction relationships, forming a distributed system. Specifically, the continuous deployment platform invokes the function platform by starting function instances; the function platform retrieves dynamic parameters from the configuration center and performs corresponding operations based on the execution type; instructions involved in the execution process are sent to the data synchronization service via the control machine, ultimately completing the database migration task. This architecture automates operations, standardizes processes, and dynamically configures configurations, effectively improving the security and efficiency of the database migration process.
[0068] Figure 4 This illustration schematically shows an embodiment based on the present application. Figure 3 The system architecture platform collaboration flowchart 400 dynamically displays the interaction sequence and data flow of each component during the method execution process.
[0069] like Figure 4 As shown, the entire collaboration process can be divided into three main stages: user locking, data comparison, and reverse synchronization.
[0070] Phase 1: User Locking. When the continuous deployment platform triggers a locking operation, the function platform first requests database account locking parameters from the configuration center to obtain detailed configuration information for the accounts to be locked. Then, the function platform loads the specific account locking configuration from the configuration center, including the target database connection information and the list of accounts to be locked. Based on these configurations, the function platform performs atomic locking operations on the specified database users through the database's native interface, ensuring that all target data objects are successfully locked within the same time window. After locking is complete, the system returns a locking success message and automatically triggers the next phase of data comparison.
[0071] Phase Two: Data Comparison. After the locking operation is completed, the system enters the data consistency verification phase. This phase can specifically include a row count comparison sub-phase and a content comparison sub-phase, following a structure-first, content-second order to form a dual verification mechanism, ensuring the comprehensiveness and accuracy of the verification results.
[0072] The row count comparison sub-stage begins with the continuous deployment platform triggering a record count comparison operation. The function platform requests the configuration file for the row-level comparison task from the configuration center, obtaining the parameters used to create the comparison task. Subsequently, the function platform accesses the control machine via a secure connection and executes the corresponding script to initiate the row-level comparison task. This task counts and compares the total number of records in the corresponding tables of the source and target databases, quickly screening for any significant data volume differences.
[0073] Content Comparison Sub-phase. The function platform requests the configuration file for the content comparison task from the configuration center to obtain the content comparison rules for key business tables. Similarly, the function platform executes a script through the control machine to initiate the content comparison task, performing precise field-level comparisons on the preset key business tables to verify the consistency of data content. Once the data consistency verification is successful, the system enters the reverse synchronization preparation phase.
[0074] Phase 3: Reverse Synchronization. The continuous deployment platform triggers a reverse data synchronization operation. The function platform requests the configuration file for the reverse synchronization task from the configuration center, obtaining the parameters used to start the task. Subsequently, the function platform executes a script through the management machine to initiate the reverse data synchronization task from the target database to the source database. This task establishes an incremental data capture channel, continuously synchronizing changed data from the target database to the source database, providing immediate data assurance for potential business rollbacks.
[0075] Throughout the process, components communicate through standardized interfaces and protocols, achieving automation and continuity of operations. The continuous deployment platform acts as the process coordinator, triggering operations at each stage sequentially; the function platform, as the execution engine, is responsible for calling and executing specific tasks; the configuration center provides dynamic parameter support, enabling flexible configuration management; the control machine acts as an intermediary, ensuring that instructions are accurately transmitted to the execution end; and the data synchronization service undertakes the core data replication function. This collaborative process effectively ensures accurate verification of data consistency and reliable maintenance of business continuity during database migration.
[0076] Based on the aforementioned methods and systems, this application, through an automated closed-loop design of atomic locking, phased verification, and pre-configured synchronization, ensures data consistency with millimeter-level precision while reducing the operational risks and business interruption time of database migration by an order of magnitude, thereby improving efficiency, reliability, and security. Specifically, this application eradicates baseline drift through atomic locking and constructs a three-dimensional verification network through layered verification, achieving dual reliable guarantees for data integrity and correctness. Through a fully automated and intelligent phased verification strategy, this application reduces manual operation time from hours to seconds, significantly improving overall verification efficiency. The built-in fault self-healing and security compliance design of this application enables the system to have automatic rollback, security isolation, and intelligent decision support capabilities, achieving controllable and manageable operational risks. The pre-configured reverse synchronization link design of this application reduces rollback recovery time and data loss to extremely low levels, providing a smooth and worry-free switchover guarantee for high-risk migration of core business systems.
[0077] Based on the above-described database flow switching method, embodiments of this application also provide a database flow switching device. The following will be combined with... Figure 5 The device is described in detail.
[0078] Figure 5 A schematic block diagram of a database flow switching device according to an embodiment of this application is shown.
[0079] like Figure 5 As shown, the database stream switching device 500 of this embodiment includes an object locking module 510, a data comparison module 520, a reverse synchronization module 530, and a lock release module 540.
[0080] The object locking module 510 is used to perform a distributed atomic locking operation on the target data object in the source database in response to receiving a database migration verification command, based on the locking configuration parameters obtained from the configuration center; the locking configuration parameters include a list of business accounts to be locked and database connection information. In one embodiment, the object locking module 510 can be used to execute step S210 described above, which will not be repeated here.
[0081] The data comparison module 520 is used to respond to the target data object completing the locking process. Based on the data verification parameters obtained from the configuration center, it calls the data comparison service to perform data consistency verification between the source database and the target database. The data consistency verification includes comparing the total number of records and comparing the data content. In one embodiment, the data comparison module 520 can be used to execute step S220 described above, which will not be repeated here.
[0082] The reverse synchronization module 530, in response to successful data consistency verification, calls the application programming interface of the data synchronization engine based on the reverse synchronization parameters obtained from the configuration center to establish a data synchronization link from the target database to the source database, supporting business rollback. The reverse synchronization configuration parameters define the data mapping relationship and synchronization rules between the source and target databases. In one embodiment, the reverse synchronization module 530 can be used to execute step S230 described above, which will not be repeated here.
[0083] The lock release module 540 is used to release the lock on the target data object in response to the completion of the data synchronization link establishment, and to switch the business traffic from the source database to the target database by updating the application configuration or load balancing settings. In one embodiment, the lock release module 540 can be used to perform step S240 described above, which will not be repeated here.
[0084] According to an embodiment of this application, the object locking module 510 is used to traverse multiple database instances of the source database based on locking configuration parameters; and to perform locking operations on the target data objects through the native interface of each database instance to ensure that all target data objects are locked within the same time window.
[0085] According to an embodiment of this application, the object locking module 510 is used to construct a multi-threaded execution framework, allocate an independent execution thread to each database instance, coordinate each execution thread to trigger locking instructions within the same time window through a unified clock synchronization mechanism, collect the locking feedback status of each database instance in real time, and generate a global locking completion signal; when the locking operation of any database instance fails or times out, a rollback mechanism is triggered to release the target data object in other database instances that have been successfully locked.
[0086] According to an embodiment of this application, the data comparison module 520 is used to obtain row count comparison configuration parameters and content comparison configuration parameters from the data verification parameters; based on the row count comparison configuration parameters, it performs a total record count comparison on the corresponding data tables in the source database and the target database; in response to the record count comparison passing, it performs a data content comparison on the preset key business tables based on the content comparison configuration parameters; and based on the record count comparison result and the data content comparison result, it generates a data consistency verification result.
[0087] According to an embodiment of this application, the data comparison module 520 is used to perform a full data comparison on key business tables with an importance level higher than a preset threshold, and to perform an adaptive sampling comparison on ordinary business tables with an importance level lower than the threshold based on the data change frequency.
[0088] According to an embodiment of this application, the reverse synchronization module 530 is used to access the management node through a secure connection based on the reverse synchronization configuration parameters; on the management node, the data synchronization engine is invoked to initialize the incremental data capture process and establish a data synchronization link from the target database to the source database.
[0089] According to an embodiment of this application, the database flow switching device 500 further includes an alarm module, which is used to maintain the locked state of the target data object in the source database and trigger an abnormal alarm notification in response to the failure of data consistency verification.
[0090] According to embodiments of this application, any multiple modules among the object locking module 510, data comparison module 520, reverse synchronization module 530, and lock release module 540 can be combined into one module, or any one of these modules can be split into multiple modules. Alternatively, at least some of the functions of one or more of these modules can be combined with at least some of the functions of other modules and implemented in one module. According to embodiments of this application, at least one of the object locking module 510, data comparison module 520, reverse synchronization module 530, and lock release module 540 can be at least partially implemented as hardware circuitry, such as field-programmable gate arrays, programmable logic arrays, systems-on-a-chip, systems-on-a-substrate, systems-on-package, application-specific integrated circuits, or implemented in hardware or firmware by any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the object locking module 510, data comparison module 520, reverse synchronization module 530, and lock release module 540 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0091] Figure 6 A block diagram schematically illustrates an electronic device suitable for implementing a database stream switching method according to an embodiment of this application.
[0092] like Figure 6As shown, an electronic device 600 according to an embodiment of this application includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory 602 or a program loaded from a storage portion 608 into a random access memory 603. The processor 601 may include, for example, a general-purpose microprocessor, an instruction set processor and / or an associated chipset and / or a dedicated microprocessor. The processor 601 may also include onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for executing different steps of the method flow according to an embodiment of this application.
[0093] Random access memory 603 stores various programs and data required for the operation of electronic device 600. Processor 601, read-only memory 602, and random access memory 603 are interconnected via bus 604. Processor 601 executes various steps of the method flow according to embodiments of this application by executing programs in read-only memory 602 and / or random access memory 603. It should be noted that programs may also be stored in one or more memories other than read-only memory 602 and random access memory 603. Processor 601 may also execute various steps of the method flow according to embodiments of this application by executing programs stored in one or more memories.
[0094] According to embodiments of this application, the electronic device 600 may further include an input / output interface 605, which is also connected to a bus 604. The electronic device 600 may also include one or more of the following components connected to the input / output interface 605: an input section 606 including a keyboard, mouse, etc.; an output section 607 including a cathode ray tube, liquid crystal display, etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card, such as a local area network card, modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.
[0095] Embodiments of this application also provide a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.
[0096] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory, read-only memory, erasable programmable read-only memory, portable compact disk read-only memory, optical storage devices, magnetic storage devices, or any suitable combination thereof. In embodiments of this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include the read-only memory 602 described above, and / or random access memory 603, and / or one or more memories other than read-only memory 602 and random access memory 603.
[0097] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the methods provided in the embodiments of this application.
[0098] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 609, and / or installed from the removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0099] In embodiments of this application, the computer program can be downloaded and installed from a network via communication section 609, and / or installed from removable medium 611. When the computer program is executed by processor 601, it performs the functions defined in the system of embodiments of this application. According to embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0100] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0101] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0102] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
Claims
1. A database stream switching method, characterized in that, The method includes: In response to receiving a database migration verification command, a distributed atomic locking operation is performed on the target data object in the source database based on the locking configuration parameters obtained from the configuration center; the locking configuration parameters include a list of business accounts to be locked and database connection information. In response to the target data object being locked, based on the data verification parameters obtained from the configuration center, the data comparison service is invoked to perform data consistency verification between the source database and the target database. The data consistency verification includes comparison of the total number of records and comparison of data content. In response to the successful data consistency verification, based on the reverse synchronization parameters obtained from the configuration center, the application programming interface of the data synchronization engine is called to establish a data synchronization link from the target database to the source database to support business rollback; the reverse synchronization configuration parameters are used to define the data mapping relationship and synchronization rules between the source database and the target database. In response to the completion of the data synchronization link, the lock on the target data object is released, and the business traffic is switched from the source database to the target database by updating the application configuration or load balancing settings.
2. The method according to claim 1, characterized in that, Performing distributed atomic locking operations on target data objects in the source database includes: Based on the locking configuration parameters, traverse multiple database instances of the source database; By using the native interfaces of each database instance, a locking operation is performed on the target data object to ensure that all target data objects are locked within the same time window.
3. The method according to claim 2, characterized in that, The step of performing a locking operation on the target data object through the native interfaces of each database instance includes: Build a multi-threaded execution framework and allocate an independent execution thread to each database instance; A unified clock synchronization mechanism is used to coordinate the triggering of locking instructions by each execution thread within the same time window; Real-time acquisition of the locking feedback status of each database instance, generating a global locking completion signal; When a locking operation on any database instance fails or times out, a rollback mechanism is triggered to release the target data object in other database instances that have been successfully locked.
4. The method according to claim 1, characterized in that, The data consistency verification performed between the source database and the corresponding target database includes: Obtain the row count comparison configuration parameters and content comparison configuration parameters from the data verification parameters; Based on the row count comparison configuration parameters, the total number of records in the corresponding data tables of the source database and the target database is compared. In response to the successful comparison of the total number of records, a data content comparison is performed on the preset key business tables based on the content comparison configuration parameters; Based on the comparison results of the total number of records and the comparison results of the data content, a data consistency verification result is generated.
5. The method according to claim 4, characterized in that, The data content comparison of the preset key business tables includes: Based on the preset business importance level, a full data comparison is performed on critical business tables with an importance level higher than the threshold, and an adaptive sampling comparison based on the data change frequency is performed on ordinary business tables with an importance level lower than the threshold.
6. The method according to claim 1, characterized in that, Establishing a data synchronization link from the target database to the source database includes: Based on the aforementioned reverse synchronization configuration parameters, access the management node via a secure connection; On the control node, the data synchronization engine is invoked to initialize the incremental data capture process and establish a data synchronization link from the target database to the source database.
7. The method according to claim 1, characterized in that, The method further includes: In response to a failure of data consistency verification, the target data object in the source database is kept locked, and an anomaly alarm notification is triggered.
8. A database stream switching device, characterized in that, The device includes: The object locking module is used to respond to a database migration verification command and perform a distributed atomic locking operation on the target data object in the source database based on the locking configuration parameters obtained from the configuration center; the locking configuration parameters include a list of business accounts to be locked and database connection information. The data comparison module is used to respond to the target data object completing the locking, and based on the data verification parameters obtained from the configuration center, call the data comparison service to perform data consistency verification between the source database and the target database. The data consistency verification includes comparison of the total number of records and comparison of data content. The reverse synchronization module is used to respond to the successful data consistency verification by calling the application interface of the data synchronization engine based on the reverse synchronization parameters obtained from the configuration center to establish a data synchronization link from the target database to the source database, so as to support business rollback; the reverse synchronization configuration parameters are used to define the data mapping relationship and synchronization rules between the source database and the target database. The lock release module is used to release the lock on the target data object in response to the completion of the data synchronization link establishment, and switch the business traffic from the source database to the target database by updating the application configuration or load balancing settings.
9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 7.