Database version upgrade management method and device, equipment and storage medium

By configuring the upgraded fallback processor and data channel in the data version control system, efficient management of the database version is achieved, solving the impact of database version upgrade on the stability of the business system and ensuring the consistency of database data.

CN120447932AActive Publication Date: 2025-08-08HANGZHOU NEWGRAND TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510948119.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-10
Publication Date
2025-08-08
Estimated Expiration
2045-07-10

AI Technical Summary

Technical Problem

In the prior art, improper database version upgrade management will affect the stability of the business system to which the database belongs.

Method used

The target upgrade environment of the target database is configured in the data version control system, including upgrading the fallback processor, the first data channel and the second data channel, listening to update requests in real time, performing classification processing and storage, and performing version upgrade or fallback processing according to the data update type.

Benefits of technology

It improves the speed and efficiency of database version upgrade, ensures the correct execution of version fallback, maintains the consistency of master-slave database data, and improves the stability of the business system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120447932A_ABST
    Figure CN120447932A_ABST
Patent Text Reader

Abstract

The invention discloses a database version upgrading management method and device, equipment and a storage medium, and belongs to the technical field of database management. The method comprises the steps that a target upgrading environment of a target database is configured in a data version management and control system; the target upgrading environment comprises an upgrading rollback processor, a first data channel and a second data channel; after the target upgrading environment is configured, binlog file monitoring is started, and a monitored target upgrading request is forwarded to the first data channel; the upgrade rollback processor obtains the to-be-classified requests from the first data channel, performs data update type classification on the to-be-classified requests according to target upgrade data in the data version management and control system, and stores the classified to-be-classified requests in a second data channel; and under the condition that a version rollback instruction of the target database is received, obtaining a to-be-processed update request from the second data channel, and performing version rollback processing on the target database according to the to-be-processed update request.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database management, and in particular to a database version upgrade management method, apparatus, device and storage medium. Background Art

[0002] In the digital age, business systems in the commercial sector generally adopt an agile development model to quickly respond to demand. This model encourages frequent version upgrades of business systems to meet new requirements. However, managing business system version upgrades often involves managing database version upgrades. Poor database version upgrade management can have an immeasurable impact on the stability of the business systems to which the database belongs.

[0003] Therefore, how to better manage database version upgrades is an issue that needs to be addressed urgently. Summary of the Invention

[0004] The present invention provides a database version upgrade management method, apparatus, device and storage medium to achieve better management of database version upgrades and improve the stability of the business system to which the database belongs.

[0005] According to one aspect of the present invention, a database version upgrade management method is provided, the method comprising:

[0006] Configuring a target upgrade environment for a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel;

[0007] After configuring the target upgrade environment, start binlog file monitoring and forward the monitored database update requests to the first data channel;

[0008] The upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system, and obtains the data update type corresponding to the request to be classified;

[0009] The upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system upgrades the target database according to the database update request stored in the second data channel;

[0010] When a version rollback instruction of the target database is received, a pending update request is obtained from the second data channel, and a version rollback process is performed on the target database according to the pending update request.

[0011] According to another aspect of the present invention, a database version upgrade management device is provided, the device comprising:

[0012] A database upgrade environment configuration module is used to configure a target upgrade environment of a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel;

[0013] The database update request monitoring module is used to start binlog file monitoring after the target upgrade environment is configured, and forward the monitored target update requests to the first data channel;

[0014] A data update type determination module is configured to enable the upgrade rollback processor to obtain the request to be classified from the first data channel, and classify the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system, to obtain the data update type corresponding to the request to be classified;

[0015] a request-to-be-classified storage module configured to cause the upgrade rollback processor to store the request-to-be-classified in the second data channel according to the data update type corresponding to the request, so that the upgrade thread of the data version control system can perform a version upgrade on the target database according to the database update request stored in the second data channel;

[0016] The database version rollback module is used to obtain the pending update request from the second data channel when receiving the version rollback instruction of the target database, and perform version rollback processing on the target database according to the pending update request.

[0017] According to another aspect of the present invention, an electronic device is provided, comprising:

[0018] at least one processor;

[0019] and a memory communicatively connected to at least one processor; wherein,

[0020] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the database version upgrade management method of any embodiment of the present invention.

[0021] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, which are used to enable a processor to implement the database version upgrade management method according to any embodiment of the present invention when executed.

[0022] According to another aspect of the present invention, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the database version upgrade management method according to any embodiment of the present invention is implemented.

