A method and device for smoothly migrating a business database

Through the combination of Spring Aop and RocketMQ, asynchronous calls and Prometheus monitoring, the problem of interface errors during database migration was solved, and a safe, stable and smooth migration was achieved, ensuring business continuity.

CN117827796BActive Publication Date: 2025-09-05CHINA TELECOM CLOUD TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311710341.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-13
Publication Date
2025-09-05
Estimated Expiration
2043-12-13

AI Technical Summary

Technical Problem

The existing technology is prone to DAO interface implementation errors during the database migration process, resulting in abnormal business execution, affecting the smooth operation of the production environment, and unable to complete smooth migration without user perception.

Method used

The source database DAO request is sent to the distributed messaging middleware RocketMQ through the SpringAop interceptor. The asynchronous thread pool calls the target database DAO interface. The Prometheus monitoring platform is used to monitor and correct logical differences until the results are consistent, and then the database is switched.

Benefits of technology

It achieves safe and stable database migration without user awareness, with high isolation and observability, ensuring business continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117827796B_ABST
    Figure CN117827796B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of database technology, and specifically discloses a method and device for smoothly migrating a business database, comprising the following steps: S1, sending business request information of a source database DAO data access layer to a distributed messaging middleware RocketMQ by means of a SpringAop interceptor; S2, sequentially calling the DAO data access layer interface implementation of a target database by means of an asynchronous thread pool; S3, outputting interface information of mismatched call results to a Prometheus monitoring and alarm platform, so as to facilitate developers to correct business logic and repair data in a targeted manner; S4, verifying the business logic after switching the database by means of an asynchronous update, and switching the DAO access layer of the target database only when the DAO request call results of the source and target databases are basically consistent, thereby achieving the purpose of smoothly transitioning the business database. Therefore, the present application has stronger security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a method and device for smoothly migrating a business database. Background Art

[0002] The three-tier architecture is designed to adhere to the concept of "high cohesion and low coupling." It divides each functional module into a three-tier architecture: presentation layer (UI), business logic layer (BLL), and data access layer (DAL). Interfaces are used between layers to access each other, and the entity class (Model) of the object model is used as a carrier for data transmission. Different entity classes of object models generally correspond to different tables in the database, and the attributes of the entity class are consistent with the field names of the database table. The purpose of the three-tier architecture to distinguish between levels is to achieve "high cohesion and low coupling." Developers have a clearer division of labor and can focus more on the analysis, design, and development of the core business logic of the application system, which speeds up the project progress, improves development efficiency, and facilitates project updates and maintenance.

[0003] In the prior art, there is a Chinese invention patent with application number 201611112165.3, invention publication number CN106776997A, and invention name: A method for migrating a database. The above patent discloses a method for migrating a database, wherein the database runs on two servers based on RAC mode and each of the two servers runs a database core process. The data in the database is stored in a memory. The migration method includes: copying the data in the memory to a new memory in the destination; detecting whether the database is for core business or non-core business; and when the database is for non-core business, relocating the two servers to the destination one after another.

[0004] The above patent can select different database migration methods as needed according to the importance of the actual business system, saving costs, shortening migration time and ensuring business continuity while minimizing the impact of database migration transition downtime on the business system.

[0005] However, as business needs dictate, rapidly expanding operations often require migrating business data to other databases. A common approach is to directly modify the business code to match the target database's syntax and then use data synchronization tools to fully migrate the data to the target database. Since database changes involve changing SQL syntax and rewriting the business DAO data access layer, complex business scenarios are prone to DAO interface implementation errors, business execution anomalies, and repeated rework, which can seriously impact the smooth operation of the production environment. Summary of the Invention

[0006] The object of the present invention is to provide a method and apparatus for smoothly migrating a service database, so as to solve the problems raised in the above background technology.

[0007] To achieve the above object, the present invention provides the following technical solution: a method for smoothly migrating a service database, comprising the following steps:

[0008] S1. Send the business request information of the source database DAO data access layer to the distributed messaging middleware RocketMQ through the SpringAop interceptor.

[0009] S2, sequentially call the DAO data access layer interface of the target database through the asynchronous thread pool;

[0010] S3: Output the interface information of the call results that do not match the match to the Prometheus monitoring and alarm platform, so that developers can modify the business logic and repair the data in a targeted manner;

[0011] S4. Verify the business logic after switching the database through asynchronous updates. Switch the DAO access layer of the target database only when the DAO request call results of the source and target databases are basically consistent, so as to achieve the purpose of smooth transition of the business database.

