Database migration method, device and equipment based on AI assistance and medium
By employing an AI-assisted migration method, which utilizes a migration knowledge graph model to generate the optimal migration strategy and monitor it in real time, the risks and resource waste associated with manual decision-making in traditional database migration are resolved, achieving efficient, reliable, and low-cost database migration.
Patent Information
- Application Number
- CN202511722199.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-27
AI Technical Summary
Traditional database migration relies on manual decision-making, resulting in high migration risks, wasted resources, and high implementation costs. Furthermore, the fixed concurrency level cannot adapt to network jitter, leading to long downtime and high failure rates.
An AI-assisted migration method is adopted, which uses a pre-trained migration knowledge graph model to generate migration prediction results. The optimal migration strategy is generated by taking minimizing downtime, data loss and migration cost as optimization objectives, and the data playback status is monitored in real time to dynamically adjust migration parameters and switching timing.
Significantly reduce the probability of migration failure, increase the success rate of migration, reduce downtime, optimize resource utilization, reduce costs, and ensure business continuity and the accuracy and integrity of data migration.
Smart Images

Figure CN121579441A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data migration technology, and specifically to an AI-assisted database migration method, apparatus, device, and medium. Background Technology
[0002] Database migration is a core component of information system upgrades, cloud transformation, and business integration. It involves the complete, consistent, and efficient migration of the structure, data, and related objects from the source database to the target database. The target database may reside on homogeneous or heterogeneous platforms (such as from Oracle to PostgreSQL) and may span different cloud environments or on-premises data centers.
[0003] Currently, traditional database migration relies on DBAs manually analyzing table structures, data volumes, and dependencies before selecting migration tools (such as AWSDMS, Alibaba Cloud DTS, or self-developed scripts). Migration solutions are mostly fixed templates involving both full and incremental migrations, requiring multiple trials and errors, with an average cycle of 2-6 weeks. Although cloud vendors provide evaluation tools, they only output compatibility reports and cannot provide optimal paths or dynamic scheduling.
[0004] Traditional database migration methods suffer from the following problems: Heavy manual decision-making requires repeated calculations of downtime windows and peak bandwidth, easily leading to underestimated data increments and rollbacks. Long downtime windows (on the order of hours) and high failure rates during a single switchover, coupled with lengthy rollback times, result in high database migration risks. Fixed concurrency levels cannot adapt to network fluctuations, leading to low bandwidth utilization and resource waste. Furthermore, cross-cloud or heterogeneous engine migrations (such as Oracle to PostgreSQL) require manually writing numerous transformation rules, resulting in high implementation costs for complex migration scenarios (such as heterogeneous and cross-cloud migrations). Summary of the Invention
[0005] In view of this, it is necessary to provide an AI-assisted database migration method, apparatus, device and medium to solve the technical problems of high dependence on human decision-making in the existing technology, which leads to high risk, waste of resources and high implementation cost in database migration.
[0006] To address the aforementioned technical problems, in a first aspect, the present invention provides an AI-assisted database migration method, comprising: Based on a pre-trained transfer knowledge graph model, transfer prediction results are generated according to the feature information of the source database and the target database. Based on the optimization objectives of minimizing downtime, data loss, and migration cost, an optimal migration strategy is generated according to the migration prediction results. The optimal migration strategy includes migration parameters. While executing the data migration task according to the optimal migration strategy, the data playback status is monitored, and the migration parameters of the data migration task are adjusted according to the monitoring results. Based on the monitoring results, predict the optimal switching time and assess the rollback risk, and adjust the execution status of the data migration task according to the assessment results.
[0007] One possible implementation also includes: Obtain the historical migration dataset; the historical migration dataset includes migration records in the database, and each migration record includes snapshot data before migration, runtime logs, and migration result labels; The runtime characteristics and resource characteristics are obtained from the runtime logs, and the structural characteristics of each database are obtained from the pre-migration snapshot data. A heterogeneous graph is constructed based on the operation log, the migration result labels, and the pre-migration snapshot data; the heterogeneous graph includes node types, node attributes, and edge relationships between connecting nodes; the node types include source database nodes, target database nodes, and migration task nodes. The heterogeneous graph is trained using a graph neural network to obtain the transfer knowledge graph model, which is used to output the transfer prediction result based on the feature information of the input source database and the target database.
[0008] In one possible implementation, the pre-trained transfer knowledge graph model generates transfer prediction results based on feature information from the source and target databases, including: Extract feature information from the source database and the target database to be migrated; the feature information includes structural features, operational features, and resource features; The extracted features are standardized and encoded to generate standardized feature vectors; The feature vector is input into the transfer knowledge graph model to output the transfer prediction result; the transfer prediction result includes the success probability, the estimated downtime, and the error rate.
[0009] In one possible implementation, the step of generating an optimal migration strategy based on the migration prediction results, with the optimization objective of minimizing downtime, data loss, and migration cost, includes: A multi-objective optimization reward function is established with the optimization objectives of minimizing the downtime, the amount of data loss, and the migration cost. Based on the migration prediction results, candidate migration strategies that maximize the reward function and satisfy the constraints are selected. The constraints include that the migration cost is lower than the budget threshold, the downtime is lower than the business time window, and the migration success rate is higher than the safety threshold. Calculate the risk score for each candidate migration strategy, and determine the candidate migration strategy with the lowest risk score as the optimal migration strategy; the optimal migration strategy includes a combination of migration tools, concurrency parameters, consistency mechanisms, and compression schemes.
[0010] One possible implementation also includes: The migration tool suite includes a dual-stream migration framework for transmitting full data and incremental logs in parallel. The consistency mechanism includes a double-write buffer mechanism and a flashback query mechanism.
[0011] In one possible implementation, monitoring the data playback status and adjusting the migration parameters of the data migration task based on the monitoring results includes: Start a shadow instance on the target database side to replay data in real time, while monitoring the replay latency and checksum error rate; When the playback delay exceeds the first delay time threshold, increase the migration concurrency or switch to a high-bandwidth transmission link; When the checksum error rate exceeds the error rate threshold, row-level checksum repair is triggered.
[0012] In one possible implementation, predicting the optimal switching timing and assessing rollback risks based on the monitoring results, and adjusting the execution status of the data migration task based on the assessment results, includes: Monitor the playback latency and number of long transactions of the binary logs of the source database in the target database playback process; When it is determined that the replay delay is less than the second delay time threshold and the number of long transactions is zero, the optimal switching point is determined and the rollback probability is calculated; the second delay time threshold is less than the first delay time threshold. If the rollback probability is less than the probability threshold, the service traffic will be switched from the source database to the target database; If the rollback probability is greater than or equal to the probability threshold, delay the switch and re-evaluate the rollback probability.
[0013] Secondly, the present invention also provides an AI-assisted database migration device, comprising: The prediction module is used to generate transfer prediction results based on the feature information of the source database and the target database, based on the pre-trained transfer knowledge graph model. The generation module is used to generate an optimal migration strategy based on the migration prediction results, with the optimization objectives of minimizing downtime, data loss, and migration cost. The optimal migration strategy includes migration parameters. The running module monitors the data playback status while starting to execute the data migration task according to the optimal migration strategy, and adjusts the migration parameters of the data migration task according to the monitoring results. The processing module is used to predict the optimal switching time based on the monitoring results and assess the rollback risk, and adjust the execution status of the data migration task based on the assessment results.
[0014] Thirdly, the present invention also provides an electronic device, including a memory and a processor, wherein, The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the AI-assisted database migration method described in any of the above implementations.
[0015] Fourthly, the present invention also provides a computer-readable storage medium for storing a computer-readable program or instruction, which, when executed by a processor, can implement the steps of the AI-assisted database migration method described in any of the above implementations.
[0016] The beneficial effects of this invention are as follows: The AI-assisted database migration method provided by this invention first generates migration prediction results through a pre-trained migration knowledge graph model, which can identify potential challenges and risks during the migration process in advance, thereby enabling targeted migration strategies. This significantly reduces the probability of migration failure and increases the success rate of migrating data from the source database to the target database. Real-time monitoring of data playback status and adjustment of migration parameters during the migration process allows for timely detection and resolution of problems, further ensuring the accuracy and integrity of data migration and thus improving the migration success rate. Furthermore, with the optimization goal of minimizing downtime, data loss, and migration costs, the migration process and migration tools and parameters are rationally planned. For example, by optimizing migration parameters, data migration efficiency is improved, downtime is reduced, and losses caused by business downtime are minimized; simultaneously, selecting cost-effective hardware and software resources and rationally allocating manpower can effectively reduce migration costs. Furthermore, by using AI to predict the optimal switching time and dynamically adjust migration parameters, database migration can be completed within seconds of downtime. Compared to traditional methods, this significantly reduces downtime and improves business continuity. During the migration process, real-time monitoring and adjustment of migration parameters ensures that the target database reaches a stable state before the switch, and that the accuracy and integrity of the data migration meet requirements. This allows for maximum business continuity during traffic switching, minimizing downtime and avoiding business losses due to data migration issues. This invention achieves efficient, reliable, and low-cost database migration through a pre-trained migration knowledge graph model and multi-objective optimization strategies. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 A schematic diagram of an embodiment of the AI-assisted database migration method provided by the present invention; Figure 2 The creation of the AI-assisted database migration method provided by this invention Figure 1 A schematic diagram of an embodiment of a transfer knowledge graph model; Figure 3 For the present invention Figure 1 A schematic diagram of an embodiment of S100; Figure 4 For the present invention Figure 1 A schematic diagram of an embodiment of S200; Figure 5 For the present invention Figure 1 A schematic diagram of an embodiment of S300; Figure 6 For the present invention Figure 1 A schematic diagram of an embodiment of the S400; Figure 7 A schematic diagram of an embodiment of the AI-assisted database migration device provided by the present invention; Figure 8 A schematic diagram of an embodiment of the electronic device provided by the present invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0020] In the description of the embodiments of the present invention, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0021] The terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature.
[0022] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] Before demonstrating the embodiments, the following terms will be explained.
[0024] TPS (Transactions Per Second) is a metric that measures the number of transactions a system can process per unit of time. A transaction typically refers to a complete business process; for example, in an e-commerce system, the entire process from a user browsing products to placing an order and making payment can be considered a transaction. The higher the TPS value, the greater the volume of transactions the system can handle per unit of time, and the stronger the system's processing capacity.
[0025] QPS (Queries Per Second) is a metric that measures the number of query requests a system can process per unit of time. A query request typically refers to a data query operation initiated by a user to the system. For example, in a search engine, a user's action of entering keywords to search can be considered a query request. The higher the QPS value, the more query requests the system can process per unit of time, and the stronger the system's responsiveness.
[0026] LOB (Large Object Blob) is used to store large amounts of data, such as text, images, audio, or video. In databases, the LOB data type can be used to store large blocks of binary or character data.
[0027] Graph Neural Networks (GNNs) are deep learning models used to process graph-structured data. By learning the feature representations of nodes and edges in a graph, GNNs can effectively handle complex relationships and structural information within the graph. GNNs have wide applications in many fields, such as social network analysis, molecular structure prediction, recommender systems, and traffic flow prediction.
[0028] This invention provides an AI-assisted database migration method, apparatus, device, and medium, which are described below.
[0029] Figure 1 This is a schematic diagram of an embodiment of the AI-assisted database migration method provided by the present invention, as shown below. Figure 1 As shown, AI-assisted database migration methods include: S100: A pre-trained transfer knowledge graph model generates transfer prediction results based on the feature information of the source and target databases.
[0030] It should be noted that feature extraction is performed on the source and target databases in this transfer task to obtain feature information of the source and target databases participating in the task. This feature information is then input into the pre-trained transfer knowledge graph model in the following example, and the transfer knowledge graph model outputs the transfer prediction result based on the feature information.
[0031] S200. Based on minimizing downtime, data loss, and migration cost as optimization objectives, an optimal migration strategy is generated according to the migration prediction results. The optimal migration strategy includes migration parameters.
[0032] It should be noted that: downtime refers to the time the source database is offline for data migration. Data loss refers to the extent of data loss during the migration process due to various reasons (such as network failures, migration tool errors, etc.). Migration cost includes the resource costs used during the migration process (such as network bandwidth, computing resources, etc.). A reward function is defined with the optimization objectives of minimizing downtime, minimizing data loss, and minimizing migration cost. Taking into account downtime, data loss, and migration cost, the Proximity Policy Optimization (PPO) algorithm is used to output the optimal migration strategy based on the migration prediction results. The optimal migration strategy is the most stable and effective migration scheme that achieves the minimization of the three objectives (i.e., minimizing downtime, minimizing data loss, and minimizing migration cost). The optimal migration strategy includes migration parameters, including concurrency-related parameters (including the number of concurrent worker threads / processes, the number of concurrent connections), data batch processing parameters (including batch size, data shard size), network and resource allocation parameters (including bandwidth utilization limits, transmission compression levels), and on / off parameters for data consistency assurance mechanisms (including enabling / disabling dual write buffers, and the verification frequency of flashback queries).
[0033] S300. While starting the data migration task according to the optimal migration strategy, monitor the data playback status and adjust the migration parameters of the data migration task according to the monitoring results.
[0034] It should be noted that during the data migration process, a data replay test is performed on the target database. Data replay refers to re-executing data operations (such as insert, update, and delete) in the source database on the target database to verify the accuracy and completeness of the data migration. Metrics for monitoring the data replay status include the success rate of data operations, data integrity, and data performance metrics (such as query response time). Then, the migration parameters of the data migration task are adjusted based on the monitoring results.
[0035] S400. Based on the monitoring results, predict the optimal switching time and assess the rollback risk, and adjust the execution status of the data migration task according to the assessment results.
[0036] It should be noted that during the data migration task, the data playback status is continuously monitored in real time. This includes monitoring the data recovery status before and after adjusting the migration parameters. Based on the real-time monitoring results, the optimal switchover timing is predicted, and the rollback risk is assessed. Rollback risk refers to the difficulty and risk of switching the source database back to the target database if problems occur during the switchover process. Then, the execution status of the data migration task is adjusted based on the rollback risk assessment results.
[0037] In summary, the AI-assisted database migration method provided in this invention first generates migration prediction results through a pre-trained migration knowledge graph model. This allows for the early identification of potential challenges and risks during the migration process, enabling targeted migration strategies. This significantly reduces the probability of migration failure and increases the success rate of migrating data from the source database to the target database. Real-time monitoring of data playback status and adjustment of migration parameters during the migration process allows for timely detection and resolution of problems, further ensuring the accuracy and integrity of data migration and thus improving the success rate. Furthermore, the method optimizes the migration process and selects migration tools and parameters with the goal of minimizing downtime, data loss, and migration costs. For example, optimizing migration parameters improves data migration efficiency and reduces downtime, thereby mitigating losses caused by business downtime. Simultaneously, selecting cost-effective hardware and software resources and allocating manpower appropriately can effectively reduce migration costs. Furthermore, by using AI to predict the optimal switching time and dynamically adjust migration parameters, database migration can be completed within seconds of downtime. Compared to traditional methods, this significantly reduces downtime and improves business continuity. During the migration process, real-time monitoring and adjustment of migration parameters ensures that the target database reaches a stable state before the switch, and that the accuracy and integrity of the data migration meet requirements. This allows for maximum business continuity during traffic switching, minimizing downtime and avoiding business losses due to data migration issues. This invention achieves efficient, reliable, and low-cost database migration through a pre-trained migration knowledge graph model and multi-objective optimization strategies.
[0038] In some embodiments of the present invention, such as Figure 2 As shown, it also includes: S010. Obtain the historical migration dataset; the historical migration dataset includes migration records of the database, and each migration record includes snapshot data before migration, running logs, and migration result labels.
[0039] It's important to note that historical migration datasets (e.g., historical migration data from 2000+ user groups) are obtained from a database migration management system, log server, or dedicated data warehouse. These datasets contain detailed information about multiple actual migration operations, including but not limited to source database type, version, data volume, peak TPS, network bandwidth, tools used, downtime, and reasons for failure. Multiple migration records can be compiled based on the detailed information for each migration operation. Each migration record includes a snapshot of the data before migration, runtime logs, and a migration result label. The migration result label records the migration outcome, such as success, failure, downtime, and data loss. Of course, the acquired data can be cleaned and formatted to ensure its integrity and consistency. For example, this includes removing duplicate records, filling in missing values, and standardizing the data format.
[0040] S020. Obtain the running characteristics and resource characteristics based on the running logs, and obtain the structural characteristics of each database based on the snapshot data before migration.
[0041] It should be noted that the following steps are taken to extract operational features from the operation logs: Operational features include the TPS curve (changes in transactions per second during the migration process), QPS peak (the highest number of queries per second during the migration process), and the proportion of long transactions (the proportion of long transactions exceeding a certain time threshold in the total number of transactions during the migration process). Resource features are also extracted from the operation logs, including available bandwidth (the actual network bandwidth used during the migration process), target database specifications (the hardware configuration of the target database, such as the number of CPU cores, memory size, and storage capacity), and network latency (network latency during the migration process). Data mining techniques or statistical analysis methods can be used to parse and process the operation logs to extract these operational and resource features.
[0042] In addition, the structural features of the database are extracted from the snapshot data before migration. These structural features include the number of tables (the number of tables in the database), the number of indexes (the number of indexes in the database), the proportion of LOB fields (the proportion of large object fields in the database), and the complexity of triggers / stored procedures (i.e., the complexity of triggers and stored procedures, such as the number of lines of code, nesting depth, etc.).
[0043] S030. Construct a heterogeneous graph based on the running log, the migration result label, and the snapshot data before migration; the heterogeneous graph includes node types, node attributes, and edge relationships between connected nodes; the node types include source database nodes, target database nodes, and migration task nodes.
[0044] It should be noted that: A Generative Neural Network (GNN) is used to associate the feature information of the source and target databases with the migration result labels output by the migration knowledge graph model in the above embodiment, forming a migration knowledge graph (i.e., the heterogeneous graph of this invention). The heterogeneous graph is a graph structure containing different types of nodes and edge relationships connecting these nodes. Node types include source database nodes, target database nodes, and migration task nodes (representing specific migration tasks). The node attributes of source database nodes include the structural and operational characteristics of the source database; the node attributes of target database nodes include the structural, resource, and operational characteristics of the target database; and the node attributes of migration task nodes include migration result labels (such as success, failure, downtime, data loss, etc.). The edge relationships represent the relationships between source database nodes and migration task nodes, as well as the relationships between migration task nodes and target database nodes. The attributes of the edges can include information such as migration tools and migration strategies.
[0045] Using graph databases or graph data structure tools, the extracted node and edge information is organized into a heterogeneous graph. That is, for each migration record, corresponding source database nodes, target database nodes, and migration task nodes are created, and edge relationships between nodes are established based on the information in the migration record to ensure that the nodes and edge relationships in the heterogeneous graph can accurately reflect the content in the historical migration dataset.
[0046] S040. The heterogeneous graph is trained using a graph neural network to obtain the transfer knowledge graph model, which is used to output the transfer prediction result based on the feature information of the input source database and the target database.
[0047] It's important to note that, based on the characteristics of the heterogeneous graphs, a suitable graph neural network architecture should be selected, such as GraphSAGE or GAT (Graph Attention Networks). The constructed heterogeneous graph is used as input, and the graph neural network is trained. The training objective is to learn the complex relationships between source database nodes, target database nodes, and transfer task nodes, and to predict the transfer results. During training, transfer result labels are used as supervision information, and the model parameters of the transfer knowledge graph model are optimized using the backpropagation algorithm. A portion of the historical transfer dataset is used as a validation set to evaluate the performance of the transfer knowledge graph model. By adjusting model parameters and optimizing training strategies, the accuracy and generalization ability of the transfer knowledge graph model can be improved. Alternatively, the transfer knowledge graph model can be updated periodically, incorporating new transfer records into the training set to maintain its timeliness and adaptability.
[0048] In this embodiment, a high-efficiency, accurate, and intelligent database migration knowledge graph model is constructed by building a heterogeneous graph and training it with a graph neural network. This model can learn the complex relationships between the source database, the target database, and the migration task, thus providing more accurate migration prediction results. The model's output migration prediction results can provide important basis for the formulation of migration strategies. For example, based on the predicted downtime and data loss, appropriate migration tools and parameters can be selected to optimize the migration strategy and improve the success rate and efficiency of the migration. Furthermore, the migration knowledge graph model can automatically learn and extract useful information from historical migration data, reducing the workload of manual analysis and decision-making. Through the model's predictions and suggestions, the migration process can be automated and intelligentized, improving the efficiency and reliability of the migration. Moreover, the model can predict potential risks during the migration process, such as excessive downtime and data loss, and identify these risks in advance and take corresponding measures to effectively reduce the uncertainty and risk during the migration process. Furthermore, the collection and organization of historical migration datasets, as well as the construction and training of the migration knowledge graph model, help accumulate and pass on migration experience. New migration tasks can draw on past experience to avoid repeating mistakes and improve the overall quality of the migration. Moreover, the model can adapt to different types of database migration tasks, including homogeneous database migration and heterogeneous database migration. In addition, by continuously updating and optimizing the migration knowledge graph model, it can cope with ever-changing migration needs and technical environments.
[0049] In some embodiments of the present invention, such as Figure 3 As shown, step S100 includes: S110. Extract the feature information of the source database and the target database to be migrated; the feature information includes structural features, operational features and resource features.
[0050] It should be noted that database management tools (such as MySQL Workbench, Oracle SQL Developer) or self-developed scripts can be used to extract the above-mentioned feature information from the source database and the target database to be migrated.
[0051] S120. Standardize and encode the extracted features to generate standardized feature vectors.
[0052] It should be noted that the extracted structural features, operational features, and resource features are normalized to a unified interval of [0, 1]. The normalization formula is shown below: Xnorm=(X-Xmin) / (Xmax-Xmin); Where X is the original feature value corresponding to any one of the structural features, operational features, and resource features, and Xmin and Xmax are the minimum and maximum values of that feature, respectively.
[0053] The original feature values are transformed into a standard normal distribution using the following formula: Xstd = (X - μ) / σ; Where μ is the mean of any one of the structural, operational, and resource characteristics, and σ is the standard deviation of any one of the structural, operational, and resource characteristics.
[0054] For categorical features (such as database type, version, etc.), One-Hot encoding is used to convert them into numerical vectors. For ordinal categorical features (such as database version number), numerical encoding is used to convert them into numerical values. The standardized and encoded feature values are combined into a feature vector. For example, a feature vector can be represented as: F = [f1, f2, ..., fn], where fi is the standardized or encoded value of the i-th feature.
[0055] S130. Input the feature vector into the transfer knowledge graph model to output the transfer prediction result; the transfer prediction result includes the success probability, estimated downtime and error rate.
[0056] It should be noted that the generated feature vector F is input into the pre-trained transfer knowledge graph model. The transfer knowledge graph model (as shown in the figure, a GNN) outputs the transfer prediction result based on the input feature vector through graph structure propagation and learning. The transfer prediction result includes the success probability, estimated downtime, and error rate. The success probability refers to the probability that the transfer knowledge graph model predicts the transfer will succeed, ranging from [0, 1]. The estimated downtime refers to the predicted downtime during the transfer process, measured in seconds or minutes. The error rate refers to the predicted error rate during the transfer process, ranging from [0, 1].
[0057] In this embodiment, by extracting detailed feature information (including structural features, operational features, and resource features) and performing standardization and encoding transformation, the generated feature vectors can more comprehensively reflect the characteristics of the source and target databases. This enables the transfer knowledge graph model to make more accurate migration predictions and improves the reliability of the prediction results. Furthermore, standardization and encoding transformation can eliminate the differences in dimensions and distributions between different features, giving the transfer knowledge graph model better generalization ability for different types of database migration tasks. Regardless of how the specific details of the migration task change, the transfer knowledge graph model can make effective predictions based on standardized feature vectors. Moreover, the process of extracting feature information and performing standardization can be automated, reducing the need for manual intervention and making the pre-migration preparation work more efficient and standardized, thus reducing the complexity and risk of migration. Furthermore, the migration prediction results (success probability, estimated downtime, and error rate) output by the migration knowledge graph model provide a scientific basis for migration decisions. Based on these predictions, potential risks and problems can be identified in advance, and corresponding optimization and adjustments can be made to formulate reasonable migration strategies and optimize migration parameters. This helps reduce potential downtime and data loss during the migration process, lower migration costs and risks, and improve the success rate and efficiency of the migration. Moreover, the migration prediction results output by the migration knowledge graph model provide detailed reference information for the migration process, making it more transparent and controllable. These prediction results allow for better monitoring of the migration process, timely identification and resolution of problems, and improved overall migration quality. In summary, through the above implementation methods, efficient and accurate prediction of database migration tasks can be achieved, providing strong support for migration decisions and significantly improving the overall performance and reliability of database migration.
[0058] In some embodiments of the present invention, such as Figure 4 As shown, step S200 includes: S210. Establish a multi-objective optimization reward function with minimizing the downtime, the amount of data loss, and the migration cost as optimization objectives.
[0059] It should be noted that a multi-objective optimization reward function is constructed, with the objectives of minimizing downtime, minimizing data loss, and minimizing migration cost. The multi-objective optimization reward function can be expressed as: Reward = -(λ1×T) down +λ2×L loss +λ3×C cost ) ; in, T down The downtime is mentioned. Lloss The amount of data loss, C cost The migration cost is defined by λ1, λ2, and λ3, which are weighting coefficients greater than zero, used to balance the priorities of different optimization objectives. These weights can be adjusted according to actual business needs.
[0060] S220. Based on the migration prediction results, select candidate migration strategies that maximize the reward function and satisfy the constraints, including that the migration cost is lower than the budget threshold, the downtime is lower than the business time window, and the migration success rate is higher than the safety threshold.
[0061] It should be noted that the migration prediction results (success probability, estimated downtime, error rate, etc.) are used in conjunction with a multi-objective optimization reward function to select candidate migration strategies that satisfy the constraints and maximize the reward function. Specifically, an initial set is generated, containing multiple candidate migration strategies that meet the constraints. The migration prediction model is used to calculate the migration prediction results (including success probability, estimated downtime, and error rate) for each candidate strategy. The data loss is calculated based on the error rate, the downtime is calculated based on the estimated downtime, and the migration cost is calculated by combining the error rate, success probability, and estimated downtime. Success probability and migration cost are inversely correlated, error rate and migration cost are positively correlated, and estimated downtime and migration cost are positively correlated. That is, the lower the success probability, the higher the migration cost; the higher the error rate, the higher the migration cost; and the longer the estimated downtime, the higher the migration cost. To minimize downtime, the efficiency of data migration needs to be considered, including data transmission speed and data processing speed during the migration process. For example, if the data volume is very large, a high-bandwidth data transmission method needs to be selected, and efficient parallel data processing algorithms should be used to accelerate the migration speed. To minimize data loss, a data verification mechanism needs to be designed to perform integrity checks on the data before and after migration to ensure data consistency. At the same time, data backup and recovery strategies should be adopted to ensure timely recovery in the event of data loss.
[0062] Thus, after obtaining the downtime, data loss, and migration cost based on the migration prediction results, the reward function value is calculated, and the candidate migration strategy that maximizes the reward function value is selected as the optimal migration strategy. That is, the reward function value of each candidate migration strategy is calculated, and the migration strategy with the largest reward function value among all migration strategies that satisfy the constraints is selected as the candidate migration strategy.
[0063] S230. Calculate the risk score of each candidate migration strategy, and determine the candidate migration strategy with the lowest risk score as the optimal migration strategy; the optimal migration strategy includes a combination of migration tools, concurrency parameters, consistency mechanisms, and compression schemes.
[0064] It should be noted that if there is only one candidate migration strategy, this candidate migration strategy is directly determined as the optimal migration strategy. However, if multiple candidate migration strategies with the same and largest reward function value are selected through S220, then a risk score is calculated for each candidate migration strategy. The factors affecting the risk score can include data loss risk (related to the amount of data loss), rollback risk (related to the rollback probability after migration failure), and latency risk (related to latency and performance issues during the migration process).
[0065] The risk score can be expressed as: Risk Score i =αf ( L lossi ) +βProllback i +γDdelay i ; Where i is the index of the candidate migration strategy, and α, β, and γ are weighting coefficients used to balance the priority of different risk factors. Risk Score i It is the risk score of the i-th candidate migration strategy. L lossi It is the data loss amount of the i-th candidate migration strategy. f ( L lossi ) represents the data loss risk of the i-th candidate migration strategy. f ( L lossi )and L lossi They are positively correlated. Prollback i It represents the backoff risk of the i-th candidate migration strategy, which can be obtained through model evaluation. Ddelay i It represents the delay risk of the i-th candidate migration strategy, which can be predicted by the model.
[0066] Thus, after obtaining the risk scores of all candidate migration strategies using the above calculation formula, the candidate migration strategy with the lowest risk score is selected as the optimal migration strategy. The optimal migration strategy includes the migration tool combination, concurrency parameters, consistency mechanisms, and compression schemes. The migration tool combination refers to the selected migration tools, such as DMS+Kafka, self-developed dual-stream, and logical replication slots. Concurrency parameters include concurrency level and batch size. Batch size refers to the number of records (rows) read from the source database and transmitted to the target database at one time during the full migration or incremental data synchronization phase of the database migration. Concurrency level and batch size adapt to network RTT. Consistency mechanisms include dual-write buffers and flashback queries. The compression scheme is the selected compression method, such as ZSTD streaming compression.
[0067] For example, the reward function simultaneously optimizes downtime, data loss, and migration costs (resource usage fees or database setup costs that can be found in cloud vendor bills), outputting the optimal policy through Proximal Policy Optimization (PPO). PPO directly outputs actions (tool, N, bw_ratio, buff_mode, compress) to maximize the reward function; a lightweight simulator can obtain (s', r) within 1ms, completing millions of interactions; a GNN is integrated into the front end of the Actor / Critic, and backpropagation is performed using PPO loss, with graph embedding and policy optimization occurring simultaneously, minimizing downtime, data loss, and migration costs. Furthermore, the downtime, data loss, and migration cost of each migration task are labeled and fed back into the knowledge graph to update the GNN weights, achieving self-evolution of the migration knowledge graph model.
[0068] In this embodiment, a multi-objective optimized reward function comprehensively considers downtime, data loss, and migration costs to ensure that the migration process achieves optimal performance across multiple key metrics. This significantly improves migration performance and meets the business's demand for efficient and reliable migration. When selecting candidate migration strategies, strict adherence to business constraints (such as migration costs below budget thresholds, downtime below the business time window, and migration success rates above safety thresholds) ensures that the migration strategies meet actual business needs and avoids negative impacts on the business due to migration operations. Based on migration prediction results and the reward function, the risk score of each candidate migration strategy is evaluated, and the strategy with the lowest risk score is selected as the optimal migration strategy. This provides a scientific basis for migration decisions, reduces the subjectivity of human decision-making, improves the scientific rigor and rationality of migration strategy selection, effectively reduces potential risks during the migration process, and enhances the reliability and stability of the migration.
[0069] In some embodiments of the present invention, it further includes: The migration tool suite includes a dual-stream migration framework for transmitting full data and incremental logs in parallel. The consistency mechanism includes a double-write buffer mechanism and a flashback query mechanism.
[0070] It should be noted that the migration tool suite includes DMS+Kafka, self-developed dual-stream, and logical replication slots. The self-developed dual-stream refers to a "dual-concurrent data stream" migration framework implemented by the cloud vendor. Its core idea is to treat "full data" and "incremental logs" as independent data streams; the two streams run in parallel at the transport layer and can be replayed out of order at the application layer; eventual consistency is ensured through client-side merging (Merge-Worker), thus changing the "full-increment serial" migration to "dual-stream parallel" migration, shortening the overall migration window. Full data migration includes data extraction (extracting full data from the source database, including table data, indexes, views, etc.), data transmission (transmitting full data to the target database via the network), and data loading (loading full data into the target database). Incremental log migration includes log capture (capturing incremental logs such as MySQL's binlog or Oracle's redolog in the source database), log transmission (transmitting incremental logs to the target database via the network), and log application (applying incremental logs to the target database to maintain real-time data updates). Full data and incremental logs are transmitted in parallel to ensure real-time synchronization of incremental data during full data migration. This involves dynamically adjusting the transmission rates of both streams (full data migration stream and incremental log migration stream) based on network bandwidth and latency, ensuring the stability of both streams. At the application layer, the full data and incremental logs are merged to ensure eventual data consistency. Furthermore, row-level verification is performed during the merging process to ensure data integrity and consistency. If data conflicts (such as primary key conflicts) are detected, conflict resolution is performed according to preset rules, such as ignoring the conflict, updating the data, or logging the conflict.
[0071] The consistency mechanism includes a dual-write buffering mechanism and a flashback query mechanism. The dual-write buffering mechanism simultaneously writes incremental logs to the target database and a temporary message queue for buffering and retention. In the event of a failover, the buffered log data in the temporary message queue is used for rapid data compensation, ensuring the data integrity and consistency of the target database and preventing data loss. For example, incremental logs are simultaneously written to the target database (i.e., the normal incremental stream) and a temporary message queue (such as Kafka or a self-developed ring buffer), retaining log data for a certain time window (e.g., 5-10 minutes) in the temporary message queue. If a write failure or primary key conflict occurs in the target database during the failover, traffic is immediately switched back to the source database, and the "second copy" of data in the queue is used to quickly compensate the target database without needing to fetch the full data again. In this way, rapid data compensation using the log data in the temporary message queue ensures the data integrity and consistency of the target database.
[0072] The flashback query mechanism is used to retrieve data at the switchover point in time using the flashback function of the source database before and after the switchover. This data is then compared with the data already written to the target database at the row level for verification and repair. Row-level verification and repair ensure data consistency before and after the switchover, reducing the risk of migration failure due to data inconsistency. If the target database fails to write data or experiences a primary key conflict, the switchover immediately reverts to the source database, using buffered log data for compensation. A message queue (such as Kafka) is used as a temporary buffer to ensure high availability and persistence of the log data. For example, the flashback function of the source database (such as the binlog_flashback tool in MySQL 5.7 or AS OF in Oracle) instantly pulls back the data immediately before the switchover, verifies the row-level checksum, and records the current maximum binlog position or SCN at the proxy layer to ensure data consistency before and after the switchover. One second before the switchover, the current maximum binlog position or SCN is recorded. Within three seconds after the switchover, a flashback query is performed on the hot rows just written to the target database, comparing them row by row. If an inconsistency is found, a single-row REPLACE operation is immediately triggered instead of a full table rollback.
[0073] In this embodiment, by transmitting full data and incremental logs in parallel and merging them at the application layer, eventual data consistency is ensured, avoiding the long downtime issues associated with traditional full-increment serial migration methods. Furthermore, a dual-write buffer mechanism and a flashback query mechanism enable rapid data recovery in case of switchover failure, further reducing downtime. In summary, the dual-stream migration framework and consistency mechanism significantly improve the efficiency, reliability, and data consistency of database migration, reduce migration costs and risks, and meet business needs for efficient and reliable migration.
[0074] In some embodiments of the present invention, such as Figure 5As shown, the monitoring data playback status, and the adjustment of the migration parameters of the data migration task based on the monitoring results, include: S310. Start a shadow instance on the target database side to replay data in real time, while monitoring the replay latency and checksum error rate.
[0075] It's important to note that a lightweight shadow instance is launched on the target database side. This instance is used for real-time replay of the source database's binary logs (binlog) or other incremental log data. The shadow instance can be a standalone database instance or a lightweight middleware, depending on the type and architecture of the target database. The shadow instance receives incremental log data from the source database over the network and applies these logs to the target database in real time. Real-time replay ensures that the data in the target database remains synchronized with the source database, reducing data latency during migration. Monitoring tools (such as Prometheus, Grafana) or a self-developed monitoring system are used to collect and analyze the latency of the shadow instance's replay logs in real time, obtaining the replay latency (the time difference between generating logs from the source database and applying logs to the target database) and the checksum error rate (the proportion of erroneous data found during data verification out of the total data).
[0076] S320. When the playback delay exceeds the first delay time threshold, increase the migration concurrency or switch to a high-bandwidth transmission link.
[0077] It should be noted that a reasonable first latency threshold (e.g., 500 milliseconds) should be set based on business needs and network environment. When the replay latency exceeds this first latency threshold, a self-healing mechanism is triggered. This self-healing mechanism includes dynamically adjusting the concurrency of the migration task based on real-time monitored replay latency, i.e., the number of log data streams processed simultaneously. For example, if the replay latency continues to exceed the first latency threshold, the concurrency is gradually increased until the replay latency returns to the normal range. The self-healing mechanism also includes switching to a high-bandwidth transmission link. This involves pre-configuring multiple transmission links, including a high-bandwidth link. When the replay latency continues to exceed the first latency threshold, the system automatically switches to the high-bandwidth link using network management tools (such as a load balancer) or a self-developed script, ensuring a smooth switchover process without affecting the continuity of data transmission.
[0078] S330. When the checksum error rate exceeds the error rate threshold, row-level checksum repair is triggered.
[0079] It's important to note that a reasonable error rate threshold (e.g., 0.01%) should be set based on business needs and data quality requirements. When the checksum error rate exceeds this threshold, row-level validation and repair are triggered. Row-level validation involves performing row-by-row verification on the data already written to the target database, comparing the data in the source and target databases row by row. Database validation tools (such as MySQL's pt-table-checksum) or self-developed validation scripts can be used for row-level validation. If data inconsistency is found, the data in the target database is immediately repaired through a proxy layer or middleware to ensure data consistency. The repair operation can be a single-row update or a batch update, depending on the severity of the error.
[0080] In this embodiment, data is replayed in real time through shadow instances, and replay latency and checksum error rate are monitored in real time. This provides transparency to the migration process, facilitating timely problem detection and mitigation. Furthermore, the shadow instance, acting as an intermediate layer for data replay, provides additional reliability assurance, ensuring data integrity and consistency and reducing data latency during migration. Further, when the replay latency exceeds a first latency threshold, concurrency is dynamically adjusted and high-bandwidth links are switched. Based on the real-time monitored replay latency, the concurrency is dynamically adjusted to improve migration efficiency, or a high-bandwidth link is switched when necessary to ensure efficient data transmission and reduce resource waste. This optimizes resource utilization, quickly responds to network fluctuations, and ensures the stability of the migration process. Moreover, various self-healing mechanisms, such as increasing concurrency and switching to high-bandwidth links, flexibly address different network environments and data scales. When the checksum error rate exceeds the threshold, row-level checksum repair is automatically triggered, reducing the risk of migration failure due to network or data quality issues, minimizing the need for manual intervention, and improving the automation and reliability of the migration.
[0081] In some embodiments of the present invention, such as Figure 6 As shown, the step of predicting the optimal switchover timing and assessing rollback risks based on the monitoring results, and adjusting the execution status of the data migration task based on the assessment results, includes: S410. Monitor the playback delay and number of long transactions of the binary logs of the source database in the target database playback.
[0082] It's important to note that: Start a lightweight shadow instance on the target database side and use monitoring tools (such as Prometheus, Grafana) or a self-developed monitoring system to monitor the replay latency and the number of long transactions in the source database's binary log (binlog) in real time. Replay latency refers to the time difference between the generation of logs from the source database and the application of logs to the target database. The number of long transactions is the number of ongoing long transactions in the target database. The number of long transactions can be collected through the transaction monitoring functions provided by the database management system (such as MySQL's SHOW ENGINE INNODB STATUS or Oracle's V$TRANSACTION view).
[0083] S420. When it is determined that the playback delay is less than the second delay time threshold and the number of long transactions is zero, the optimal switching point is determined and the rollback probability is calculated; the second delay time threshold is less than the first delay time threshold.
[0084] It should be noted that a second delay threshold is set, which should be less than the first delay threshold (e.g., the second delay threshold is set to 300 milliseconds, and the first delay threshold is 500 milliseconds). The second delay threshold ensures that the latency during switching is as low as possible, thereby reducing the impact on business operations. When the replay latency is less than the second delay threshold (300 milliseconds) and the number of long transactions is zero, the optimal switching point is determined to have been reached. A pre-trained machine learning model (such as a regression network in an AI model) is used to calculate the rollback probability. This machine learning model, based on historical migration data and real-time monitoring data, assesses the risk of a rollback that might occur during the switch in the current state. The rollback probability calculation formula can be expressed as: P = f(replay latency, number of long transactions, other monitoring metrics); Where P is the backoff probability and f() is the pre-trained regression model.
[0085] S430. If the rollback probability is less than the probability threshold, the service traffic is switched from the source database to the target database. S440. If the rollback probability is greater than or equal to the probability threshold, delay the switch and re-evaluate the rollback probability.
[0086] It should be noted that a reasonable probability threshold (e.g., 5%) should be set. This threshold determines whether a switchover should be initiated. When the rollback probability is less than the threshold, a switchover command is sent to the Proxy (proxy server), which then switches business traffic from the source database to the target database. The switchover process should be as smooth as possible to ensure business continuity. The switchover time should be controlled within seconds (e.g., 3 seconds). When the rollback probability is greater than or equal to the threshold, the switchover is delayed, and the rollback probability is reassessed. The delay time can be set to a fixed value (e.g., 30 seconds) or dynamically adjusted based on real-time monitoring data. During the delay, the replay delay and the number of long transactions are continuously monitored, and the rollback probability is recalculated.
[0087] For example, a 30-minute incremental log rollback window is maintained, and AI assesses the rollback probability in real time. If the rollback probability exceeds a probability threshold, the observation period is automatically extended. Before issuing a switchover command, the rollback probability must be calculated. If the rollback probability exceeds the probability threshold, the "extended observation period" is immediately initiated. The moment the rollback probability is determined to be greater than the probability threshold is the moment the rollback insurance is activated. During the observation period, 30 minutes of incremental logs are continuously retained, and the rollback probability is reassessed every second. A true traffic switchover is only allowed when the rollback probability falls below the probability threshold. If the probability does not decrease within 60 minutes, a manual alarm is triggered, and the switchover is terminated.
[0088] In this embodiment, by monitoring replay latency and the number of long transactions, the optimal state of the target database is ensured during the switchover, reducing the risk of switchover failure due to excessive latency or long transaction blocking. A pre-trained machine learning model is used to calculate the rollback probability, further assessing the switchover risk and improving the scientific rigor and reliability of the switchover decision. Furthermore, a second latency threshold is set to ensure the switchover latency is as low as possible, thereby reducing the impact on business operations. When the rollback probability is below the second latency threshold, business traffic is quickly switched, ensuring the switchover process is completed within seconds, reducing business interruption time. When the rollback probability is above the second latency threshold, the switchover is delayed and reassessed to avoid switching under high-risk conditions, reducing the risk of rollback due to switchover failure and ensuring data consistency and integrity. This application, through a dynamic monitoring and evaluation mechanism, can adjust the switchover strategy based on real-time data, enhancing the flexibility and adaptability of the migration process. It supports flexible adjustment of thresholds and latency based on actual business needs and real-time monitoring data. By monitoring replay latency, the number of long transactions, and the rollback probability, detailed information about the migration process is provided, enhancing the transparency and controllability of the migration process. Furthermore, by dynamically adjusting the switchover strategy, unnecessary resource consumption is reduced. For example, it avoids switching under conditions of high latency or high rollback risk, thereby optimizing resource utilization. This application can significantly improve the security, reliability, and efficiency of switching during database migration, reduce business downtime, lower rollback risk, and meet the business's need for efficient and reliable migration.
[0089] In some embodiments of this invention, a Dependency Graph Convolutional Network (Dep-GCN) can be introduced to capture implicit dependencies such as foreign keys, triggers, and DBLinks, preventing functional loss after migration. Specifically, Dep-GCN transforms all "foreign keys, triggers, DBLinks, and nested views" into edges of a directed heterogeneous graph, labeling them "must be migrated in the same batch." It automatically outputs a list of objects that "must be migrated in the same batch" through node classification, ensuring that the AI planner does not miss any implicit dependencies and completely solves the problem of "functional loss after migration."
[0090] In some embodiments of the present invention, the entire data can be processed in parallel by partition key or hash-based fragmentation, with AI predicting the optimal fragment size to avoid hotspots. Alternatively, ZSTD streaming compression can be applied to cold partitions during the full data processing stage, reducing the amount of data transmitted by 40%.
[0091] In some embodiments of the present invention, each checksum and switching instruction can be written into the consortium blockchain for audit traceability. Additionally, sensitive fields (such as phone numbers) can be processed by an AI-based de-identification model before transmission to maintain format consistency.
[0092] To better implement the AI-assisted database migration method in this invention embodiment, based on the AI-assisted database migration method, correspondingly, as follows: Figure 7 As shown, this embodiment of the invention also provides an AI-assisted database migration device 700, comprising: The prediction module 701 is used to generate transfer prediction results based on the feature information of the source database and the target database, using a pre-trained transfer knowledge graph model. The generation module 702 is used to generate an optimal migration strategy based on the migration prediction results, with the optimization objectives of minimizing downtime, data loss, and migration cost. The optimal migration strategy includes migration parameters. The running module 703 monitors the data playback status while starting to execute the data migration task according to the optimal migration strategy, and adjusts the migration parameters of the data migration task according to the monitoring results. The processing module 704 is used to predict the optimal switching time based on the monitoring results and assess the rollback risk, and adjust the execution status of the data migration task based on the assessment results.
[0093] The AI-assisted database migration device 700 provided in the above embodiments can implement the technical solutions described in the above AI-assisted database migration method embodiments. The specific implementation principles of each module or unit can be found in the corresponding content in the above AI-assisted database migration method embodiments, and will not be repeated here.
[0094] like Figure 8As shown, the present invention also provides an electronic device 800. The electronic device 800 includes a processor 801, a memory 802, and a display 803. Figure 8 Only some components of the electronic device 800 are shown, but it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0095] In some embodiments, processor 801 may be a central processing unit (CPU), microprocessor, or other data processing chip, used to run program code stored in memory 802 or process data, such as the AI-assisted database migration method of the present invention.
[0096] In some embodiments, processor 801 may be a single server or a group of servers. The server group may be centralized or distributed. In some embodiments, processor 801 may be local or remote. In some embodiments, processor 801 may be implemented on a cloud platform. In one embodiment, the cloud platform may include a private cloud, public cloud, hybrid cloud, community cloud, distributed cloud, intranet, multi-cloud, etc., or any combination thereof.
[0097] In some embodiments, memory 802 may be an internal storage unit of electronic device 800, such as a hard disk or memory of electronic device 800. In other embodiments, memory 802 may also be an external storage device of electronic device 800, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. equipped on electronic device 800.
[0098] Furthermore, the memory 802 may include both internal storage units of the electronic device 800 and external storage devices. The memory 802 is used to store application software and various types of data installed on the electronic device 800.
[0099] In some embodiments, display 803 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 803 is used to display information from electronic device 800 and to display a visual user interface. Components 801-803 of electronic device 800 communicate with each other via a system bus.
[0100] In one embodiment, when processor 801 executes the database migration program in memory 802, the following steps may be performed: Based on the optimization objectives of minimizing downtime, data loss, and migration cost, an optimal migration strategy is generated according to the migration prediction results. The optimal migration strategy includes migration parameters. While executing the data migration task according to the optimal migration strategy, the data playback status is monitored, and the migration parameters of the data migration task are adjusted according to the monitoring results. Based on the monitoring results, predict the optimal switching time and assess the rollback risk, and adjust the execution status of the data migration task according to the assessment results.
[0101] It should be understood that when the processor 801 executes the database migration program in the memory 802, in addition to the functions mentioned above, it can also perform other functions, as detailed in the description of the corresponding method embodiments above.
[0102] Furthermore, this embodiment of the invention does not specifically limit the type of electronic device 800 mentioned. Electronic device 800 can be a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, laptop computer, or other portable electronic device. Exemplary embodiments of portable electronic devices include, but are not limited to, portable electronic devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable electronic device can also be other portable electronic devices, such as a laptop computer with a touch-sensitive surface (e.g., a touch panel). It should also be understood that in some other embodiments of the invention, electronic device 800 may not be a portable electronic device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0103] Accordingly, this application also provides a computer-readable storage medium for storing computer-readable programs or instructions. When the programs or instructions are executed by a processor, they can implement the steps or functions of the AI-assisted database migration methods provided in the above-described method embodiments.
[0104] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.), and the computer program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0105] The above provides a detailed description of the AI-assisted database migration method, apparatus, device, and medium provided by this invention. Specific examples have been used to illustrate the principles and implementation methods of this invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this invention. At the same time, those skilled in the art will recognize that there will be changes in the specific implementation methods and application scope based on the ideas of this invention. Therefore, the content of this specification should not be construed as a limitation of this invention.
Claims
1. An AI-assisted database migration method, characterized in that, include: Based on a pre-trained transfer knowledge graph model, transfer prediction results are generated according to the feature information of the source database and the target database. Based on the optimization objectives of minimizing downtime, data loss, and migration cost, an optimal migration strategy is generated according to the migration prediction results. The optimal migration strategy includes migration parameters. While executing the data migration task according to the optimal migration strategy, the data playback status is monitored, and the migration parameters of the data migration task are adjusted according to the monitoring results. Based on the monitoring results, predict the optimal switching time and assess the rollback risk, and adjust the execution status of the data migration task according to the assessment results.
2. The AI-assisted database migration method according to claim 1, characterized in that, Also includes: Obtain the historical migration dataset; the historical migration dataset includes migration records in the database, and each migration record includes snapshot data before migration, runtime logs, and migration result labels; The runtime characteristics and resource characteristics are obtained from the runtime logs, and the structural characteristics of each database are obtained from the pre-migration snapshot data. A heterogeneous chart is constructed based on the running log, the migration result labels, and the pre-migration snapshot data; The heterogeneous graph includes node types, node attributes, and edge relationships between connecting nodes; the node types include source database nodes, target database nodes, and migration task nodes. The heterogeneous graph is trained using a graph neural network to obtain the transfer knowledge graph model, which is used to output the transfer prediction result based on the feature information of the input source database and the target database.
3. The AI-assisted database migration method according to claim 2, characterized in that, The pre-trained transfer knowledge graph model generates transfer prediction results based on feature information from the source and target databases, including: Extract feature information from the source database and the target database to be migrated; the feature information includes structural features, operational features, and resource features; The extracted features are standardized and encoded to generate standardized feature vectors; The feature vector is input into the transfer knowledge graph model to output the transfer prediction result; the transfer prediction result includes the success probability, the estimated downtime, and the error rate.
4. The AI-assisted database migration method according to claim 1, characterized in that, The optimal migration strategy is generated based on the migration prediction results, with the optimization objectives of minimizing downtime, data loss, and migration cost. This includes: A multi-objective optimization reward function is established with the optimization objectives of minimizing the downtime, the amount of data loss, and the migration cost. Based on the migration prediction results, candidate migration strategies that maximize the reward function and satisfy the constraints are selected. The constraints include that the migration cost is lower than the budget threshold, the downtime is lower than the business time window, and the migration success rate is higher than the safety threshold. Calculate the risk score for each candidate migration strategy, and determine the candidate migration strategy with the lowest risk score as the optimal migration strategy; the optimal migration strategy includes a combination of migration tools, concurrency parameters, consistency mechanisms, and compression schemes.
5. The AI-assisted database migration method according to claim 4, characterized in that, Also includes: The migration tool suite includes a dual-stream migration framework for transmitting full data and incremental logs in parallel. The consistency mechanism includes a double-write buffer mechanism and a flashback query mechanism.
6. The AI-assisted database migration method according to claim 1, characterized in that, The monitoring data playback status, and the adjustment of the migration parameters of the data migration task based on the monitoring results, include: Start a shadow instance on the target database side to replay data in real time, while monitoring the replay latency and checksum error rate; When the playback delay exceeds the first delay time threshold, increase the migration concurrency or switch to a high-bandwidth transmission link; When the checksum error rate exceeds the error rate threshold, row-level checksum repair is triggered.
7. The AI-assisted database migration method according to claim 6, characterized in that, The step of predicting the optimal switching timing and assessing rollback risks based on the monitoring results, and adjusting the execution status of the data migration task based on the assessment results, includes: Monitor the playback latency and number of long transactions of the binary logs of the source database in the target database playback process; When it is determined that the replay delay is less than the second delay time threshold and the number of long transactions is zero, the optimal switching point is determined and the rollback probability is calculated; the second delay time threshold is less than the first delay time threshold. If the rollback probability is less than the probability threshold, the service traffic will be switched from the source database to the target database; If the rollback probability is greater than or equal to the probability threshold, delay the switch and re-evaluate the rollback probability.
8. An AI-assisted database migration device, characterized in that, include: The prediction module is used to generate transfer prediction results based on the feature information of the source database and the target database, based on the pre-trained transfer knowledge graph model. The generation module is used to generate an optimal migration strategy based on the migration prediction results, with the optimization objectives of minimizing downtime, data loss, and migration cost. The optimal migration strategy includes migration parameters. The running module monitors the data playback status while starting to execute the data migration task according to the optimal migration strategy, and adjusts the migration parameters of the data migration task according to the monitoring results. The processing module is used to predict the optimal switching time based on the monitoring results and assess the rollback risk, and adjust the execution status of the data migration task based on the assessment results.
9. An electronic device, characterized in that, Including memory and processor, among which, The memory is used to store programs; The processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the AI-assisted database migration method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer-readable programs or instructions, which, when executed by a processor, can perform the steps in the AI-assisted database migration method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Data migration method and device, equipment and storage medium
CN117687993A
Machine Learning Predictions for Database Migrations
US20210241131A1
Cited By
A database migration engineering experience reuse method, device and medium
CN122220324A