[0023] The technical solution of an embodiment of the present invention is to configure a target upgrade environment of a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel; after the target upgrade environment is configured, binlog file monitoring is started, and the monitored target update request is forwarded to the first data channel; the upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the data update type of the request to be classified according to the target upgrade data of the target database in the data version control system, and obtains the data update type corresponding to the request to be classified; the upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system performs version upgrade on the target database according to the database update request stored in the second data channel; when a version rollback instruction of the target database is received, the update request to be processed is obtained from the second data channel, and version rollback processing is performed on the target database according to the update request to be processed. The above technical solution, after configuring the target upgrade environment of the target database in the data version control system, starts binlog file monitoring, monitors the target update request for updating the target database in real time, and uses the upgrade rollback processor, the first data channel and the second data channel created for the target database in the data version control system to classify and store the monitored target update request, so that the target database can be subsequently targeted for version upgrade or version rollback processing according to the data update type corresponding to the target update request, thereby improving the upgrade speed of subsequent target database version upgrades, improving the efficiency of subsequent target database version rollbacks, ensuring the correct execution of subsequent target database version rollbacks, and in the process of target database version upgrades or version rollbacks, ensuring the consistency of master-slave database data, thereby achieving better management of target database version upgrades and improving the stability of the business system to which the target database belongs.

[0024] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0026] Figure 1 This is a flowchart of a database version upgrade management method provided according to the first embodiment of the present invention;

[0027] Figure 2 This is a flowchart of a database version upgrade management method provided according to the second embodiment of the present invention;

[0028] Figure 3 This is a schematic diagram of the structure of a database version upgrade management device provided according to the third embodiment of the present invention;

[0029] Figure 4 It is a structural diagram of an electronic device for implementing the database version upgrade management method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0030] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.

[0031] It should be noted that the terms "objective", "first" and "second" in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0032] In addition, it should be noted that in the technical solution of the present invention, the collection, storage, use, processing, transmission, provision and disclosure of version upgrade success instructions and version rollback instructions, etc., are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.

[0033] Example 1

[0034] Figure 1 This is a flowchart of a database version upgrade management method provided in the first embodiment of the present invention. This embodiment is applicable to the situation where version upgrade management is performed on a database associated with a business system. The method can be executed by a database version upgrade management device, which can be implemented in the form of hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:

[0035] S101. Configure a target upgrade environment for a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel.

[0036] Among them, the data version control system refers to a system used to manage version upgrades of databases associated with business systems. The target database refers to the database in the business system that needs to be upgraded. The target upgrade environment refers to the upgrade environment required for the target database to be upgraded. The upgrade rollback processor refers to a processor in the data version control system used to classify target update requests by data update type. Among them, the target update request refers to a request to update the target database. The first data channel refers to the data channel in the data version control system used to store monitored target update requests. The second data channel refers to the data channel in the data version control system used to store target update requests classified by data update type.

[0037] It should be noted that when upgrading a target database using the data version control system, an upgrade rollback processor, a first data channel, and a second data channel are created for each target database in the data version control system. In other words, in the data version control system, each target database corresponds to one upgrade rollback processor, one first data channel, and one second data channel.

[0038] Specifically, build the blood relationship between the table structure data in the target database in the data version control system; configure the target grayscale release rules of the target database; connect to the target database; obtain and store the target version change method of the target database, and adjust the target version change method; create the upgrade rollback processor, the first data channel and the second data channel of the target database.

[0039] Table structure data refers to the data stored in the target database as tables. Target grayscale release rules refer to the rules for grayscale releases to the target database. Optionally, target grayscale release rules include grayscale release fields. Grayscale release fields are fields used in code or configuration to indicate whether a user, database update request, or traffic falls within the grayscale release range.

[0040] The target version change mode refers to the target database version change method; optionally, the target version change mode is determined by the value of the binlog_format variable in the target database. Specifically, if binlog_format = ROW in the target database, the target version change mode is row-based; if binlog_format = STATEMENT in the target database, the target version change mode is SQL statement-based; if binlog_format = MIXED in the target database, the target version change mode is mixed.

[0041] More specifically, in the data version control system, the kinship relationship between the table structure data in the target database can be established based on the field mapping relationship, primary key, foreign key, and data conversion rules of the data table in the target database; the target grayscale release rules of the target database can be configured according to actual business needs; the target database can be connected using a preset database connection string; the binlog record mode viewing command, such as SHOW VARIABLES LIKE 'binlog_format', can be used to view the binlog record mode of the target database and use it as the target version change mode of the target database; the target version change mode is stored in a preset storage unit of the data version control system so that the original binlog record mode of the target database can be restored after the target database version upgrade is completed; after the target version change mode of the target database is stored, the target version change mode of the target database is adjusted to a row-based change mode, that is, the value of binlog_format in the target database is adjusted to ROW, so as to obtain a more complete and clear database version upgrade details, which facilitates subsequent maintenance of the target database; the target database's target identifier is determined based on the target database's IP address and port; and based on the target identifier, an upgrade rollback processor, a first data channel, and a second data channel are created for the target database. The target identifier is used to uniquely identify the target database.