[0012] Furthermore, the source database DAO request is mirrored to the DAO data access layer interface of the target database, and the DAO business logic of the target database is corrected online through hot loading.

[0013] Furthermore, the target database DAO data access layer is completely decoupled from the original business code.

[0014] Furthermore, the Prometheus monitoring platform can monitor the DAO request call comparison results of the source and target databases in real time, providing reference guidance for developers to make business corrections.

[0015] Furthermore, the aspect rules of the SpringAop interceptor are defined to intercept the methods, parameters and call results implemented by the source database DAO data access layer.

[0016] Furthermore, the asynchronous thread pool is started to sequentially consume the call messages of the distributed message middleware RockMQ, and the abnormal interface information of the mismatch between the call results of the two database DAO interfaces is sent to the Prometheus monitoring and alarm platform, so that developers can correct business logic and data in a targeted manner.

[0017] Furthermore, the developer modifies the target database DAO data access layer implementation logic and database data through hot loading technology.

[0018] Furthermore, the DAO data access logic of the target database is verified through asynchronous calls, asynchronous comparisons, and asynchronous updates, and the business database is not switched until the DAO request call results of the source and target databases are consistent, so that the switching and migration of the business database is completed without the user's perception.

[0019] The present invention also provides a device for smoothly migrating a service database, which is applicable to the above-mentioned method for smoothly migrating a service database.

[0020] Compared with the prior art, the present invention has the following advantages:

[0021] 1. Strong isolation: Without affecting existing production business, the DAO request of the source database is mirrored to the DAO data access layer interface of the target database through asynchronous calling and asynchronous comparison results. The DAO business logic of the target database is then corrected online through hot loading.

[0022] 2. Strong Security: The target database's DAO data access layer is completely decoupled from the original business code. Business logic after database switching is verified through asynchronous updates, and the target database's DAO access layer is not switched until the DAO request call results between the source and target databases are essentially consistent.

[0023] 3. Observability: The introduction of the Prometheus monitoring platform can monitor the DAO request call comparison results of the source and target databases in real time, providing reference guidance for developers to make business corrections.

[0024] 4. Practicality: This application is particularly suitable for database switching of complex businesses. It can smoothly switch and migrate business databases without user perception, and has higher practicality. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments described in the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0026] Figure 1 It is a schematic diagram of a flow chart structure in the prior art;

[0027] Figure 2 This is an overall flow chart provided for an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0029] See also Figure 1 The present invention provides a technical solution: a method for smoothly migrating a business database, comprising the following steps:

[0030] S1. Send the business request information of the source database DAO data access layer to the distributed messaging middleware RocketMQ through the SpringAop interceptor.

[0031] S2, sequentially call the DAO data access layer interface of the target database through the asynchronous thread pool;

[0032] S3: Output the interface information of the call results that do not match the match to the Prometheus monitoring and alarm platform, so that developers can modify the business logic and repair the data in a targeted manner;

[0033] S4. Verify the business logic after switching the database through asynchronous updates. Switch the DAO access layer of the target database only when the DAO request call results of the source and target databases are basically consistent, so as to achieve the purpose of smooth transition of the business database.

[0034] Specifically, the original solution for implementing database migration in the business system in the prior art is mainly to directly replace the interface implementation logic of the business DAO data access layer, and then migrate all the database records of the source database to the target database through the data synchronization tool. It uses a one-size-fits-all approach to complete the database switch migration, and cannot perform DAO business rollback. It has the characteristics of poor stability and low security. However, the present application uses the SpringAop interceptor to send the business request information of the source database DAO data access layer to the distributed messaging middleware RocketMQ, and then calls the DAO data access layer interface of the target database in sequence through the asynchronous thread pool. The interface information of the call result that does not match the call result is output to the Prometheus monitoring and alarm platform, which is convenient for developers to correct business logic and data repair in a targeted manner. This patent solution has stronger security, isolation, stability and observability.

[0035] Among them, Yilian is a stable, secure, efficient and scalable IM instant messaging system that has been developed. It mainly provides users with text messages, files, images, voice, video and other communication functions in single chat and group chat modes. The three-tier architecture of the system generally includes the presentation layer, the business logic layer, and the dao data access layer. The data access layer is used to implement interaction and access with the database, such as obtaining data from the database, saving or modifying data in the database, etc. RocketMQ is Alibaba's open source distributed message middleware with low latency, high concurrency, high availability and high reliability. It supports transactional messages, chronological messages, batch messages, scheduled messages, message backtracking and other functions. SpringAOP is a standard and easy-to-use aop framework provided by Spring. It uses dynamic proxy technology to implement the weaving of proxy methods, and adds functions to business methods without affecting the main business process methods.

