Database upgrade methods, devices, storage media and electronic equipment

CN120832353BActive Publication Date: 2026-08-14BEIJING JINGDONG YUANSHENG TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-19
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0005]本公开的目的在于提供一种数据库升级方法、数据库升级装置、存储介质及电子设备,旨在解决在数据库升级时需停止数据写入以及数据一致性校验难度高的问题

Benefits of technology

[0040]在本公开的一些实施例所提供的技术方案中,通过构建与新版数据库同构的,且与旧版数据库同种数据库系统的复刻数据库,进而利用复刻数据库将旧版数据库中的数据迁移至新版数据库,在迁移初期进行数据双写,同时写入旧版数据库和新版数据库,当写入侧的第一校验完成后,开启数据双读,同时读取旧版数据库和新版数据库,当读取侧的第二校验完成后,则达到新、旧数据库的写入和读取一致,便实现了使用侧无感地进行数据迁移。这样一来,一方面数据迁移时在数据写入方面,无需停止数据写入,避免作业停止,用户使用侧无感;另一方面,可以同时从旧版或新版进行单源数据读取,进而通过构建的复刻数据库进行写入数据和读取数据的校验,降低数据一致性校验难度。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120832353B_ABST
    Figure CN120832353B_ABST
Patent Text Reader

Abstract

This disclosure relates to the field of data processing technology, specifically to a database upgrade method, a database upgrade apparatus, a storage medium, and an electronic device. The database upgrade method includes: constructing a replica database that is isomorphic to the new database and belongs to the same database system as the old database; writing incremental data to the old database in response to a data write request, and writing incremental data to the new database after migrating all data from the old database to the new database via the replica database; upon successful first verification, reading data from both the old and new databases in response to a data read request; and upon successful second verification, writing data to the new database in response to a data write request, and reading data from the new database in response to a data read request. The database upgrade method provided by this disclosure enables database upgrades without stopping data writing and reduces the difficulty of data consistency verification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, specifically to a database upgrade method, a database upgrade device, a storage medium, and an electronic device. Background Technology

[0002] As business grows and data specifications are upgraded, existing database tables are often redesigned and upgraded. This involves migrating data from the old database to the new database while ensuring a smooth migration, continuous support for data production, and data consistency.

[0003] However, existing database upgrade methods often require stopping data writing to the old database and enabling the new database only after the data migration is complete, due to differences in storage media and table structures between the new and old databases. This presents several challenges: firstly, the data migration process halts data writing, causing online operations to stop; secondly, the new and old databases have heterogeneous structures, making data consistency verification difficult; and thirdly, the single-source read switch limits data reading to either the old or new version.