[0042] Among them, the target identifier of the target database is determined according to the IP address and port of the target database, which can be specifically: the IP address and port of the target database are spliced into a target string in a fixed format; and the target string is hashed by a preset hash algorithm to obtain the target identifier of the target database.

[0043] Optionally, configuring the target database's target upgrade environment in the data version control system may further include: detecting whether a slave database exists in the target database; if so, obtaining the slave database's slave database information; logging into the slave database based on the slave database information, and instructing the slave database to stop all replication threads. The slave database information includes, but is not limited to, the target database's slave database's IP address, port number, username, and login password. Replication threads include I / O threads and SQL threads.

[0044] Specifically, the slave databases of the target database can be displayed through a slave database display command, such as SHOW SLAVE HOSTS; if it is detected that the number of slave databases displayed for the target database is 0, it is determined that the target database does not have any slave databases; otherwise, it is determined that the target database does have any slave databases; when it is determined that the target database does have any slave databases, the slave database information of the slave database of the target database is obtained, and based on the obtained slave database information, the slave database of the target database is logged in; the slave database of the target database is ordered to stop all replication threads to avoid inconsistency between the slave database data of the target database and the target database data due to version rollback of the target database, thereby ensuring the data security of the slave database of the target database.

[0045] It is understandable that when upgrading the target database with the help of the data version control system, the target upgrade environment of the target database should be configured in the data version control system first to simulate the actual upgrade environment of the target database, ensure the smooth progress of the target database version upgrade, reduce the impact of the target database version upgrade on the business system to which the target database belongs, and ensure the security and stability of the business system to which the target database belongs.

[0046] S102: After configuring the target upgrade environment, start binlog file monitoring and forward the monitored target update request to the first data channel.

[0047] Specifically, after configuring the target upgrade environment, start binlog file monitoring to monitor the target update request in real time; and after monitoring the target update request, forward the monitored target update request to the first data channel to temporarily store the target update request.

[0048] It should be noted that the first data channel stores the target update requests it receives in the form of a queue.

[0049] S103. The upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system to obtain the data update type corresponding to the request to be classified.

[0050] The request to be classified refers to the database update request stored in the first data channel. The target upgrade data refers to the data required for the target database version upgrade; optionally, the target upgrade data includes target structure definition statements and target phased release rules. The target structure definition statements refer to the statements used to modify the target database structure definition during the target database version upgrade, that is, the target structure definition statements refer to the DDL (Data Definition Language) statements involved in the target database version upgrade.

[0051] Specifically, the upgrade fallback processor continuously obtains requests to be classified from the first data channel. For each request to be classified obtained, the upgrade fallback processor detects whether the execution statement in the request to be classified belongs to the target structure definition statement; if so, the upgrade fallback processor determines that the data update type corresponding to the request to be classified is upgrade metadata; if not, the upgrade fallback processor matches the fields in the execution statement in the request to be classified with the grayscale release fields in the target grayscale release rules; if the match is successful, the upgrade fallback processor determines that the data update type corresponding to the request to be classified is grayscale metadata; otherwise, the upgrade fallback processor determines that the data update type corresponding to the request to be classified is derived metadata.

[0052] Upgrade metadata refers to the structured metadata of the target database that is directly modified during a version upgrade. For example, metadata about the target database's indexes and stored procedures. Dark release metadata refers to metadata in the target database that requires a dark release. Derived metadata refers to metadata calculated or derived from existing data in the target database.

[0053] S104. The upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system upgrades the target database according to the database update request stored in the second data channel.

[0054] The second data channel includes an upgrade metadata subchannel, a grayscale metadata subchannel, and a derived metadata subchannel. The upgrade metadata subchannel is used to store pending classification requests whose corresponding data update type is upgrade metadata; the grayscale metadata subchannel is used to store pending classification requests whose corresponding data update type is grayscale metadata; and the derived metadata subchannel is used to store pending classification requests whose corresponding data update type is derived metadata. The upgrade thread is the thread in the data version control system used to process database update requests in the second data channel.

