System upgrading method and device, electronic equipment and readable storage medium
By dividing the smart device system upgrade into two independent processes: main business and SQL statement, and performing error marking and remedial operations when the SQL statement upgrade fails, the problem of high upgrade failure rate in the existing technology is solved, and a more efficient system upgrade is achieved.
Patent Information
- Application Number
- CN202111621913.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-28
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2041-12-28
AI Technical Summary
In the existing technology, during the upgrade process of the smart device system, the strong coupling between the main business and SQL statement upgrades leads to a high overall upgrade failure rate, which wastes time and resource costs.
The system upgrade is divided into two independent processes: the main business and the SQL statement. The main business upgrade is completed first, and then the SQL statement upgrade is performed. When the SQL statement upgrade fails, the error is marked and remedial operations are performed until the preset requirements are met and the upgrade process is terminated.
It reduces the failure rate of the overall upgrade process, saves time and resource costs, and improves the success rate of system upgrades and user experience.
Smart Images

Figure CN114296760B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet of Things technology, and more specifically, to a system upgrade method, device, electronic device, and readable storage medium. Background Art
[0002] In IoT scenarios involving smart devices, such as smart homes and smart offices, the systems they rely on often need to be upgraded due to the short upgrade cycles and frequent feature and software updates. Updating server-based systems that control smart device functions often involves upgrading multiple aspects, such as core services and SQL statements.
[0003] In the prior art, server system upgrades are typically performed as a single process. The upgrades of various components within the process interact with each other, creating a strong coupling. With this approach, if an error occurs in any component, the entire upgrade process may become difficult to continue, leading to overall upgrade failure. This prior art approach is highly susceptible to overall upgrade failure, necessitating repeated upgrades, which wastes time and resources. Summary of the Invention
[0004] The purpose of this application includes, for example, providing a system upgrade method, device, electronic device and readable storage medium, which can save time and resource costs for system upgrades.
[0005] The embodiments of the present application can be implemented as follows:
[0006] In a first aspect, the present application provides a system upgrade method, applied to a server, the method comprising:
[0007] Executing a first upgrade process to upgrade the main business of the system;
[0008] After the first upgrade process is completed and the main business is successfully upgraded, a second upgrade process is triggered to upgrade the SQL statements of the database;
[0009] When the second upgrade process is completed and the execution result of the second upgrade process meets the preset requirements, the system upgrade process is ended.
[0010] In an optional embodiment, when the second upgrade process is completed and the execution result of the second upgrade process meets the preset requirements, the step of ending the system upgrade process includes:
[0011] During the execution of the second upgrade process, an error event is marked for the SQL statement that failed to be upgraded, and the upgrade of the next SQL statement is continued;
[0012] When all SQL statements to be upgraded are executed and the execution result of the second upgrade process meets the preset requirements, the system upgrade process ends.
[0013] In an optional embodiment, the step of ending the system upgrade process when all SQL statements to be upgraded are executed and the execution result of the second upgrade process meets preset requirements includes:
[0014] After all SQL statements to be upgraded are executed, the error events marked with the SQL statements that failed to be upgraded are saved;
[0015] After the server is restarted, continuing to perform the upgrade operation on the SQL statement marked with the error event;
[0016] The execution result of the second upgrade process is obtained based on the upgrade result of continuing to execute the upgrade operation, and when the execution result meets the preset requirement, the system upgrade process is ended.
[0017] In an optional embodiment, the step of obtaining an execution result of the second upgrade process based on the upgrade result of continuing to execute the upgrade operation, and ending the system upgrade process when the execution result meets a preset requirement, includes:
[0018] When the upgrade result of the upgrade operation is continued and the corresponding SQL statement is successfully upgraded, the error event marked by the successfully upgraded SQL statement is deleted;
[0019] When the upgrade result of the upgrade operation is continued and the corresponding SQL statement fails to be upgraded, the error event marked by the failed SQL statement is retained;
[0020] When the number of retained error events is lower than a preset threshold, it is determined that the execution result meets the preset requirements and the system upgrade process ends.
[0021] In an optional embodiment, the method further comprises:
[0022] Respond to operation requests sent by terminal devices;
[0023] When a database operation executed based on the operation request fails, obtaining database operation failure information;
[0024] Remedial operations are performed on the SQL statements in the database according to the failure information and a pre-stored upgrade file containing multiple versions of SQL statements.
[0025] In an optional embodiment, the failure information includes an identifier of the database where the operation failed and a failure type;
[0026] The step of performing remedial operations on the SQL statements in the current database based on the failure information and the pre-stored upgrade file containing multiple versions of SQL statements includes:
[0027] When the failure type is characterized as an SQL statement type, determining the target database according to the identifier of the database, and obtaining the table or field that causes the database operation failure;
[0028] Searching for an upgrade file containing multiple versions of SQL statements, and obtaining all SQL statements whose corresponding versions are higher than or equal to the version of the table or field;
[0029] Add all the SQL statements to the target database.
[0030] In an optional embodiment, when the failure type is characterized as a functional type, the method further includes:
[0031] Download and install an update and upgrade data package, wherein the update and upgrade data package includes a functional module for implementing the database operation, wherein the database operation includes at least one of adding data, modifying data, deleting data or querying the database.
[0032] In an optional embodiment, the step of executing the first upgrade process to upgrade the main business of the system includes:
[0033] Backing up and saving the current main business data packet in the server;
[0034] Downloading an upgrade data package, wherein the upgrade data package includes multiple configuration files related to the main business functions;
[0035] Decompress the upgrade package and save it to the specified directory of the server.
[0036] In a second aspect, the present application provides a system upgrade device, applied to a server, comprising:
[0037] A first execution module, configured to execute a first upgrade process to upgrade a main service of the system;
[0038] A triggering module, configured to trigger a second upgrade process to upgrade the SQL statements of the database after the first upgrade process is completed and the main business is successfully upgraded;
[0039] The second execution module is configured to terminate the system upgrade process when the second upgrade process is completed and the execution result of the second upgrade process meets a preset requirement.
[0040] In a third aspect, the present application provides an electronic device comprising: a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to implement the system upgrade method described in any one of the aforementioned implementations.
[0041] In a fourth aspect, the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the system upgrade method as described in any one of the aforementioned embodiments.
[0042] The beneficial effects of the embodiments of the present application include, for example:
[0043] The present application provides a system upgrade method, apparatus, electronic device, and readable storage medium. The method first executes a first upgrade process to upgrade the system's main business. After the first upgrade process is completed and the main business upgrade is successful, a second upgrade process is triggered to upgrade the database's SQL statements. When the second upgrade process is completed and the execution results of the second upgrade process meet preset requirements, the system upgrade process ends. This solution separates the upgrade of the main business and the SQL statement into two separate processes. After the main business upgrade is successful, the SQL statement upgrade is executed. This allows the main business upgrade to no longer rely on the SQL statement upgrade, making it less likely that the entire upgrade process will fail. This avoids unnecessary repetition of upgrade processes, saving time and resource costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0045] Figure 1 A schematic diagram of an application scenario of the system upgrade method provided in an embodiment of the present application;
[0046] Figure 2 A schematic diagram of another application scenario of the system upgrade method provided in an embodiment of the present application;
[0047] Figure 3 A flowchart of the system upgrade method provided in an embodiment of the present application;
[0048] Figure 4 for Figure 3 Flowchart of the sub-steps included in step S101;
[0049] Figure 5 for Figure 3Flowchart of the sub-steps included in step S103;
[0050] Figure 6 for Figure 5 Flowchart of the sub-steps included in step S1032;
[0051] Figure 7 for Figure 6 Flowchart of the sub-steps included in step S10323;
[0052] Figure 8 Another flowchart of the system upgrade method provided in an embodiment of the present application;
[0053] Figure 9 for Figure 8 Flowchart of the sub-steps included in step S106;
[0054] Figure 10 A structural block diagram of an electronic device provided in an embodiment of the present application;
[0055] Figure 11 This is a functional module block diagram of the system upgrade device provided in an embodiment of the present application.
[0056] Icons: 110 - storage medium; 120 - processor; 130 - system upgrade device; 131 - first execution module; 132 - trigger module; 133 - second execution module; 140 - communication interface. DETAILED DESCRIPTION
[0057] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.
[0058] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.
[0059] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0060] In the description of this application, it should be noted that the terms "first", "second", etc., if used, are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0061] See also Figure 1 , is a schematic diagram of an application scenario of the system upgrade method provided in an embodiment of the present application, wherein the scenario includes a server and multiple terminal devices. Each terminal device is connected to the server in communication to realize data and information exchange.
[0062] In this embodiment, the terminal device may be a control device for smart devices such as smart home and smart office equipment. For example, it may be a control device for smart curtains, smart lights, smart refrigerators, smart door locks, and other smart devices. An application for controlling the smart device, such as an app or an embedded control program, may be installed on the terminal device to control the smart device.
[0063] In this embodiment, the server may be a background server of an application on a terminal device, a local server, or a cloud server, and this embodiment does not impose any specific restrictions on this.
[0064] The server provides a system for controlling and upgrading terminal devices. This system implements related functions based on a database and other configuration files stored on the server. The database contains tools, code, data, and other information related to the functions of the application. In this embodiment, the terminal device's control information for each smart device is processed by the server, and then the server sends the corresponding control information to the control device of the corresponding smart device, thereby implementing the corresponding control.
[0065] Also, see Figure 2 , shows a schematic diagram of another application scenario of the system upgrade method provided by an embodiment of the present application. This scenario includes a local server, a cloud server, and multiple terminal devices. The local server can be connected to the cloud server and each terminal device respectively. For example, the local server can be connected to the cloud server via network communication, and the local server can be connected to each terminal device via the ZigBee protocol.
[0066] Likewise, the terminal device may be a control device of the smart device, and the local server may be a device deployed in a field environment such as a home or office and connectable to the control device.
[0067] The system upgrade method provided in this embodiment can be applied to the above-mentioned local server, and the local server can obtain the data packets required for the upgrade from the cloud server, perform upgrade verification through the cloud server, etc. In addition, the local server can also obtain the data packets required for the upgrade through a storage device such as a USB flash drive.
[0068] In this application scenario, each terminal device is connected with the local server through the zigbee protocol, and in the case that the local server obtains the data packet required for upgrading, the upgrading of the system of each terminal device can be successfully performed even in the case of no network. Through the system architecture provided by the embodiment, the defect that it is difficult to upgrade in the case of no network can be avoided, and the implementability of upgrading is improved.
[0069] In addition, if the existing terminal device is used to communicate with the remote server to realize upgrading, the influence on the user in the case of upgrading failure is relatively large, because once the upgrading fails, it is difficult to troubleshoot the existing problems due to the implementation based on the remote server, the user needs to contact the after-sales or even the research and development to troubleshoot the problems, which greatly improves the maintenance cost. In the embodiment, the local server is deployed in the field environment, and when the upgrading fails, the problem can be conveniently troubleshooted, thereby avoiding causing a large maintenance cost.
[0070] Figure 3 A flowchart of a system upgrading method provided by the embodiment of the application is shown, which can be implemented by the server shown in Figure 1 or the local server shown in Figure 2 . It should be understood that in other embodiments, the order of some steps of the system upgrading method of the embodiment can be exchanged according to actual needs, or some steps can be omitted or deleted. The detailed steps of the system upgrading method are described as follows.
[0071] S101, a first upgrading process is performed to upgrade the main business of the system.
[0072] S102, after the first upgrading process is executed and the main business upgrading is successful, a second upgrading process is triggered to upgrade the SQL statement of the database.
[0073] S103, when the second upgrading process is executed and the execution result of the second upgrading process meets the preset requirement, the upgrading process of the system is ended.
[0074] With the continuous improvement of the demand for the functionality and humanization of intelligent devices, and the continuous improvement of the intelligent device products by manufacturers, the functionality of intelligent devices often needs to be upgraded and improved in the process of using intelligent devices. This involves the need to upgrade the system on the server side, so that the server can support more rich and perfect functionality control of intelligent devices.
[0075] The upgrading of the system in the server mainly involves two parts, one part is the upgrading of the function-related main service, and the other part is the upgrading of the SQL statements in the database. The existing databases include multiple types, such as hierarchical databases, relational databases, object-oriented databases, XML databases and the like, among which, the relational database is the most widely used database at present. The SQL statement is a language used for operating the relational database.
[0076] In the upgrading of the database, the upgrading of the main service is mainly implemented by downloading and installing some files, and therefore, the success rate of the upgrading of the main service is very high. The upgrading of the SQL statement includes the addition of fields, tables and the like, and in the case that the database is busy or the database is locked, the upgrading of the SQL statement will fail, and therefore, the failure rate of the upgrading of the SQL statement is higher than that of the upgrading of the main service.
[0077] In the existing upgrading mode, the upgrading process is executed as a whole, and the upgrading of the main service and the upgrading of the SQL statement are not separated, for example, when the upgrading of the SQL statement fails, the upgrading of the main service may be rolled back, resulting in the need to execute the upgrading process from the beginning. In the existing upgrading mode, the entire upgrading process needs to depend on the upgrading status of the SQL statement, which is easy to cause the problems of consuming more time and resource cost.
[0078] In the existing upgrading mode, the upgrading process needs to depend on the upgrading status of the SQL statement, the upgrading status of the SQL statement and the upgrading status of the main service influence each other, the SQL statement upgrading with a higher failure rate than the main service upgrading is easy to reduce the overall upgrading success rate, and further easily affects the user experience.
[0079] In the embodiment, the database upgrading is separated into two processes, including a first upgrading process and a second upgrading process. The first upgrading process is executed to upgrade the main service of the system, and after the execution of the first upgrading process ends and the upgrading of the main service succeeds, for example, the downloading and installation of the main service-related files succeed, the second upgrading process is triggered to be executed.
[0080] The second upgrading process can be used to upgrade the SQL statements of the database, and in the case that the execution of the second upgrading process ends and the execution result of the second upgrading process meets the preset requirement, it can be determined that the system upgrading process ends.
[0081] The system upgrading method provided in the embodiment separates the upgrading of the main service and the SQL statement into two processes for execution, and after the upgrading of the main service succeeds, the upgrading of the SQL statement is executed, so that the upgrading of the main service no longer depends on the upgrading status of the SQL statement, some unnecessary rollback actions can be avoided, and time and resource cost are saved.
[0082] In this embodiment, during the upgrade of the main business of the system, due to the main business upgrade may also cause incompatibility, mismatching and other phenomena leading to upgrade failure, in order to ensure that when the main business upgrade has problems, it does not affect the original function use, and to achieve the purpose of the main business upgrade, please refer to Figure 4 In this embodiment, the above step S101 can be implemented in the following ways:
[0083] S1011, back up and save the current main business data packet in the server.
[0084] S1012: Download an upgrade data package, where the upgrade data package includes multiple configuration files related to main business functions.
[0085] S1013: decompress the upgrade data package and save it to a designated directory on the server.
[0086] In the server, the functional support related to the main business is stored in the database in the form of a main business data package. The process of upgrading the main business is the process of successfully replacing the current main business data package with the updated main business data package.
[0087] In this embodiment, before performing the main business upgrade, the current main business data package in the server can be backed up and saved. For example, if the current database version is version 2.0 and the version to be upgraded is version 3.0, the current version 2.0 main business data package can be backed up and saved in advance.
[0088] As a possible implementation, after downloading the upgrade data package, i.e., the version 3.0 upgrade data package, the server may pre-verify the upgrade data package, for example, including format verification, data verification, and verification of whether the upgrade data package matches the version 3.0 upgrade data package. After successful verification, the server decompresses the upgrade data package and saves it to a designated directory on the server.
[0089] After completing the above operations, the upgrade data package of version 3.0 is currently saved in the specified directory. If it is determined after detection that the upgrade data package can be executed normally, that is, after the upgrade is confirmed to be successful, the specified directory and the backup version 2.0 main business data package can be deleted.
[0090] If the upgrade data package is found to be unable to run successfully after the test, that is, the upgrade fails, the upgrade data package needs to be repaired or re-downloaded.
[0091] During the patching or re-downloading process, the control function of the control device may not be used normally. Therefore, the original main business data package should continue to be saved until the upgrade data package is patched or re-downloaded and the upgrade is confirmed to be successful, and then the original main business data package should be deleted.
[0092] As another possible implementation, the server can decompress the upgrade data package and save it to a designated directory of the server after downloading the upgrade data package. The original version 2.0 main service data package in the designated directory can be deleted while saving the version 3.0 upgrade data package to the designated directory.
[0093] After the upgrade data package of version 3.0 is successfully checked and upgraded, the original main service data package saved by the backup can be deleted. If the upgrade data package of version 3.0 is not successfully checked or is successfully checked but finally fails to upgrade, since the original version 2.0 main service data package is saved by the backup, the main service data package saved by the backup can be restored to the designated directory of the server. Thus, the defect that the terminal device cannot perform various functions in the case of upgrade failure is avoided.
[0094] After the upgrade of the main service is successfully implemented, the upgrade of the SQL statement is triggered to execute the second upgrade process. The upgrade of the SQL statement mainly needs to add the SQL statement missing in the current version compared to the version to be upgraded. As known from the above, the upgrade of the SQL statement is affected by multiple factors. In the prior art, in the case of failure of the upgrade of a certain SQL statement, rollback needs to be performed to re-execute. This way also causes an impact on the progress of the upgrade of the SQL statement, and consumes a large amount of time and resource cost.
[0095] Based on the above considerations, please refer to Figure 5 In the embodiment, when the upgrade of the SQL statement is performed in step S103, the following way can be used to implement the upgrade of the SQL statement:
[0096] S1031, in the process of executing the second upgrade process, an error event is marked for the SQL statement that fails to upgrade, and the upgrade of the next SQL statement is continued.
[0097] S1032, when all the SQL statements to be upgraded are executed and the execution result of the second upgrade process meets the preset requirement, the upgrade process of the system is ended.
[0098] In the embodiment, in the case of upgrading from the current version to the target version, if 20 SQL statements are missing in the current version compared to the target version, the 20 missing SQL statements can be sequentially added to the database. During the process of adding the 20 SQL statements, if, for example, the database is locked or busy during the addition of a certain SQL statement, the addition of the SQL statement can fail, that is, the upgrade of the SQL statement fails.
[0099] In the existing processing method, when the above situation occurs, the operation may be rolled back for re-execution. However, due to the fact that the database is locked or busy, the problem may not be resolved in a short time, which will result in a large consumption of time and resources.
[0100] In this embodiment, if the above situation occurs, the SQL statement that failed to be upgraded will be marked as an error event, for example, an error mark empty file will be generated. After the mark, the upgrade of subsequent SQL statements will continue.
[0101] In this way, each time an SQL statement encounters an upgrade failure, an error event is marked and the upgrade of subsequent SQL statements continues until all SQL statements to be upgraded are executed. The upgrade process is then determined based on the execution result of the second upgrade process to determine whether to terminate the entire upgrade process. In other words, if the execution result of the second upgrade process meets the preset requirements, the entire upgrade process can be terminated. Otherwise, the second upgrade process needs to be continued until the execution result meets the preset requirements.
[0102] In this embodiment, only SQL statements that failed to be upgraded are marked as error events, and the upgrade of subsequent SQL statements continues. After all SQL statements to be upgraded have been executed, a decision is made whether to terminate the upgrade process or continue with the second upgrade process. This avoids the drawback of rolling back and re-executing each SQL statement that failed to be upgraded, which would waste a lot of time and processing resources.
[0103] See also Figure 6 In this embodiment, if you need to continue to execute the second upgrade process, you can do so in the following ways:
[0104] S10321: After all SQL statements to be upgraded are executed, error events marked for SQL statements that failed to be upgraded are saved.
[0105] S10322: After the server is restarted, continue to perform the upgrade operation on the SQL statement marked with the error event.
[0106] S10323: Obtain an execution result of the second upgrade process based on the upgrade result of continuing to execute the upgrade operation, and end the system upgrade process when the execution result meets the preset requirements.
[0107] As can be seen from the above, in the second upgrade process, first, all SQL statements to be upgraded may be executed once, and after completion, error events marked for all SQL statements that failed to upgrade in the process are saved.
[0108] By restarting the server, you can reload the SQL statements. At the same time, after each server restart, the database status is likely to change, for example, the database status is no longer busy or locked. Therefore, you can continue to perform the upgrade operation on the SQL statements marked with error events, thereby achieving upgrade optimization. During this continued upgrade operation, the upgrade operation is also performed sequentially on each SQL statement marked with an error event.
[0109] The upgrade process may be executed in one or more rounds, where a round is defined as executing all SQL statements marked with error events (not necessarily a successful execution). For example, if the results of one more round meet the preset requirements, the database upgrade process ends. If the results of one more round do not meet the preset requirements, a second round is required.
[0110] Similarly, the condition for triggering the continuation of the second round of upgrade operations may be a server restart. In addition, if the terminal device triggers a function request and the function request cannot be successfully implemented, it indicates that the failure may be caused by an SQL statement that was not successfully upgraded. In this case, the upgrade operation may also be triggered to continue.
[0111] According to this logic, if the final execution result of the second upgrade process meets the preset requirements, it can be determined that the SQL statement upgrade is successful and the system upgrade process can be ended.
[0112] In this embodiment, by saving the error events marked by all SQL statements that failed to upgrade and triggering the continuation of the upgrade operation when the server is restarted, the upgrade operation can be continued when the database is restarted to improve the status of being busy or locked, and the successful upgrade of the SQL statements that failed to upgrade can be further solved.
[0113] See also Figure 7 In this embodiment, when continuing to perform the upgrade operation, it can be determined whether to end the system upgrade process in the following ways:
[0114] S103231: When the upgrade result of the upgrade operation indicates that the corresponding SQL statement is successfully upgraded, the error event marked by the successfully upgraded SQL statement is deleted.
[0115] S103232: When the upgrade result of continuing to execute the upgrade operation indicates that the corresponding SQL statement upgrade has failed, retain an error event marked by the SQL statement that failed to upgrade.
[0116] S103233: When the number of retained error events is lower than a preset threshold, it is determined that the execution result meets the preset requirements and the system upgrade process ends.
[0117] In this embodiment, during the continued upgrade process, if a SQL statement is successfully upgraded, the error event marked for that SQL statement is deleted; otherwise, the error mark for that SQL statement is retained. The continued execution process is divided into rounds. If the number of error events retained after a round is lower than a preset threshold, the system upgrade process can be determined to have been initially successful.
[0118] The preset threshold may be set based on a fault tolerance mechanism, for example, it may be 3, 4, etc.
[0119] For example, during the continued execution process, if the number of error events remaining after the first round of continued execution is 5, then the execution results of that round are determined to have not met the preset requirements, and the second round of upgrade operations can be continued. If the number of error event data remaining after the second round of upgrade operations is 2, then the execution results of that round are determined to have met the preset requirements, and the system upgrade process can be terminated.
[0120] Of course, in this embodiment, the preset threshold can be set to 1, that is, the system upgrade process can be determined to be complete only when all SQL statements are successfully upgraded.
[0121] In this embodiment, the reason why the preset threshold can be set to a value greater than 1 is that after the initial upgrade process, the system upgrade can be remedied during use. Therefore, a certain fault tolerance mechanism can be set in the initial upgrade process, and combined with subsequent remedial measures, it will not affect the use of the corresponding functions of the terminal device.
[0122] Based on the above considerations, please refer to Figure 8 The system upgrade method provided in this embodiment may further include the following steps:
[0123] S104: Respond to the operation request sent by the terminal device.
[0124] S105: When the database operation executed based on the operation request fails, obtain database operation failure information.
[0125] S106: Perform remedial operations on the SQL statements in the database according to the failure information and a pre-stored upgrade file containing multiple versions of SQL statements.
[0126] When using a smart home, you may need to manipulate the functions supported by the upgraded system. For example, if the system upgrade includes adjusting the brightness of smart lights, then after the above system upgrade process is completed, theoretically, the brightness of smart lights can be adjusted.
[0127] If the terminal device sends an operation request, such as a request to adjust the brightness of a smart light, the server will call the system to perform corresponding system operations based on the operation request when receiving the operation request, such as calling adjustment statements, adjustment tools, etc.
[0128] As can be seen from the above, in the system upgrade process, the upgrade process may not end until the upgrade is completely successful, or if some exceptions may occur after the system upgrade process ends, these situations may cause the system operation executed based on the operation request to fail.
[0129] The biggest cause of system operation failures may be unsuccessful upgrades of SQL statements, which in turn lead to database operation failures. Therefore, in this embodiment, database operation failure information can be obtained. During the system upgrade process, the server contains an upgrade file containing multiple versions of SQL statements, including the SQL statements of the version to be upgraded to, which are the SQL statements that the current database version should contain. It may also contain SQL statements of other versions. In the second upgrade process described above, the SQL statement upgrade is implemented based on the SQL statements in this upgrade file.
[0130] In the event that the above operation on the database fails, a remedial operation may be performed on the SQL statements in the database based on the failure information and the SQL statements in the upgrade file.
[0131] In this embodiment, through the preliminary upgrade of the system in advance and the remedial operation of the database during use, the overall successful upgrade of the final system can be guaranteed, and the system can support the implementation of corresponding functions.
[0132] In this embodiment, during use, the failure information for a database operation failure includes the database identifier and failure type. The database identifier may indicate the specific database for which the operation failed, while the failure type may reflect the type of operation requested. For example, if the operation request initiated by the terminal device is for a function that the upgraded database should theoretically support, then the failure type may be determined to be an SQL statement, meaning that the SQL statement failed to be successfully upgraded.
[0133] See also Figure 9In this embodiment, if the failure type is a SQL statement type, remedial actions can be performed in the following ways:
[0134] S1061: When the failure type is characterized as an SQL statement type, determine the target database according to the identifier of the database, and obtain the table or field that causes the database operation failure.
[0135] S1062: Search for an upgrade file containing multiple versions of SQL statements, and obtain all SQL statements whose corresponding versions are higher than or equal to the version of the table or field.
[0136] S1063: Add all the SQL statements to the target database.
[0137] In this embodiment, the server includes multiple databases, and the data stored in the databases can be divided according to, for example, different terminal device types or different regions where the terminal devices are located. For example, data related to the same type of terminal devices communicating with the server can be stored in the same database, or data related to terminal devices within the same divided region communicating with the server can be stored in the same database. It should be noted that the division method for storing data in the database can be set as required and is not specifically limited in this embodiment.
[0138] When operating a database based on an operation request from a terminal device, the operation may be performed on one of multiple databases. Therefore, if the operation fails, the database identifier may be recorded and the target database may be determined from the multiple databases.
[0139] If the failure type is an SQL statement type, it is often due to the failure of the SQL statement upgrade causing the corresponding table or field to not be added to the database and thus fail. Therefore, in this embodiment, the table or field that caused the database operation failure can be obtained, that is, the table or field is not added to the database.
[0140] The upgrade file contains SQL statements for multiple versions, allowing you to obtain the SQL statements corresponding to each version of a table or field. During the upgrade process, you may upgrade between multiple versions, for example, from version 1.0 to version 2.0, and then from version 2.0 to version 3.0. During use, missing tables or fields may be missing from either version 2.0 or version 3.0.
[0141] If the table or field is missing in version 2.0, you can add SQL statements of the same or higher version as the missing table or field to the target database. If the table or field is missing in version 3.0, you can add SQL statements of the same version as the missing table or field to the target database.
[0142] In this embodiment, the integrity of the database upgrade can be further guaranteed by performing remedial operations on the SQL statements in the database during use.
[0143] In this embodiment, the database operations may be the aforementioned operations for the functions that the upgraded database in the upgraded system should have. In addition, in addition to these operations, other operation scenarios may exist. For example, a terminal device may need to control some other functions of a smart home, and this function may not be the function that needs to be upgraded in the aforementioned database upgrade process, resulting in the failure of the database operation. This type of failure can be divided into functional types.
[0144] When the failure type is characterized as a functional type, an update and upgrade data package can be downloaded and installed. The update and upgrade data package contains a functional module for implementing database operations. The database operations include at least one of adding data, modifying data, deleting data or querying data in the database.
[0145] For example, the above operations on the database need to be implemented by adding data, deleting data, modifying data, etc. Therefore, the database needs to be further upgraded so as to support the control mode required by the terminal device.
[0146] Among them, further upgrading the database involves upgrading the SQL statements. The following is an example of some SQL statements corresponding to database operations:
[0147] add_table: add database;
[0148] drop_table: delete the database;
[0149] add_column: add fields;
[0150] add_index: add index;
[0151] drop_index: delete index;
[0152] add_data: add data;
[0153] delete_data: delete data;
[0154] update_data updates data.
[0155] The system upgrade method provided in this embodiment separates the main service upgrade and SQL statement upgrade into two separate processes. After the first upgrade process completes and the main service upgrade succeeds, the second upgrade process is triggered and executed. The system upgrade process ends when the execution results of the second upgrade process meet preset requirements. This ensures that the main service upgrade is not affected by the SQL upgrade status and no longer depends on the SQL upgrade results. This avoids unnecessary rollbacks and saves time and processing resources during the system upgrade.
[0156] See also Figure 10 , is a schematic diagram of exemplary components of an electronic device provided in an embodiment of the present application, the electronic device may be Figure 1 The server shown in Figure 2 The electronic device may include a storage medium 110, a processor 120, a system upgrade device 130 and a communication interface 140. In this embodiment, the storage medium 110 and the processor 120 are both located in the electronic device and are separately arranged. However, it should be understood that the storage medium 110 may also be independent of the electronic device and can be accessed by the processor 120 through a bus interface. Alternatively, the storage medium 110 may also be integrated into the processor 120, for example, it may be a cache and / or a general register.
[0157] The system upgrade device 130 can be understood as the above-mentioned electronic device, or the processor 120 of the electronic device, or can be understood as a software function module independent of the above-mentioned electronic device or processor 120 that implements the above-mentioned system upgrade method under the control of the electronic device.
[0158] like Figure 11 As shown, the system upgrade device 130 may include a first execution module 131, a trigger module 132, and a second execution module 133. The functions of each functional module of the system upgrade device 130 are described in detail below.
[0159] A first execution module 131 is configured to execute a first upgrade process to upgrade the main service of the system;
[0160] It can be understood that the first execution module 131 can be used to execute the above step S101. For the detailed implementation of the first execution module 131, reference can be made to the above content related to step S101.
[0161] A trigger module 132 is configured to trigger a second upgrade process to upgrade the SQL statements of the database after the first upgrade process is completed and the main business upgrade is successful;
[0162] It can be understood that the trigger module 132 can be used to execute the above step S102. For the detailed implementation of the trigger module 132, reference can be made to the above content related to step S102.
[0163] The second execution module 133 is configured to terminate the system upgrade process when the second upgrade process is completed and the execution result of the second upgrade process meets a preset requirement.
[0164] It can be understood that the second execution module 133 can be used to execute the above step S103. For the detailed implementation of the second execution module 133, reference can be made to the above content related to step S103.
[0165] In a possible implementation, the second execution module 133 may be specifically configured to:
[0166] During the execution of the second upgrade process, an error event is marked for the SQL statement that failed to be upgraded, and the upgrade of the next SQL statement is continued;
[0167] When all SQL statements to be upgraded are executed and the execution result of the second upgrade process meets the preset requirements, the system upgrade process ends.
[0168] In a possible implementation, the second execution module 133 may be specifically configured to:
[0169] After all SQL statements to be upgraded are executed, the error events marked with the SQL statements that failed to be upgraded are saved;
[0170] After the server is restarted, continuing to perform the upgrade operation on the SQL statement marked with the error event;
[0171] The execution result of the second upgrade process is obtained based on the upgrade result of continuing to execute the upgrade operation, and when the execution result meets the preset requirement, the system upgrade process is ended.
[0172] In a possible implementation, the second execution module 133 may be specifically configured to:
[0173] When the upgrade result of the upgrade operation is continued and the corresponding SQL statement is successfully upgraded, the error event marked by the successfully upgraded SQL statement is deleted;
[0174] When the upgrade result of the upgrade operation is continued and the corresponding SQL statement fails to be upgraded, the error event marked by the failed SQL statement is retained;
[0175] When the number of retained error events is lower than a preset threshold, it is determined that the execution result meets the preset requirements and the system upgrade process ends.
[0176] In a possible implementation, the system upgrade device 130 further includes a remediation module, which can be used to:
[0177] Respond to operation requests sent by terminal devices;
[0178] When a database operation executed based on the operation request fails, obtaining database operation failure information;
[0179] Remedial operations are performed on the SQL statements in the database according to the failure information and a pre-stored upgrade file containing multiple versions of SQL statements.
[0180] In a possible implementation, the failure information includes an identifier of the database where the operation failed and a failure type. The remediation module may be specifically configured to:
[0181] When the failure type is characterized as an SQL statement type, determining the target database according to the identifier of the database, and obtaining the table or field that causes the database operation failure;
[0182] Searching for an upgrade file containing multiple versions of SQL statements, and obtaining all SQL statements whose corresponding versions are higher than or equal to the version of the table or field;
[0183] Add all the SQL statements to the target database.
[0184] In a possible implementation, when the failure type is characterized as a functional type, the remediation module may further be configured to:
[0185] Download and install an update and upgrade data package, wherein the update and upgrade data package includes a functional module for implementing the database operation, wherein the database operation includes at least one of adding data, modifying data, deleting data or querying the database.
[0186] In a possible implementation, the first execution module 131 may be specifically configured to:
[0187] Backing up and saving the current main business data packet in the server;
[0188] Downloading an upgrade data package, wherein the upgrade data package includes multiple configuration files related to the main business functions;
[0189] Decompress the upgrade package and save it to the specified directory of the server.
[0190] In an embodiment of the present application, corresponding to the above-mentioned system upgrade method, a computer-readable storage medium is further provided, in which a computer program is stored. When the computer program is run, each step of the above-mentioned system upgrade method is executed.
[0191] Among them, the steps executed when the aforementioned computer program is running will not be described here one by one, and reference can be made to the explanation of the system upgrade method in the previous article.
[0192] In summary, the system upgrade method, device, electronic device, and readable storage medium provided in the embodiments of the present application first execute a first upgrade process to upgrade the main business of the system. After the first upgrade process is completed and the main business upgrade is successful, a second upgrade process is triggered to upgrade the SQL statements of the database. When the second upgrade process is completed and the execution result of the second upgrade process meets the preset requirements, the system upgrade process is terminated. This solution separates the upgrade of the main business and the SQL statement into two processes for execution. After the main business upgrade is successful, the SQL statement upgrade is executed. In this way, the main business upgrade is no longer dependent on the SQL statement upgrade, which is less likely to cause the failure of the entire upgrade process, avoids some unnecessary rollback operations, and saves time and resource costs.
[0193] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A system upgrade method, characterized in that: Applied to a server, and used to implement a function upgrade of a smart device, the method includes: Executing a first upgrade process to upgrade the main business of the system; After the first upgrade process is completed and the main business is successfully upgraded, a second upgrade process is triggered to upgrade the SQL statements of the database; When the second upgrade process is completed and the execution result of the second upgrade process meets the preset requirements, the system upgrade process is terminated; The step of ending the system upgrade process when the second upgrade process is completed and the execution result of the second upgrade process meets the preset requirements includes: During the execution of the second upgrade process, an error event is marked for the SQL statement that failed to be upgraded, and the upgrade of the next SQL statement is continued; When all SQL statements to be upgraded are executed and the execution result of the second upgrade process meets the preset requirements, the system upgrade process ends; The step of ending the system upgrade process when all SQL statements to be upgraded are executed and the execution result of the second upgrade process meets the preset requirements includes: After all SQL statements to be upgraded are executed, the error events marked with the SQL statements that failed to be upgraded are saved; After the server is restarted, continuing to perform the upgrade operation on the SQL statement marked with the error event; The execution result of the second upgrade process is obtained based on the upgrade result of continuing to execute the upgrade operation, and when the execution result meets the preset requirement, the system upgrade process is ended.
2. The system upgrade method according to claim 1, characterized in that: The step of obtaining an execution result of the second upgrade process based on the upgrade result of continuing to execute the upgrade operation, and ending the system upgrade process when the execution result meets a preset requirement, includes: When the upgrade result of the upgrade operation is continued and the corresponding SQL statement is successfully upgraded, the error event marked by the successfully upgraded SQL statement is deleted; When the upgrade result of the upgrade operation is continued and the corresponding SQL statement fails to be upgraded, the error event marked by the failed SQL statement is retained; When the number of retained error events is lower than a preset threshold, it is determined that the execution result meets the preset requirements and the system upgrade process ends.
3. The system upgrade method according to claim 1, characterized in that: The method further comprises: Respond to operation requests sent by terminal devices; When a database operation executed based on the operation request fails, obtaining database operation failure information; Remedial operations are performed on the SQL statements in the database according to the failure information and a pre-stored upgrade file containing multiple versions of SQL statements.
4. The system upgrade method according to claim 3, characterized in that: The failure information includes the identifier of the database where the operation failed and the failure type; The step of performing remedial operations on the SQL statements in the current database according to the failure information and a pre-stored upgrade file containing multiple versions of SQL statements includes: When the failure type is characterized as an SQL statement type, determining the target database according to the identifier of the database, and obtaining the table or field that causes the database operation failure; Searching for an upgrade file containing multiple versions of SQL statements, and obtaining all SQL statements whose corresponding versions are higher than or equal to the version of the table or field; Add all the SQL statements to the target database.
5. The system upgrade method according to claim 4, characterized in that: When the failure type is characterized as a functional type, the method further includes: Download and install an update and upgrade data package, wherein the update and upgrade data package includes a functional module for implementing the database operation, wherein the database operation includes at least one of adding data, modifying data, deleting data or querying the database.
6. The system upgrade method according to claim 1, characterized in that: The step of executing the first upgrade process to upgrade the main business of the system includes: Backing up and saving the current main business data packet in the server; Downloading an upgrade data package, wherein the upgrade data package includes multiple configuration files related to the main business functions; Decompress the upgrade package and save it to the specified directory of the server.
7. A system upgrade device, characterized in that: Applied to a server, for implementing the system upgrade method according to any one of claims 1 to 6, the device comprising: A first execution module, configured to execute a first upgrade process to upgrade a main service of the system; A triggering module, configured to trigger a second upgrade process to upgrade the SQL statements of the database after the first upgrade process is completed and the main business is successfully upgraded; The second execution module is configured to terminate the system upgrade process when the second upgrade process is completed and the execution result of the second upgrade process meets a preset requirement.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to implement the system upgrade method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that Used to store a computer program, wherein when the computer program is executed by a processor, the system upgrade method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Service part upgrading method and device, computer equipment and storage medium
CN113326052A
Method of upgrading sequence
CN1858704A