[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this disclosure is to provide a database upgrade method, database upgrade device, storage medium, and electronic device, which aim to solve the problems of needing to stop data writing and the high difficulty of data consistency verification during database upgrade.

[0006] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part from practice of this disclosure.

[0007] According to one aspect of the present disclosure, a database upgrade method is provided, comprising: constructing a replica database that is isomorphic to the new version of the database and belongs to the same database system as the old version of the database;

[0008] In response to a data write request, incremental data is written to the old version database, and after all the data in the old version database is migrated to the new version database through the replica database, the incremental data is written to the new version database.

[0009] Based on the replica database, the incremental data written to the old database and the new database are subjected to a first verification, and when the first verification passes, data is read from the old database and the new database in response to a data read request.

[0010] Based on the replica database, a second verification is performed on the data read from the old database and the new database respectively. When the second verification passes, the data is written to the new database in response to a data write request, and the data is read from the new database in response to a data read request.

[0011] According to some embodiments of this disclosure, based on the foregoing scheme, the method further includes: migrating all data in the old database to the new database through the replica database, wherein migrating all data in the old database to the new database through the replica database includes:

[0012] The old database sends a first data update message to the first message queue;

[0013] The consumer program consumes the first message queue to write the full amount of data in the old database into the replica database after data specification transformation;

[0014] After the replica database successfully writes the full amount of data, it sends a second data update message to the second message queue.

[0015] The consumer program consumes the second message queue to write the full data in the replica database into the new database after data specification transformation.

[0016] According to some embodiments of this disclosure, based on the foregoing scheme, when writing incremental data to the old database in response to a data write request, and writing the incremental data to the new database after migrating all data in the old database to the new database through the replica database, the method further includes:

[0017] In response to a data read request, data is read from the legacy database.

[0018] According to some embodiments of this disclosure, based on the foregoing scheme, when the first verification passes, the method further includes:

[0019] In response to a data write request, incremental data is written to both the old database and the new database simultaneously.

[0020] According to some embodiments of this disclosure, based on the foregoing scheme, the step of writing incremental data to the old version database in response to a data write request, and writing the incremental data to the new version database after migrating all data in the old version database to the new version database through the replica database, includes:

[0021] In response to a data write request, the first interface is invoked to write the data to the legacy database via the second interface; and

[0022] The first interface is invoked to write data into the new database via the third interface.

[0023] According to some embodiments of this disclosure, based on the foregoing scheme, the step of writing data to the new version database in response to a data write request when the second verification passes includes: in response to the data write request, calling the third interface to write data to the new version database; wherein the parameters and return values ​​of the first interface and the third interface are consistent.

[0024] According to some embodiments of this disclosure, based on the foregoing scheme, the first verification of the incremental data written to the old version database and the new version database respectively based on the replicated database includes:

[0025] Extract the first, second, and third data that are written to the old database, the replica database, and the new database respectively in response to the same data write request;

[0026] Based on the core fields of the first data, the second data, and the third data, extract the first core attribute summary information, the second core attribute summary information, and the third core attribute summary information, respectively.

[0027] When the first core attribute summary information, the second core attribute summary information, and the third core attribute summary information are all the same, the first verification is considered to have passed.

[0028] According to some embodiments of this disclosure, based on the foregoing scheme, the second verification of data read from the old version database and the new version database respectively based on the replica database includes:

[0029] Extract the fourth, fifth, and sixth data read from the old database, the replica database, and the new database respectively in response to the same data read request;

[0030] Based on the core fields of the fourth data, the fifth data, and the sixth data, extract the fourth core attribute summary information, the fifth core attribute summary information, and the sixth core attribute summary information, respectively.

[0031] When the fourth core attribute summary information, the fifth core attribute summary information, and the sixth core attribute summary information are all the same, the second verification is considered to have passed.

[0032] According to a second aspect of the present disclosure, a database upgrade apparatus is provided, comprising:

[0033] The building module is used to build a replica database that is isomorphic to the new database and belongs to the same database system as the old database.

[0034] The dual-write module is used to respond to a data write request by writing incremental data to the old version database, and after migrating all the data in the old version database to the new version database through the replica database, write the incremental data to the new version database.

[0035] The dual-read module is used to perform a first verification on the incremental data written to the old database and the new database respectively based on the replica database, and when the first verification passes, it reads data from the old database and the new database respectively in response to a data read request;

[0036] The upgrade module is used to perform a second verification on the data read from the old version database and the new version database respectively based on the replica database, and when the second verification passes, write the data to the new version database in response to a data write request, and read the data from the new version database in response to a data read request.

[0037] According to a third aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the database upgrade method as described in the above embodiments.

[0038] According to a fourth aspect of the present disclosure, an electronic device is provided, characterized in that it includes: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the database upgrade method as described in the above embodiments.

[0039] The exemplary embodiments disclosed herein may have some or all of the following beneficial effects:

[0040] In some embodiments of this disclosure, a replica database is constructed that is isomorphic to the new database and uses the same database system as the old database. This replica database is then used to migrate data from the old database to the new database. During the initial migration phase, dual data writing is performed simultaneously in both the old and new databases. Once the first verification on the write side is complete, dual data reading is initiated, simultaneously reading from both the old and new databases. Once the second verification on the read side is complete, write and read consistency between the old and new databases is achieved, enabling seamless data migration for the user. This approach eliminates the need to stop data writing during migration, preventing job interruptions and ensuring a seamless user experience. Furthermore, it allows for simultaneous single-source data reading from either the old or new database, with the replica database used for write and read verification, reducing the difficulty of data consistency checks.

[0041] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0042] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:

[0043] Figure 1 The diagram illustrates a flowchart of a database upgrade method in the prior art.

[0044] Figure 2 The illustration schematically shows a flowchart of a database upgrade method according to an exemplary embodiment of the present disclosure;

[0045] Figure 3 This illustration schematically depicts a process for writing data to a new version of a database in an exemplary embodiment of this disclosure;

[0046] Figure 4 This illustration schematically depicts a data verification process according to an exemplary embodiment of the present disclosure;