[0055] Specifically, if the data update type corresponding to the request to be classified is upgrade metadata, the upgrade rollback processor stores the request to be classified in the upgrade metadata sub-channel of the second data channel; if the data update type corresponding to the request to be classified is grayscale metadata, the upgrade rollback processor stores the request to be classified in the grayscale metadata sub-channel of the second data channel; if the data update type corresponding to the request to be classified is derived metadata, the upgrade rollback processor stores the request to be classified in the derived metadata sub-channel of the second data channel, so that the upgrade thread of the database version control system can quickly determine how to upgrade the target database version according to the database update requests stored in different sub-channels in the second data channel, thereby realizing targeted processing of database update requests, and there is no need to perform secondary data update type determination on the database update requests stored in the second data channel, thereby improving the speed of target database version upgrade and improving the efficiency and certainty of target database version rollback.

[0056] Optionally, to better distinguish different requests to be classified, the upgrade / fallback processor can hash each request to be classified before storing it in the second data channel to obtain a unique request identifier for the request to be classified. The upgrade / fallback processor then stores each request to be classified in a different subchannel of the second data channel in the form of a unique request identifier-request.

[0057] S105 . Upon receiving a version rollback instruction from the target database, obtain a pending update request from the second data channel, and perform version rollback processing on the target database according to the pending update request.

[0058] The pending update request refers to the database update request stored in the second data channel. Specifically, upon receiving a version rollback instruction for the target database, the pending update request is obtained from the sub-channel of the second data channel based on the sub-channel priority in the second data channel. For example, if the priority of the derived metadata sub-channel in the second data channel is higher than the priority of the upgrade metadata sub-channel, higher than the priority of the grayscale metadata sub-channel, and the priority of the upgrade metadata sub-channel is equal to the priority of the grayscale metadata sub-channel, then the pending update request is first obtained from the derived metadata sub-channel of the second data channel. After processing the database update request in the derived metadata sub-channel, the database update requests in the upgrade metadata sub-channel and the grayscale metadata sub-channel are processed simultaneously, that is, the pending update request is obtained from the derived metadata sub-channel and the grayscale metadata sub-channel of the second data channel respectively. Thereafter, based on the pending update request and the preset version rollback rule, the target database is subjected to version rollback processing.

[0059] The technical solution of an embodiment of the present invention is to configure a target upgrade environment of a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel; after the target upgrade environment is configured, binlog file monitoring is started, and the monitored target update request is forwarded to the first data channel; the upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the data update type of the request to be classified according to the target upgrade data of the target database in the data version control system, and obtains the data update type corresponding to the request to be classified; the upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system performs version upgrade on the target database according to the database update request stored in the second data channel; when a version rollback instruction of the target database is received, the update request to be processed is obtained from the second data channel, and version rollback processing is performed on the target database according to the update request to be processed. The above technical solution, after configuring the target upgrade environment of the target database in the data version control system, starts binlog file monitoring, monitors the target update request for updating the target database in real time, and uses the upgrade rollback processor, the first data channel and the second data channel created for the target database in the data version control system to classify and store the monitored target update request, so that the target database can be subsequently targeted for version upgrade or version rollback processing according to the data update type corresponding to the target update request, thereby improving the upgrade speed of subsequent target database version upgrades, improving the efficiency of subsequent target database version rollbacks, ensuring the correct execution of subsequent target database version rollbacks, and in the process of target database version upgrades or version rollbacks, ensuring the consistency of master-slave database data, thereby achieving better management of target database version upgrades and improving the stability of the business system to which the target database belongs.

[0060] Example 2

[0061] Figure 2 This is a flowchart of a database version upgrade management method provided by Example 2 of the present invention. Based on the above embodiment, this embodiment further optimizes "version rollback processing of the target database according to pending update requests" and provides an optional implementation plan. It should be noted that for the parts not described in detail in the embodiment of the present invention, reference can be made to the relevant descriptions of other embodiments. Figure 2 As shown, the method includes:

[0062] S201. Configure a target upgrade environment for a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel.

[0063] S202: After configuring the target upgrade environment, start binlog file monitoring and forward the monitored target update request to the first data channel.

[0064] S203. The upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system to obtain the data update type corresponding to the request to be classified.

[0065] S204. The upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system upgrades the target database according to the database update request stored in the second data channel.

[0066] S205: Upon receiving a version rollback instruction from the target database, obtain a pending update request from the second data channel.

[0067] S206: When it is determined that the pending update request comes from the derived metadata subchannel, execute the execution statement in the pending update request in the slave database of the target database.

[0068] Specifically, when it is determined that the pending update request comes from the derived metadata subchannel, the execution statement in the pending update request is directly executed in the slave database of the target database to ensure that the derived metadata is synchronized in the slave database of the target database.