[0036] The source database's DAO requests are mirrored to the target database's DAO data access layer interface implementation, and the target database's DAO business logic is corrected online through hot reloading. Without impacting existing production operations, this approach uses asynchronous calls and asynchronous comparison results to mirror the source database's DAO requests to the target database's DAO data access layer interface implementation. Hot reloading is then used to correct the target database's DAO business logic online, providing strong isolation.

[0037] The target database's DAO data access layer is completely decoupled from the original business code. The target database's DAO data access layer is completely decoupled from the original business code. Business logic after the database switch is verified through asynchronous updates. The target database's DAO access layer is not switched until the DAO request call results between the source and target databases are substantially consistent, resulting in enhanced security. The Prometheus monitoring platform monitors the DAO request call comparison results between the source and target databases in real time, providing developers with guidance for business corrections and ensuring high visibility. Developers can use hot reloading technology to correct the target database's DAO data access layer implementation logic and database data.

[0038] Define SpringAop interceptor rules to intercept the methods, parameters, and call results implemented in the source database's DAO data access layer. Specifically, define SpringAop interceptor rules to intercept the methods, parameters, and call results implemented in the source database's DAO data access layer. Send client request information sequentially to the distributed messaging middleware RockMQ.

[0039] An asynchronous thread pool is launched to sequentially consume call messages from the distributed messaging middleware RockMQ. Abnormal interface information indicating mismatched call results between the two database DAO interface implementations is reported to the Prometheus monitoring and alerting platform, enabling developers to modify business logic and repair data in a targeted manner. The target database's DAO data access logic is verified through asynchronous calls, asynchronous comparisons, and asynchronous updates. The business database is not switched until the DAO request call results between the source and target databases match, completing the switch and migration without user awareness.

[0040] In another embodiment provided by the present invention, a DAO data access layer of a target database can be implemented (data in the target database is accessed through a JDB driver of the target data).

[0041] The present invention also provides a device for smoothly migrating a service database, which is applicable to the above-mentioned method for smoothly migrating a service database.

[0042] Specifically, this solution can establish a method and device for smoothly migrating a business database. This method, especially for complex business database switching, can smoothly switch and migrate business databases without user awareness, providing higher security, stability, and observability.

[0043] It should be noted that the electrical equipment involved in this application can be powered by batteries or external power supply.

[0044] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.

Claims

1. A method for smoothly migrating a business database, characterized in that: The following steps are involved: S1. Send the business request information of the source database DAO data access layer to the distributed messaging middleware RocketMQ through the SpringAop interceptor. S2, sequentially call the DAO data access layer interface of the target database through the asynchronous thread pool; S3: Output the interface information of the call results that do not match the match to the Prometheus monitoring and alarm platform, so that developers can modify the business logic and repair the data in a targeted manner; S4. Verify the business logic after switching the database through asynchronous updates. Switch the DAO access layer of the target database until the DAO request call results of the source and target databases are basically consistent, achieving the purpose of smooth transition of the business database. The source database DAO request is mirrored to the target database DAO data access layer interface implementation, and the target database DAO business logic is modified online through hot loading; The Prometheus monitoring platform can monitor the DAO request call comparison results of the source and target databases in real time; Start the asynchronous thread pool to sequentially consume the call messages of the distributed message middleware RocketMQ, and output the abnormal interface information of the mismatch between the call results of the two database DAO interfaces to the Prometheus monitoring and alarm platform; The developer uses the hot loading technology to modify the target database DAO data access layer implementation logic and database.

2. The method for smoothly migrating a service database according to claim 1, characterized in that: The target database DAO data access layer is completely decoupled from the original business code.

3. The method for smoothly migrating a service database according to claim 1, characterized in that: Define the aspect rules of the SpringAop interceptor to intercept the method implemented by the source database DAO data access layer.

4. The method for smoothly migrating a service database according to claim 2, wherein: The target database DAO data access layer is updated and replaced through hot loading technology, and the business logic of the DAO data access layer is optimized and adjusted without affecting the existing production environment.

5. The method for smoothly migrating a service database according to claim 1, characterized in that: The DAO data access logic of the target database is verified by asynchronous calling, asynchronous comparison and asynchronous updating.

6. A device for smoothly migrating a service database, characterized by: It is applicable to the method for smoothly migrating a service database as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Migration method of database

    CN106776997A

  • Program statement processing method and device, equipment and storage medium

    CN114064007A

  • Data source switching method and device, electronic equipment and storage medium

    CN115374083A