[0047] Figure 5 This schematic diagram illustrates a database upgrade structure according to an exemplary embodiment of the present disclosure;

[0048] Figure 6 This schematic diagram illustrates the composition of a database upgrade apparatus according to an exemplary embodiment of the present disclosure;

[0049] Figure 7This schematic diagram illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure;

[0050] Figure 8 The schematic diagram illustrates the structure of a computer system of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0051] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art.

[0052] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this disclosure.

[0053] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0054] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0055] As business grows, it is necessary to upgrade the existing database. The new version of the database will be based on the old database table structure and will be expanded and redesigned. The new database tables and the old database tables will differ in storage media and table structure.

[0056] Figure 1 This diagram illustrates a flowchart of a database upgrade method in the prior art. (Refer to...) Figure 1 As shown, the existing database upgrade process is as follows:

[0057] 1. The old write interface stops writing old database data to the old master database v1;

[0058] 2. Perform data migration from the old database v1 to the new database v2;

[0059] 3. The database dual-write interface supports dual writing between the new database v2 and the old database v1;

[0060] 4. Set a switch to toggle data reading, which can read data from the new database v2 or the old database v1.

[0061] Existing database upgrade methods have the following drawbacks:

[0062] 1. Job Stoppage: Data migration requires stopping data writing, causing the online job to stop.

[0063] 2. Heterogeneous storage: The old database v1 and the new database v2 have heterogeneous structures, making data consistency verification more difficult.

[0064] 3. Single-source read: The read interface is set to read from a single source database, which can only read data from either the old or new version of the database.

[0065] To address the numerous shortcomings of existing technologies, this disclosure provides a database upgrade method that enables smooth data migration without interrupting data writing services during database upgrades and data migration. Furthermore, by introducing the Copilot auxiliary library, dual-source writing and delayed double-checking are implemented to ensure data consistency. Simultaneously, during data reading, the old and new versions of the database are compared and validated in real time.

[0066] The implementation details of the technical solutions of the embodiments of this disclosure are described in detail below.

[0067] Figure 2 This illustration schematically depicts a flowchart of a database upgrade method according to an exemplary embodiment of this disclosure. Figure 2 As shown, the database upgrade method includes steps S1 to S4:

[0068] Step S1: Construct a replica database that is isomorphic to the new database and uses the same database system as the old database.

[0069] Step S2: In response to the data write request, incremental data is written to the old version database, and after all the data in the old version database is migrated to the new version database through the replica database, the incremental data is written to the new version database.

[0070] Step S3: Based on the replica database, perform a first verification on the incremental data written to the old database and the new database respectively, and when the first verification passes, in response to the data read request, read data from the old database and the new database respectively;

[0071] Step S4: Perform a second verification on the data read from the old version database and the new version database respectively based on the replica database, and when the second verification passes, write the data to the new version database in response to the data write request, and read the data from the new version database in response to the data read request.

[0072] In some embodiments of this disclosure, a replica database is constructed that is isomorphic to the new database and uses the same database system as the old database. This replica database is then used to migrate data from the old database to the new database. During the initial migration phase, dual data writing is performed simultaneously in both the old and new databases. Once the first verification on the write side is complete, dual data reading is initiated, simultaneously reading from both the old and new databases. Once the second verification on the read side is complete, write and read consistency between the old and new databases is achieved, enabling seamless data migration for the user. This approach eliminates the need to stop data writing during migration, preventing job interruptions and ensuring a seamless user experience. Furthermore, it allows for simultaneous single-source data reading from either the old or new database, with the replica database used for write and read verification, reducing the difficulty of data consistency checks.

[0073] The following will describe in more detail the steps of the database upgrade method in this example embodiment, with reference to the accompanying drawings and embodiments.

[0074] In step S1, a replica database is constructed that is isomorphic to the new database and uses the same database system as the old database.

[0075] During data migration, the old database (denoted as M1) consists of existing database tables, and its storage structure is no longer suitable for business development, requiring an upgrade in its structure and storage. The upgraded new database (denoted as M3) is heterogeneous with the M1 tables, making direct comparison of the data between the two inconvenient.

[0076] Therefore, a Copilot database (denoted as M2) is constructed that is isomorphic to M3. The M2 table directly synchronizes data from the M1 table. Data is written to the M2 and M3 tables from two different channels respectively. Then, the data consistency is changed from comparing the heterogeneous M1 and M3 to comparing the isomorphic M2 and M3.