[0069] S207: When it is determined that the pending update request comes from the upgrade metadata sub-channel or the grayscale metadata sub-channel, generate a reverse execution statement corresponding to the execution statement in the pending update request according to the statement type of the execution statement in the pending update request.

[0070] It should be noted that if the statement type of the execution statement in the pending update request is an INSERT statement, the statement type of the reverse execution statement corresponding to the execution statement in the pending update request is a DELETE statement; if the statement type of the execution statement in the pending update request is an UPDATE statement, the statement type of the reverse execution statement corresponding to the execution statement in the pending update request is also an UPDATE statement; if the statement type of the execution statement in the pending update request is a DELETE statement, the statement type of the reverse execution statement corresponding to the execution statement in the pending update request is an INSERT statement.

[0071] Specifically, when it is determined that the pending update request comes from the upgrade metadata sub-channel or the grayscale metadata sub-channel, if it is detected that the statement type of the execution statement in the pending update request is an INSERT statement, the table name, field name and field value are extracted from the execution statement in the pending update request, and based on the extracted table name, field name and field value, a reverse execution statement corresponding to the execution statement in the pending update request is generated; if it is detected that the statement type of the execution statement in the pending update request is an UPDATE statement, the table name, modified field name and WHERE condition are extracted from the execution statement in the pending update request, and based on the extracted table name, modified field name and WHERE condition, a first slave database execution statement is generated; in the slave database of the target database Execute a first slave database execution statement to obtain a first slave database execution result; generate a reverse execution statement corresponding to the execution statement in the pending update request based on the extracted table name, modified field name, WHERE condition and the first slave database execution result; if it is detected that the statement type of the execution statement in the pending update request is a DELETE statement, extract the table name and WHERE condition from the execution statement in the pending update request, and generate a second slave database execution statement based on the extracted table name and WHERE condition; execute the second slave database execution statement in the slave database of the target database to obtain a second slave database execution result; generate a reverse execution statement corresponding to the execution statement in the pending update request based on the extracted table name and the second slave database execution result.

[0072] The first slave database execution statement refers to the SQL statement executed in the slave database of the target database when the statement type of the execution statement in the pending update request is an UPDATE statement. It should be noted that the statement type of the first slave database execution statement is a SELECT statement. The first slave database execution result refers to the execution result obtained after executing the first slave database execution statement in the slave database of the target database.

[0073] The second slave database execution statement refers to an SQL statement executed in the slave database of the target database when the statement type of the execution statement in the pending update request is a DELETE statement. It should be noted that the statement type of the second slave database execution statement is a SELECT statement. The second slave database execution result refers to the execution result obtained after executing the second slave database execution statement in the slave database of the target database.

[0074] For example, when it is determined that the pending update request comes from the upgrade metadata sub-channel or the grayscale metadata sub-channel, if the execution statement in the pending update request is as follows:

[0075] INSERT INTO students (class_id, name, gender, score) VALUES (2, 'Daniel', 'M', 80);

[0076] The statement type of the execution statement in the pending update request is an INSERT statement. Thus, from the execution statement in the pending update request, the following can be extracted: the table name is students, the field value of the field name class_id is 2 (i.e., class_id = 2), the field value of the field name name is 'Daniel' (i.e., name = 'Daniel'), the field value of the field name gender is M (i.e., gender = 'M'), and the field value of the field name score is 80 (i.e., score = 80). Then, based on the extracted table name, field names, and field values, the following reverse execution statement corresponding to the execution statement in the pending update request is generated:

[0077] DELETE FROM students

[0078] WHERE class_id = 2 AND name = 'Daniel' AND gender = 'M' AND score = 80;

[0079] If the execution statement in the pending update request is as follows:

[0080] UPDATE users SET age = 31 WHERE id = 1;

[0081] The statement type of the execution statement in the pending update request is an UPDATE statement. Thus, from the execution statement in the pending update request, the following can be extracted: the table name is users, the modified field name is age, and the WHERE condition is id = 1; Based on the extracted table name, modified field name, and WHERE condition, the following first slave database execution statement is generated:

[0082] SELECT age FROM users WHERE id = 1;

[0083] After that, execute the above first slave database execution statement in the slave database of the target database, and the following first slave database execution result is obtained: age = 30; Based on the extracted table name, modified field name, WHERE condition, and the first slave database execution result, the following reverse execution statement corresponding to the execution statement in the pending update request is generated:

[0084] UPDATE users SET age = 30 WHERE id = 1;

[0085] If the execution statement in the pending update request is as follows:

[0086] DELETE FROM employees WHERE age = 60;