[0077] The older database M1 and the Copilot database M2 are in the same database system, while the newer database M3 can use a different database. In practical solutions, tables M1, M2, and M3 can also be stored in a unified database, which can be flexibly adjusted according to the technology selection.

[0078] Step S2: In response to the data write request, incremental data is written to the old version database, and after all the data in the old version database is migrated to the new version database through the replica database, the incremental data is written to the new version database.

[0079] Specifically, step S2 is the first stage of the database upgrade. In the first stage, when writing data, on the one hand, the data is migrated from the old database to the new database, and on the other hand, dual writing is performed, writing incremental data to both the old database and the new database at the same time.

[0080] In one embodiment of this disclosure, the method further includes: migrating all data in the old database to the new database through the replica database, specifically including the following steps: the old database sends a first data update message to a first message queue; a consumer program consumes the first message queue to write all data in the old database into the replica database after data specification conversion; after successfully writing the all data, the replica database sends a second data update message to a second message queue; the consumer program consumes the second message queue to write all data in the replica database into the new database after data specification conversion.

[0081] Incremental data is written to the old database using the original data writing process. Data is written to the new database through two channels: one is the indirect writing channel, which involves migrating all data in the old database, i.e., synchronizing from the old database M1 table to the Copilot database M2 table, and then indirectly writing to the new database M3 table; the other is the direct writing channel, which involves directly writing incremental data to the new database M3 table.

[0082] Figure 3 This illustration schematically depicts a process for writing data to a new version of a database according to an exemplary embodiment of this disclosure. (Reference) Figure 3 As shown:

[0083] Indirect write channel: After data is written to the old database table M1, a data change ID message is sent to message queue Q1. The consumer program then consumes Q1, retrieves the data details from table M1, performs data specification conversion, and writes it to table M2 in the Copilot database. Simultaneously, a data change message for M2 is sent to message queue Q2, which is then consumed by the consumer program and written to the homogeneous table M3.

[0084] Direct write channel: After converting the data obtained from the request through the facade interface, the data is directly written into the new version of the database M3 table.

[0085] Based on the above method, during the data writing process, it is not necessary to stop the data operation, and full and incremental data synchronization can be completed through the message system.

[0086] In one embodiment of this disclosure, in response to a data write request, incremental data is written to the old database, and after all data in the old database is migrated to the new database through the replica database, the incremental data is written to the new database, including: in response to a data write request, calling a first interface to write data to the old database through a second interface; and calling the first interface to write data to the new database through a third interface.

[0087] Specifically, the first interface (denoted as R1) is... Figure 3 The facade interface in the database uses facade interface R1 to call the second interface (denoted as R2) to write data to the old database M1, and to call the third interface (denoted as R3) to write data to the new database M3.

[0088] In one embodiment of this disclosure, when writing incremental data to the old database in response to a data write request, and when writing the incremental data to the new database after migrating all data in the old database to the new database through the replica database, the method further includes: reading data from the old database in response to a data read request.

[0089] Specifically, in the first phase of the database upgrade, data reading still only comes from the old database, and the original data reading method has not been changed to ensure the smooth operation of business.

[0090] Step S3: Based on the replicated database, perform a first verification on the incremental data written to the old database and the new database respectively, and when the first verification passes, in response to the data read request, read data from the old database and the new database respectively.

[0091] Specifically, in the dual-write process, a first verification is performed on the write side of the database. In one embodiment of this disclosure, the first verification of the incremental data written to the old database and the new database based on the replicated database includes: extracting first data, second data, and third data written to the old database, the replicated database, and the new database respectively in response to the same data write request; extracting first core attribute summary information, second core attribute summary information, and third core attribute summary information based on the core fields of the first data, the second data, and the third data; and determining that the first verification passes when the first core attribute summary information, the second core attribute summary information, and the third core attribute summary information are all the same.

[0092] Figure 4 This illustration schematically depicts a data verification process according to an exemplary embodiment of the present disclosure. Although the storage structures of the legacy database M1 table and the Copilot replica database M2 table are different, the core attribute information representing the data is the same. (See reference...) Figure 4 As shown, the core field C1 can be extracted from table M1 through the parsing program, and then the core attribute information summary D1 can be extracted from the core field C1; similarly, the core field C2 and the core attribute information summary D2 can be extracted from table M2; and the core field C2 and the core attribute information summary D3 can be extracted from table M3.