[0087] Then the statement type of the execution statement in the pending update request is a DELETE statement, so it can be extracted from the execution statement in the pending update request that: the table name is employees, and the WHERE condition is age = 60; According to the extracted table name and WHERE condition, the following second execution statement for the slave database is generated:

[0088] SELECT * FROM employees WHERE age = 60;

[0089] After that, execute the above second execution statement for the slave database in the slave database of the target database to obtain the following second execution result for the slave database:

[0090] id name sex age 3 Zhang San male 60

[0091] After that, according to the extracted table name and the second execution result for the slave database, generate the following reverse execution statement corresponding to the execution statement in the pending update request:

[0092] INSERT INTO employees (id, name, sex, age) VALUES (3, 'Zhang San','male', 60);

[0093] S208. Execute the reverse execution statement in the target database to roll back the version of the target database.

[0094] Specifically, for each pending update request obtained from the upgrade metadata sub-channel or the gray-scale metadata sub-channel of the second data channel, execute the reverse execution statement corresponding to the execution statement in the pending update request in the target database to restore the target database to the state before the execution statement in the pending request is executed.

[0095] Optionally, to ensure data consistency between the target database and its slaves, and to ensure the correctness of the replication chain, after the target database is restored to its pre-upgrade state, the current change position of the target database's binlog file is obtained. The synchronization start position of the target database's slaves is set based on the current change position of the target database's binlog file. Specifically, the synchronization start position is set to the current change position of the target database's binlog file. The synchronization start position refers to the starting point at which data synchronization between the target database's slaves and the target database begins.

[0096] Optionally, to restore the target database's original binlog recording mode and ensure that the master and slave databases remain synchronized, after setting the synchronization start position for the target database's slave database, you can obtain the target database's target version change mode from the data version control system. Based on the obtained target version change mode, adjust the target database's current version change mode. Simultaneously, instruct the target database's slave database to start all replication threads, specifically the I / O thread and SQL thread. The current version change mode refers to the target database's version change mode during this version upgrade.

[0097] Optionally, to avoid wasting resources, after starting all replication threads in the slave database of the target database, close the binlog file monitoring, and destroy the upgrade rollback processor, the first data channel, and the second data channel corresponding to the target database in the data version control system.

[0098] The technical solution of the embodiment of the present invention is to start binlog file monitoring after configuring the target upgrade environment of the target database in the data version control system, monitor the target update request for updating the target database in real time, and classify and store the monitored target update request with the help of the upgrade rollback processor, the first data channel and the second data channel created for the target database in the data version control system, so that the target database can be subsequently subjected to targeted version upgrade processing or version rollback processing according to the data update type corresponding to the target update request, thereby improving the upgrade speed of subsequent target database version upgrades, improving the efficiency of subsequent target database version rollbacks, ensuring the correct execution of subsequent target database version rollbacks, and ensuring the consistency of master-slave database data during the process of target database version upgrades or version rollbacks, thereby achieving better management of target database version upgrades and improving the stability of the business system to which the target database belongs.

[0099] Based on the above embodiment, as an optional method of the embodiment of the present invention, it is also possible to: upon receiving a successful version upgrade instruction from the target database, in order to restore the original binlog recording mode of the target database and ensure that the master and slave databases are always in a synchronized state, obtain the target database's target version change mode from the data version control system, and adjust the target database's current version change mode based on the obtained target version change mode; at the same time, instruct the target database's slave database to start all replication threads, that is, instruct the target database's slave database to start the I / O thread and SQL thread. Afterwards, to avoid wasting resources, shut down the binlog file monitoring, and destroy the upgrade rollback processor, first data channel, and second data channel corresponding to the target database in the data version control system.

[0100] Example 3

[0101] Figure 3 This is a schematic diagram of the structure of a database version upgrade management device provided by the third embodiment of the present invention. This embodiment is applicable to the situation where version upgrade management is performed on the database associated with the business system. The device can be implemented in the form of hardware and / or software and can be configured in an electronic device. Figure 3 As shown, the device includes:

[0102] The database upgrade environment configuration module 301 is used to configure a target upgrade environment of a target database in the data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel;

[0103] The database update request monitoring module 302 is used to start binlog file monitoring after configuring the target upgrade environment and forward the monitored target update request to the first data channel;

[0104] The data update type determination module 303 is configured to enable the upgrade rollback processor to obtain the request to be classified from the first data channel, and classify the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system to obtain the data update type corresponding to the request to be classified;

[0105] The request storage module 304 is configured to store the request in the second data channel according to the data update type corresponding to the request, so that the upgrade thread of the data version control system can upgrade the target database according to the database update request stored in the second data channel.

[0106] The database version rollback module 305 is configured to obtain a pending update request from the second data channel upon receiving a version rollback instruction from the target database, and perform version rollback processing on the target database according to the pending update request.

[0107] The technical solution of an embodiment of the present invention is to configure a target upgrade environment of a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel; after the target upgrade environment is configured, binlog file monitoring is started, and the monitored target update request is forwarded to the first data channel; the upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the data update type of the request to be classified according to the target upgrade data of the target database in the data version control system, and obtains the data update type corresponding to the request to be classified; the upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system performs version upgrade on the target database according to the database update request stored in the second data channel; when a version rollback instruction of the target database is received, the update request to be processed is obtained from the second data channel, and version rollback processing is performed on the target database according to the update request to be processed. The above technical solution, after configuring the target upgrade environment of the target database in the data version control system, starts binlog file monitoring, monitors the target update request for updating the target database in real time, and uses the upgrade rollback processor, the first data channel and the second data channel created for the target database in the data version control system to classify and store the monitored target update request, so that the target database can be subsequently targeted for version upgrade or version rollback processing according to the data update type corresponding to the target update request, thereby improving the upgrade speed of subsequent target database version upgrades, improving the efficiency of subsequent target database version rollbacks, ensuring the correct execution of subsequent target database version rollbacks, and in the process of target database version upgrades or version rollbacks, ensuring the consistency of master-slave database data, thereby achieving better management of target database version upgrades and improving the stability of the business system to which the target database belongs.

[0108] Optionally, the target upgrade data includes target structure definition statements and target phased release rules;

[0109] The data update type determination module 303 is specifically configured to:

[0110] The upgrade fallback processor detects whether the execution statement in the request to be classified belongs to the target structure definition statement;

[0111] If so, the upgrade rollback processor determines that the data update type corresponding to the request to be classified is upgrade metadata;

[0112] If not, the upgrade rollback processor matches the fields in the execution statement in the request to be classified with the grayscale release fields in the target grayscale release rule;

[0113] If the match is successful, the upgrade rollback processor determines that the data update type corresponding to the request to be classified is grayscale metadata;

[0114] Otherwise, the upgrade rollback processor determines that the data update type corresponding to the request to be classified is derived metadata.

[0115] Optionally, the second data channel includes an upgraded metadata sub-channel, a grayscale metadata sub-channel, and a derived metadata sub-channel.

[0116] Optionally, the database version rollback module 305 is specifically configured to:

[0117] When it is determined that the pending update request comes from the derived metadata subchannel, executing an execution statement in the pending update request in the slave database of the target database;

[0118] If it is determined that the pending update request comes from the upgrade metadata sub-channel or the grayscale metadata sub-channel, generating a reverse execution statement corresponding to the execution statement in the pending update request according to the statement type of the execution statement in the pending update request;

[0119] Execute the reverse statement in the target database to implement version rollback of the target database.

[0120] Optionally, the database upgrade environment configuration module 301 is specifically used to:

[0121] Construct the blood relationship between table structure data in the target database;

[0122] Configure the target grayscale release rules for the target database;

[0123] Connect to the target database;

[0124] Obtain and store the target version change method of the target database, and adjust the target version change method;

[0125] An upgrade rollback processor, a first data channel, and a second data channel are created for the target database.

[0126] Optionally, the database upgrade environment configuration module 301 is further specifically configured to:

[0127] Check whether the target database has a slave database;

[0128] If it exists, obtain the slave database information from the slave database;

[0129] Log in to the slave database based on the slave database information and stop all replication threads in the slave database.

[0130] Optionally, the replication thread includes an I / O thread and an SQL thread.

[0131] The database version upgrade management device provided in the embodiment of the present invention can execute the database version upgrade management method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing each database version upgrade management method.

[0132] According to an embodiment of the present invention, the present invention further provides an electronic device, a readable storage medium and a computer program product.

[0133] Example 4

[0134] Figure 4 A schematic diagram of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices (such as helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.

[0135] like Figure 4 As shown, electronic device 10 includes at least one processor 11 and memory, such as read-only memory (ROM) 12 and random access memory (RAM) 13, communicatively connected to at least one processor 11. The memory stores computer programs executable by the at least one processor. Processor 11 can perform various appropriate actions and processes based on the computer programs stored in ROM 12 or loaded from storage unit 18 into RAM 13. RAM 13 can also store various programs and data required for the operation of electronic device 10. Processor 11, ROM 12, and RAM 13 are interconnected via bus 14. An input / output (I / O) interface 15 is also connected to bus 14.

[0136] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0137] Processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any other suitable processor, controller, microcontroller, etc. Processor 11 executes the various methods and processes described above, such as the database version upgrade management method.