[0093] According to the data writing process above, when the core attribute information summary information of a piece of data corresponding to the same data writing request is equal in three different databases, that is, D1=D2 and D2=D3, then the data written through dual sources is considered to be the same, thus ensuring the consistency of data in the old and new databases.

[0094] Once the first verification passes, the second phase of the database upgrade begins. In this second phase, data writing continues to employ dual-write, meaning incremental data is simultaneously written to both the old database M1 and the new database M3. Data reading occurs simultaneously from both the old and new databases.

[0095] Step S4: Perform a second verification on the data read from the old version database and the new version database respectively based on the replica database, and when the second verification passes, write the data to the new version database in response to the data write request, and read the data from the new version database in response to the data read request.

[0096] In one embodiment of this disclosure, the second verification of data read from the old database and the new database based on the replica database includes: extracting fourth, fifth, and sixth data read from the old database, the replica database, and the new database respectively in response to the same data read request; extracting fourth, fifth, and sixth core attribute summary information based on the core fields of the fourth, fifth, and sixth data; and determining that the second verification passes when the fourth, fifth, and sixth core attribute summary information are all the same.

[0097] Specifically, the second verification method is similar to the first verification method, both of which use data from the three databases M1, M2 and M3 for consistency verification, which will not be elaborated on further here.

[0098] When the second verification passes, the third phase of the database upgrade begins. In the third phase, data is written only to the new version of database M3, and data is read only from the new version of database M3, thus completing the upgrade process from the old version of database to the new version.

[0099] In one embodiment of this disclosure, when the second verification passes, in response to a data write request, data is written to the new version of the database, including: in response to the data write request, calling the third interface to write the data to the new version of the database; wherein the parameters and return values ​​of the first interface and the third interface are the same.

[0100] Specifically, after a period of stable operation, when the second verification passes, the facade interface R1 can be taken offline, stopping the writing and reading of data in the old database, which is completely replaced by the new database interface R3 and the new database M3.

[0101] Figure 5 This schematic diagram illustrates a database upgrade structure according to an exemplary embodiment of the present disclosure. (Reference) Figure 5 As shown, the data is generated through the operating platform O1, the fusion module O2, and the intelligence module O3.

[0102] Data writing:

[0103] like Figure 5 As shown, the first interface is the facade interface R1, the R2 interface is the interface for the old version of the database, and the R3 interface is the interface for the new version of the database.

[0104] During the parallel use of the old and new databases, i.e. the first and second phases of the database upgrade, the R1 interface calls the old database interface R2 and the new database interface R3 respectively to complete the dual writing of data.

[0105] When the second verification passes, the third stage of the database upgrade is initiated. In this stage, the facade interface R1 is no longer called to complete the dual data write; instead, the R3 interface is called directly. The parameters and return values ​​of the R1 and R3 interfaces remain consistent, allowing the R3 interface to smoothly replace the R1 interface based on the interface protocol.

[0106] Data reading:

[0107] In the first phase, data is written twice, reading data from the old database M1. At this stage, to ensure the availability of the original data service, only the data is written twice, but the data reading logic is not changed.

[0108] The second phase involves dual-writing data, simultaneously reading data from both the new and old databases, comparing and merging the data, and returning the retrieved data. If inconsistencies are found between the two sources, the data is returned from the old database, and the inconsistencies between the new and old databases are statistically analyzed and confirmed. If necessary, the data synchronization logic is adjusted.

[0109] In the third stage, data is no longer written twice; it is only written to the new database M3 and read from the new database.

[0110] Based on the above method, by introducing the Copilot auxiliary library with the same structure as the new database, the writing of data from the dual-source isomorphic database is completed, avoiding job interruption and ensuring a seamless user experience. In addition, by using three core database columns and core attribute information, dual-source verification of the data source is completed, ensuring data consistency and reducing the difficulty of data consistency verification.

[0111] Figure 6 This schematic diagram illustrates the composition of a database upgrade apparatus according to an exemplary embodiment of the present disclosure, such as... Figure 6 As shown, the database upgrade device 600 may include a construction module 601, a dual-write module 602, a dual-read module 603, and an upgrade module 604. Wherein:

[0112] Module 601 is used to build a replica database that is isomorphic to the new database and belongs to the same database system as the old database.

[0113] The dual-write module 602 is used to respond to a data write request by writing incremental data to the old version database, and after migrating all the data in the old version database to the new version database through the replica database, write the incremental data to the new version database.

[0114] The dual-read module 603 is used to perform a first verification on the incremental data written to the old database and the new database respectively based on the replica database, and when the first verification passes, it reads data from the old database and the new database respectively in response to a data read request.

[0115] The upgrade module 604 is used to perform a second verification on the data read from the old version database and the new version database respectively based on the replica database, and when the second verification passes, write the data to the new version database in response to a data write request, and read the data from the new version database in response to a data read request.

[0116] According to an exemplary embodiment of this disclosure, the database upgrade device 600 further includes a migration module for migrating all data in the old database to the new database via the replica database. This includes: the old database sending a first data update message to a first message queue; a consumer program consuming the first message queue to write all data in the old database to the replica database after data specification conversion; the replica database sending a second data update message to a second message queue after successfully writing the all data; and the consumer program consuming the second message queue to write all data in the replica database to the new database after data specification conversion.

[0117] According to an exemplary embodiment of this disclosure, the dual-write module 602 is further configured to read data from the legacy database in response to a data read request.

[0118] According to an exemplary embodiment of this disclosure, the dual-read module 603 is further configured to, in response to a data write request, simultaneously write incremental data to both the old version database and the new version database.

[0119] According to an exemplary embodiment of this disclosure, the dual-write module 602 is further configured to, in response to a data write request, invoke a first interface to write data to the old version database via a second interface; and invoke the first interface to write data to the new version database via a third interface.

[0120] According to an exemplary embodiment of this disclosure, the upgrade module 604 is further configured to call the third interface to write data to the new version of the database in response to a data write request; wherein the parameters and return values ​​of the first interface and the third interface are the same.

[0121] According to an exemplary embodiment of this disclosure, the dual-read module 603 is further configured to extract first data, second data, and third data written to the old database, the replica database, and the new database respectively in response to the same data write request; extract first core attribute summary information, second core attribute summary information, and third core attribute summary information based on the core fields of the first data, the second data, and the third data respectively; and determine that the first verification is passed when the first core attribute summary information, the second core attribute summary information, and the third core attribute summary information are all the same.

[0122] According to an exemplary embodiment of this disclosure, the upgrade module 604 is further configured to extract fourth data, fifth data, and sixth data read from the old database, the replica database, and the new database respectively in response to the same data read request; extract fourth core attribute summary information, fifth core attribute summary information, and sixth core attribute summary information based on the core fields of the fourth data, the fifth data, and the sixth data respectively; and determine that the second verification is passed when the fourth core attribute summary information, the fifth core attribute summary information, and the sixth core attribute summary information are all the same.

[0123] The specific details of each module in the aforementioned database upgrade device 600 have been described in detail in the corresponding database upgrade method, so they will not be repeated here.

[0124] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0125] In an exemplary embodiment of this disclosure, a storage medium capable of implementing the above-described method is also provided. Figure 7 This schematic diagram illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure, such as... Figure 7 As shown, a program product 700 for implementing the above-described method according to an embodiment of the present disclosure is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a mobile phone. However, the program product of the present disclosure is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.

[0126] In an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided. Figure 8 The schematic diagram illustrates the structure of a computer system of an electronic device according to an exemplary embodiment of the present disclosure.

[0127] It should be noted that, Figure 8 The computer system 800 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0128] like Figure 8 As shown, the computer system 800 includes a Central Processing Unit (CPU) 801, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 802 or programs loaded from storage section 808 into Random Access Memory (RAM) 803. The RAM 803 also stores various programs and data required for system operation. The CPU 801, ROM 802, and RAM 803 are interconnected via a bus 804. An Input / Output (I / O) interface 805 is also connected to the bus 804.

[0129] The following components are connected to I / O interface 805: an input section 806 including a keyboard, mouse, etc.; an output section 807 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to I / O interface 805 as needed. A removable medium 811, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 810 as needed so that computer programs read from it can be installed into storage section 808 as needed.

[0130] In particular, according to embodiments of this disclosure, the processes described below with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 809, and / or installed from removable medium 811. When the computer program is executed by central processing unit (CPU) 801, it performs various functions defined in the system of this disclosure.