[0138] In some embodiments, the database version upgrade management method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the database version upgrade management method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute the database version upgrade management method in any other appropriate manner (e.g., via firmware).

[0139] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0140] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0141] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, device, or apparatus. A computer-readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media may include an electrical connection based on one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0142] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device that has: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0143] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0144] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.

[0145] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.

[0146] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A database version upgrade management method, characterized in that: include: Configuring a target upgrade environment for a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel; After configuring the target upgrade environment, start binlog file monitoring and forward the monitored target update request to the first data channel; The upgrade rollback processor obtains the request to be classified from the first data channel, and classifies the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system, to obtain a data update type corresponding to the request to be classified; The upgrade rollback processor stores the request to be classified in the second data channel according to the data update type corresponding to the request to be classified, so that the upgrade thread of the data version control system upgrades the target database according to the database update request stored in the second data channel; When a version rollback instruction of the target database is received, a pending update request is obtained from the second data channel, and a version rollback process is performed on the target database according to the pending update request.

2. The method according to claim 1, characterized in that The target upgrade data includes a target structure definition statement and a target phased release rule; Classifying the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system to obtain the data update type corresponding to the request to be classified includes: The upgrade rollback processor detects whether the execution statement in the request to be classified belongs to the target structure definition statement; If so, the upgrade rollback processor determines that the data update type corresponding to the request to be classified is upgrade metadata; If not, the upgrade rollback processor matches the fields in the execution statement in the request to be classified with the grayscale release fields in the target grayscale release rule; If the match is successful, the upgrade rollback processor determines that the data update type corresponding to the request to be classified is grayscale metadata; Otherwise, the upgrade rollback processor determines that the data update type corresponding to the request to be classified is derived metadata.

3. The method according to claim 1, characterized in that The second data channel includes an upgraded metadata sub-channel, a grayscale metadata sub-channel, and a derived metadata sub-channel.

4. The method according to claim 3, characterized in that Performing version rollback processing on the target database according to the pending update request includes: If it is determined that the pending update request comes from the derived metadata subchannel, executing an execution statement in the pending update request in a slave database of the target database; If it is determined that the pending update request comes from the upgrade metadata sub-channel or the grayscale metadata sub-channel, generating a reverse execution statement corresponding to the execution statement in the pending update request according to the statement type of the execution statement in the pending update request; The reverse execution statement is executed in the target database to implement version rollback of the target database.

5. The method according to claim 1, characterized in that Configuring the target upgrade environment of the target database in the data version control system includes: Constructing a kinship relationship between table structure data in the target database; Configure target phased release rules for the target database; Connecting to the target database; Acquire and store the target version change method of the target database, and adjust the target version change method; An upgrade rollback processor, a first data channel, and a second data channel are created for the target database.

6. The method according to claim 5, characterized in that Configuring the target upgrade environment of the target database in the data version control system further includes: Detecting whether a slave database exists in the target database; If it exists, obtaining the slave database information of the slave database; According to the slave database information, log in to the slave database and instruct the slave database to stop all replication threads.

7. The method according to claim 6, characterized in that The replication thread includes an I / O thread and an SQL thread.

8. A database version upgrade management device, characterized in that: include: A database upgrade environment configuration module is used to configure a target upgrade environment of a target database in a data version control system; wherein the target upgrade environment includes an upgrade rollback processor, a first data channel, and a second data channel; A database update request monitoring module is used to start binlog file monitoring after configuring the target upgrade environment, and forward the monitored target update requests to the first data channel; a data update type determination module, configured for the upgrade rollback processor to obtain a request to be classified from the first data channel, and classify the request to be classified into a data update type according to the target upgrade data of the target database in the data version control system, to obtain a data update type corresponding to the request to be classified; a request-to-be-classified storage module, configured for the upgrade rollback processor to store the request-to-be-classified in the second data channel according to the data update type corresponding to the request-to-be-classified, so that the upgrade thread of the data version control system can perform a version upgrade on the target database according to the database update request stored in the second data channel; The database version rollback module is used to obtain the pending update request from the second data channel when receiving the version rollback instruction of the target database, and perform version rollback processing on the target database according to the pending update request.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor. The computer program is executed by the at least one processor so that the at least one processor can execute the database version upgrade management method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the database version upgrade management method according to any one of claims 1 to 7 when executed.

Citation Information

Patent Citations

  • System and method for realizing data synchronization optimization processing in big data environment

    CN111177173A

  • Complex computing network for controlling computing operations based on a computing load

    US20240220324A1