[0131] It should be noted that the computer-readable medium shown in the embodiments of this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0132] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0133] The units described in the embodiments of this disclosure can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the unit itself.

[0134] In another aspect, this disclosure also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to perform the methods described in the above embodiments.

[0135] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0136] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this disclosure.

[0137] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein.

[0138] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.

Claims

1. A database upgrade method, characterized in that, include: Construct a replica database that is isomorphic to the new database and uses the same database system as the old database; In response to a data write request, incremental data is written to the old version database, and after all the data in the old version database is migrated to the new version database through the replica database, the incremental data is written to the new version database. Based on the replica database, the incremental data written to the old database and the new database are subjected to a first verification, and when the first verification passes, data is read from the old database and the new database in response to a data read request. Based on the replica database, a second verification is performed on the data read from the old database and the new database respectively. When the second verification passes, the data is written to the new database in response to a data write request, and the data is read from the new database in response to a data read request.

2. The database upgrade method according to claim 1, characterized in that, The method further includes: migrating all data in the old database to the new database through the replica database, wherein migrating all data in the old database to the new database through the replica database includes: The old database sends a first data update message to the first message queue; The consumer program consumes the first message queue to write the full amount of data in the old database into the replica database after data specification transformation; After the replica database successfully writes the full amount of data, it sends a second data update message to the second message queue. The consumer program consumes the second message queue to write the full data in the replica database into the new database after data specification transformation.

3. The database upgrade method according to claim 1, characterized in that, The method further includes, in response to a data write request, writing incremental data to the old database, and after migrating all data in the old database to the new database via the replica database, writing the incremental data to the new database, the method further includes: In response to a data read request, data is read from the legacy database.

4. The database upgrade method according to claim 1, characterized in that, Upon successful verification, the method further includes: In response to a data write request, incremental data is written to both the old database and the new database simultaneously.

5. The database upgrade method according to claim 1, characterized in that, The step of responding to a data write request by writing incremental data to the old database, and writing the incremental data to the new database after migrating all data in the old database to the new database via the replica database, includes: In response to a data write request, the first interface is invoked to write the data to the legacy database via the second interface; and The first interface is invoked to write data into the new database via the third interface.

6. The database upgrade method according to claim 5, characterized in that, Upon successful verification, in response to a data write request, the data is written to the new database, including: In response to a data write request, the third interface is invoked to write the data into the new database; wherein the parameters and return values ​​of the first interface and the third interface are the same.

7. The database upgrade method according to claim 2, characterized in that, The first verification of the incremental data written to the old database and the new database based on the replicated database includes: Extract the first, second, and third data that are written to the old database, the replica database, and the new database respectively in response to the same data write request; Based on the core fields of the first data, the second data, and the third data, extract the first core attribute summary information, the second core attribute summary information, and the third core attribute summary information, respectively. When the first core attribute summary information, the second core attribute summary information, and the third core attribute summary information are all the same, the first verification is considered to have passed.

8. The database upgrade method according to claim 2, characterized in that, The second verification of data read from the old database and the new database based on the replica database includes: Extract the fourth, fifth, and sixth data read from the old database, the replica database, and the new database respectively in response to the same data read request; Based on the core fields of the fourth data, the fifth data, and the sixth data, extract the fourth core attribute summary information, the fifth core attribute summary information, and the sixth core attribute summary information, respectively. When the fourth core attribute summary information, the fifth core attribute summary information, and the sixth core attribute summary information are all the same, the second verification is considered to have passed.

9. A database upgrade device, characterized in that, include: The building module is used to build a replica database that is isomorphic to the new database and belongs to the same database system as the old database. The dual-write module is used to respond to a data write request by writing incremental data to the old version database, and after migrating all the data in the old version database to the new version database through the replica database, write the incremental data to the new version database. The dual-read module is used to perform a first verification on the incremental data written to the old database and the new database respectively based on the replica database, and when the first verification passes, it reads data from the old database and the new database respectively in response to a data read request; The upgrade module is used to perform a second verification on the data read from the old version database and the new version database respectively based on the replica database, and when the second verification passes, write the data to the new version database in response to a data write request, and read the data from the new version database in response to a data read request.

10. A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the database upgrade method as described in any one of claims 1 to 8.

11. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the database upgrade method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for carrying out non-stop data migration by utilizing MySQL Binlog

    CN110532241A

  • Database upgrading method and device

    CN115495436A