Finite-state machine-based rollback method, apparatus and device, and storage medium

By adopting a rollback method based on finite state machine in Kubernetes, the problem of storage resource residue after PVC creation fails is solved, and the stability and integrity of resources are achieved.

CN119806684APending Publication Date: 2025-04-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411683195.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-04-11

AI Technical Summary

Technical Problem

When creating PVC in Kubernetes, network problems lead to residual storage resources in the backend, and there is a lack of an effective rollback mechanism to delete these residual resources.

Method used

Using a rollback method based on a finite state machine, by obtaining the RBJob in the queue, judging its state and performing rollback task abstraction, designing the state of the rollback task to formulate the running process in each state, simplifying the complexity of the rollback task, and introducing a running interval to prevent mistaken deletion.

Benefits of technology

It effectively solves the problem of residual back-end storage resource caused by network problems, simplifies the execution process of rollback tasks, and ensures the stability and integrity of resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119806684A_ABST
    Figure CN119806684A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of rollback mechanisms, and discloses a rollback method, device and equipment based on a finite state machine, and a storage medium, the method comprises the following steps: obtaining an RBJob in a queue, and determining whether the state of the RBJob is a cancel state; if the RBJob is in a non-cancel state, the states of the RBJob are sequentially obtained on the basis of a finite state machine, rollback task abstraction is carried out, and the states of the RBJob comprise a task new establishment state, a check query state, a confirmation state, a deletion state and an end state; the RBJob is cached by adopting an RBDict data structure, and all the RBJob are traversed until the interval value is greater than or equal to the interval initial value, the rollback mechanism is designed based on the finite-state machine mechanism, the complexity of the rollback task is simplified, the operation interval interval value is introduced to prevent mistaken deletion, and resource residue caused by network environment abnormity is prevented.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of rollback mechanisms, and in particular to a rollback method, device, equipment and storage medium based on a finite state machine. Background Art

[0002] When creating a PVC (PersistentVolume Claim), K8S (Kubernetes) will first create an API object PVC, and then call CSI (Container Storage Interface) to control the node component to create the backend storage. To create the backend storage, the Openapi interface is generally called, that is, the http request interacts with the backend. When the backend storage explicitly returns that the creation is successful, CSI will create a PV (Persistent Volume) and bind it to the PVC. When the backend storage explicitly returns that the creation failed, CSI will not create the PV. If the PVC is deleted at this time, K8S allows the PVC to be deleted. In this case, if the reason for the creation failure is a network timeout, that is, the backend creation is successful, but the CSI does not receive the correct result due to network delays and other reasons, the PVC deletion will cause the backend storage to remain. Therefore, how to delete the residual backend storage resources has become a problem that needs to be solved urgently. Summary of the invention

[0003] In view of this, the present invention provides a rollback method, apparatus, device and storage medium based on a finite state machine to solve the problem of how to delete the residual backend resources.

[0004] In a first aspect, the present invention provides a rollback method based on a finite state machine, the method comprising:

[0005] Get the RBJob in the queue and determine whether the status of the RBJob is canceled;

[0006] If RBJob is in a non-cancel state, the finite state machine is used to obtain the RBJob status in sequence and perform rollback task abstraction. The RBJob status includes task creation status, check query status, confirmation status, deletion status, and end status.

[0007] Use the RBDict data structure to cache RBJobs and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

[0008] The present invention designs a rollback mechanism based on a finite state machine mechanism, designs the state of the rollback task to formulate the running process in each state, simplifies the complexity of the rollback task, introduces the running interval interval value to prevent accidental deletion, and is applicable to all mainstream K8S container orchestration systems and resource residual rollback scenarios caused by network requests. It improves the problem of backend resource residual caused by network problems when K8S creates PVC, and prevents a large amount of resource residual caused by abnormal network environment.

[0009] In an optional implementation, the status of RBJob is obtained in sequence, including:

[0010] When the RBJob status is the task creation status, a query request is sent to enter the check query status;

[0011] If the query result meets the rollback condition, the confirmation state is entered;

[0012] Execute the deletion of storage resources and enter the deletion state after sending the deletion request;

[0013] Storage resource deletion is in progress and will enter the end state after successful execution.

[0014] The present invention designs the state of the rollback task based on a finite state machine mechanism, so as to formulate the operation flow in each state, thereby greatly simplifying the complexity of the rollback task.

[0015] In an optional embodiment, the method further includes:

[0016] When receiving the asynchronous request result of checking RBJob, determine whether the request result is successful;

[0017] If the check request result is unsuccessful, determine whether a timeout error occurs in the creation request;

[0018] If a timeout error occurs during the creation request, the RBJob is added to the cache.

[0019] The present invention designs an asynchronous processing mechanism for rollback requests by taking into account the smoothness of the rollback process, avoids timeout blocking due to network reasons, and uses asynchronous requests to design a corresponding request response processing mechanism.

[0020] In an optional implementation, if the request result is unsuccessful, after determining whether a timeout error occurs in the creation request, the method further includes:

[0021] If the creation request does not time out, the RBJob is deleted.

[0022] The present invention takes into account the timeout situation of the rollback task and deletes the RBJob, thereby ensuring the stability of the rollback task.

[0023] In an optional implementation, deleting RBJob includes:

[0024] Get the corresponding RBJob according to the key and lock the RBJob;

[0025] Set the cancel status of RBJob to true;

[0026] Unlock RBJob;

[0027] If RBJob is in the delete state, it blocks until the delete operation receives the result.

[0028] The present invention locks RBJob first when deleting a rollback task to avoid the impact caused by task deletion, sets the cancel state of RBJob to true instead of directly deleting it, and deletes it when the rollback mechanism runs to the task, thereby improving the deletion mechanism of RBJob.

[0029] In an optional embodiment, the method further includes:

[0030] Set the initial interval value of RBJob;

[0031] Each time a task is created, the interval value decreases by one;

[0032] If the interval value is smaller than the initial value, rollback is performed.

[0033] The present invention sets the initial value of the interval of RBJob to execute the rollback process according to the value of the interval, thereby avoiding the situation where the rollback is executed within the retry interval.

[0034] In a second aspect, the present invention provides a rollback device based on a finite state machine, the device comprising:

[0035] The judgment module is used to obtain the RBJob in the queue and determine whether the status of the RBJob is canceled;

[0036] The acquisition module is used to obtain the status of RBJob in sequence based on the finite state machine if RBJob is in a non-cancel state, and perform rollback task abstraction. The status of RBJob includes task creation status, check query status, confirmation status, deletion status, and end status;

[0037] The cache module is used to cache RBJobs using the RBDict data structure and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

[0038] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the finite state machine-based rollback method of the above-mentioned first aspect or any corresponding embodiment thereof by executing the computer instructions.

[0039] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the finite state machine-based rollback method of the above-mentioned first aspect or any corresponding embodiment thereof.

[0040] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the finite state machine-based rollback method of the above-mentioned first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 is a flow chart of a rollback method based on a finite state machine according to an embodiment of the present invention;

[0043] Figure 2 is a flow chart of a Rollback cycle mechanism according to an embodiment of the present invention;

[0044] Figure 3 is a schematic diagram of a process for checking an asynchronous request result according to an embodiment of the present invention;

[0045] Figure 4 is a flow chart of a rollback task adding and deleting mechanism according to an embodiment of the present invention;

[0046] Figure 5 is a structural block diagram of a rollback device based on a finite state machine according to an embodiment of the present invention;

[0047] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution 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 described embodiments are 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0049] The following are the glossaries of the terms used in the embodiments of the present invention:

[0050] 1.Kubernetes (K8S for short) provides the concept of PersistentVolume, which is a persistent volume. The backend of a persistent volume is generally connected to network storage, that is, distributed storage. In order to abstract the demand and supply of persistent volumes, K8S provides another abstract PersistentVolume Claim (PVC), which expresses the user's request for storage. The template of PV is the Storage Class, which contains the basic configuration of PV.

[0051] 2. CSI (Container Storage Interface) is the storage plug-in currently used by K8S. After PVC is created, a volume is created in the backend storage cluster according to the storage class associated with PVC and bound to PV.

[0052] 3. CSI is divided into control components and node components. The embodiment of the present invention only focuses on the control components. When the control components are deployed in K8S, they are deployed in a master-slave mode, and the master-slave switching adopts the lease mechanism of K8S.

[0053] Based on the process of creating a PVC, the finite state machine-based rollback method provided in the embodiment of the present invention needs to consider the following aspects:

[0054] 1) Creating PVC is concurrent, and a storage structure that supports concurrency is required to cache the data to be rolled back;

[0055] 2) After receiving the failure result, CSI will keep retrying the creation, with an interval between each retry until the PVC is deleted. That is, after the first request times out, a rollback task needs to be added, and before the second retry creation, the rollback task needs to be deleted;

[0056] 3) In a high-availability scenario, the primary-slave switch will cause the rollback process to lose cached data. If it is not the primary node, the rollback task should not be processed;

[0057] 4) Rollback requests, including query and delete, may also time out. How to handle timeouts?

[0058] According to an embodiment of the present invention, a rollback method embodiment based on a finite state machine is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0059] In this embodiment, a rollback method based on a finite state machine is provided. Figure 1 is a flow chart of a rollback method based on a finite state machine according to an embodiment of the present invention, such as Figure 1 As shown, the process includes the following steps:

[0060] Step S101, obtaining the RBJob in the queue, and determining whether the status of the RBJob is canceled.

[0061] In the embodiment of the present invention, RBJob in the queue is obtained. RBJob is a single rollback task. First, the rollback task abstraction and finite state machine design are performed. The single rollback task contains specific execution parameters for query and deletion. The key stored in the dictionary is the specific PV name, so that the same PV will only be added to the task once.

[0062] Determine whether the status of RBJob is canceled. The cancel status is a single variable. Tasks in the cancel status will be deleted after the loop starts, that is, the subsequent rollback process will not be executed.

[0063] Step S102: If the RBJob is in a non-cancel state, the state of the RBJob is obtained in sequence based on the finite state machine to perform rollback task abstraction.

[0064] In the embodiment of the present invention, the status of RBJob includes new task creation status, querying checking query status, confirming status, removing deletion status, and end ending status.

[0065] Considering the complexity of rollback, the finite state machine mechanism is introduced. The finite state machine is a tool for object behavior modeling. Its main function is to describe the state sequence that an object goes through during its life cycle and how to respond to various events from the outside world. The rollback task is abstracted and given different states. Each state only needs to process a fixed process, which can greatly simplify the complexity of task execution.

[0066] After getting a RBJob in the queue, lock it and determine whether the RBJob is in cancel state. The cancel state is a single variable. Tasks in the cancel state will be deleted after the loop starts, that is, the subsequent rollback process will not be executed. If the RBJob is in cancel state, delete the RBJob from the queue. If the RBJob is not in cancel state, get the state of the RBJob.

[0067] Step S103: Use the RBDict data structure to cache the RBJob, and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

[0068] In the embodiment of the present invention, considering that tasks need to be obtained according to PV names for saving and deletion, a concurrent safe dictionary structure, called RBDict, is used to cache RBJobs. The entire rollback process needs to be run once at intervals, and each time all RBJobs need to be traversed for processing until the interval value is greater than or equal to the initial interval value.

[0069] The finite state machine-based rollback method provided in this embodiment designs a rollback mechanism based on the finite state machine mechanism, designs the state of the rollback task to formulate the running process in each state, simplifies the complexity of the rollback task, introduces the running interval interval value to prevent accidental deletion, and is applicable to all mainstream K8S container orchestration systems and resource residual rollback scenarios caused by network requests. It improves the problem of backend resource residual caused by network problems when K8S creates PVC, and prevents a large amount of resource residual caused by abnormal network environment.

[0070] In this embodiment, a rollback method based on a finite state machine is provided, and the process includes the following steps:

[0071] Step S201, obtaining the RBJob in the queue, and determining whether the state of the RBJob is canceled.

[0072] For details, please see Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.

[0073] Step S202: If the RBJob is in a non-cancel state, the state of the RBJob is obtained in sequence based on the finite state machine to perform rollback task abstraction.

[0074] Specifically, the above step S202 includes:

[0075] Step S2021, when the status of RBJob is the task creation status, a query request is sent to enter the check query status.

[0076] Step S2022: If the query result satisfies the rollback condition, the confirmation state is entered.

[0077] Step S2023, execute deletion of storage resources, and enter the deletion state after sending the deletion request.

[0078] Step S2024: storage resource deletion is being executed, and after successful execution, the process enters the end state.

[0079] In this embodiment of the present invention, RBJob has the following five states:

[0080] (1) new: indicates that the task is newly created. After the query request is issued, it can enter the querying state;

[0081] (2) querying: indicates checking whether the query result meets the rollback condition. If so, the system enters the confirm state.

[0082] (3) confirm: indicates that the rollback jump is satisfied and the storage resource can be deleted. After the deletion request is issued, the state can be entered into the removing state.

[0083] (4) Removing: Indicates that the deletion is in progress. After successful execution, the state can be entered into the end state:

[0084] (5)end: indicates that the task is completed and no operation is performed.

[0085] The five states change in sequence. The condition for querying to change to confirming state is that the underlying storage exists and the PV does not exist.

[0086] By designing the state of the rollback task based on the finite state machine mechanism, it is convenient to formulate the operation process in each state, which greatly simplifies the complexity of the rollback task.

[0087] Step S203: Use the RBDict data structure to cache the RBJob, and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

[0088] For details, please see Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.

[0089] In some optional embodiments, the method further comprises:

[0090] Step Sa, set the initial value of the interval of RBJob.

[0091] Step Sb: Each time a task is created, the interval value is reduced by one.

[0092] Step Sc: if the interval value is smaller than the initial value, roll back.

[0093] In the embodiment of the present invention, the entire rollback process needs to be run once at a certain interval, and each time it needs to traverse all rollback tasks for processing. The interval time needs to be greater than the created retry interval, and all RBJobs must initially set the interval variable to 1, that is, the initial value is 1. Each time a RBJob in the new state is executed, the interval value is reduced by one. The rollback process is executed only when the interval is less than 1 to ensure that the rollback process will not be executed within the retry interval.

[0094] By setting the initial interval value of RBJob, the rollback process is executed according to the interval value, thus avoiding the situation where the rollback is performed within the retry interval.

[0095] Step S204, when receiving the asynchronous request result of checking RBJob, determine whether the request result is successful.

[0096] Step S205: If the check request result is unsuccessful, determine whether a timeout error occurs in the creation request.

[0097] Step S206: If a timeout error occurs in the creation request, the RBJob is added to the cache.

[0098] In the embodiment of the present invention, it is checked whether the asynchronous request result of RBJob is received. If the asynchronous request result of RBJob is received, it is determined whether the request result is successfully checked. If the request result is not successfully checked, it is determined whether a timeout error occurs in the creation request. If a timeout error occurs in this creation request, it is necessary to add RBJob to the cache.

[0099] By considering the smoothness of the rollback process, an asynchronous processing mechanism for rollback requests is designed to avoid timeout blocking due to network reasons, and a corresponding request response processing mechanism is designed using asynchronous requests.

[0100] Step S207: If the creation request does not time out, the RBJob is deleted.

[0101] In the embodiment of the present invention, if the creation request does not have a timeout error, the cancel state of the RBJob is set to true and the state is set to end to delete the RBJob.

[0102] Considering the timeout of the rollback task, RBJob is deleted to ensure the stability of the rollback task.

[0103] In some optional implementations, the above step S207 includes:

[0104] Step S2071, obtain the corresponding RBJob according to the key, and lock the RBJob.

[0105] Step S2072, setting the cancel state of RBJob to true.

[0106] Step S2073, unlock RBJob.

[0107] Step S2074, if RBJob is in the deletion state, block until the deletion operation receives the result.

[0108] In an embodiment of the present invention, when deleting an RBJob, first obtain the corresponding RBJob through the key to determine whether the RBJob exists. If the RBJob does not exist, end directly. If the RBJob exists, lock the RBJob. When removing the RBJob, do not delete it directly, but first determine whether the cancel status is True. If it is True, unlock the RBJob directly. If it is not True, set the cancel status of the RBJob to True, and then unlock the RBJob. After the RBJob is unlocked, determine whether the RBJob is in the removing state. If it is not in the removing state, end directly. If it is in the removing state, block until the deletion operation receives the result.

[0109] The finite state machine-based rollback method provided in this embodiment locks RBJob before deleting the rollback task to avoid the impact caused by task deletion, sets the cancel state of RBJob to true instead of directly deleting it, and deletes it when the rollback mechanism runs to the task, thereby improving the deletion mechanism of RBJob.

[0110] like Figure 2As shown in Figure 2, it is a flow chart of the Rollback loop mechanism. At the beginning of the loop, a RBJob in the queue is obtained and locked. It is determined whether the RBJob is in the cancel state. If the RBJob is in the cancel state, the RBJob is deleted from the queue. If the RBJob is in a non-cancel state, it is determined whether the current node is a master node. If the current node is a non-master node, the RBJob is deleted from the queue. If the current node is a master node, it is determined whether the execution interval interval is less than or equal to 0. If the execution interval interval is less than or equal to 0, the RBJob status is obtained in sequence. The RBJob status is obtained. When the status is new, an asynchronous querying operation is issued and the RBJob is set to the querying state. When the status is querying, an asynchronous result check operation is performed. When the status is confirm, an asynchronous removal operation is issued and the RBJob is set to the removal state. When the status is removal, an asynchronous result check operation is performed. If the execution interval interval is greater than 0, the execution interval interval is reduced by one, and the loop ends.

[0111] Considering that querying and deleting will also take a certain amount of time, which will cause the time spent on rolling back a single task to be longer, an asynchronous call mechanism is adopted, that is, sending requests and reading responses are processed separately. Figure 3 As shown, Figure 3 The flowchart for checking the asynchronous request result is as follows: First, check whether the asynchronous request result of RBJob is received. If not, end directly. If the asynchronous request result of RBJob is received, determine whether the request result is successful. If the request result is not successful, determine whether a timeout error occurs. If a timeout error occurs, roll back to the migration state (new / confirm). If no timeout error occurs, set the cancel state of RBJob to true, and the state to end, and delete RBJob. If the request result is successful, determine whether it is a query operation. If it is not a query operation, remove is executed successfully, set the cancel state of RBJob to true, and the state to end, and delete RBJob. If it is a query operation, determine whether the confirm condition is met. If the confirm condition is met, set RBJob to the confirm state. If the confirm condition is not met, set the cancel state of RBJob to true, and the state to end, and delete RBJob.

[0112] like Figure 4 As shown, Figure 4This is a flowchart of the RBJob adding and deleting mechanism. It is divided into adding mechanism and deleting mechanism. It supports the mechanism of dynamically adding and deleting rollback tasks, supports concurrency, supports master-slave switching, and can continue to work in complex situations. After the creation of the PV named A times out, a rollback task needs to be added. Add RBJob to RBDict. If there is already the same key, directly replace the value (status is new, interval value is 1, cancel is False). When creating a PV named A, you need to delete the rollback task first, delete RBJob, and get the corresponding RBJob through the key. If it does not exist, it ends directly. If it exists, lock RBJob, determine whether the cancel status is true, if true, unlock RBJob, and end the process. If the cancel status is not true, set the cancel status of RBJob to true, unlock RBJob. Determine whether RBJob is in the removing state. If not, it ends directly. If it is in the removing state, block until the deletion operation receives the result and end the process.

[0113] The finite state machine-based rollback method provided in this embodiment has the following main advantages:

[0114] (1) Taking into account complex situations such as active / standby switching, retry mechanism, concurrent creation, and rollback timeout, the stability of the rollback task and the robustness of the program are ensured;

[0115] (2) The finite state machine mechanism allows the rollback tasks of various states to execute the processes in their respective states in an orderly manner. After the rollback request times out, the state can be rolled back, simplifying complex situations.

[0116] (3) Rollback mechanism designed based on finite state machine mechanism. Based on the finite state machine mechanism, the state of the rollback task is designed, and the operation process under each state is formulated, which greatly simplifies the complexity of the rollback task. The entire mechanism introduces a running interval to prevent accidental deletion. When a timeout error occurs in the rollback task, the state can be rolled back without affecting subsequent processing;

[0117] (4) A rollback task operation mechanism based on a state machine, including an asynchronous processing mechanism for rollback requests. Considering the smoothness of the rollback process and avoiding timeouts due to network reasons, the rollback uses asynchronous requests and designs a corresponding request response processing mechanism;

[0118] (5) Supports dynamic addition and deletion of rollback tasks. Supports concurrency and active / standby switching, and can continue to work even in complex situations.

[0119] In this embodiment, a rollback device based on a finite state machine is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the term "module" may be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0120] This embodiment provides a rollback device based on a finite state machine, such as Figure 5 As shown, including:

[0121] The first determination module 501 is used to obtain the RBJob in the queue and determine whether the status of the RBJob is canceled.

[0122] The acquisition module 502 is used to acquire the status of RBJob in sequence based on the finite state machine and perform rollback task abstraction if RBJob is in a non-cancel state. The status of RBJob includes task creation status, check query status, confirmation status, deletion status, and end status.

[0123] The first cache module 503 is used to cache RBJobs using the RBDict data structure and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

[0124] In some optional implementations, the acquisition module 502 includes:

[0125] The first state acquisition unit is used to send a query request to enter the check query state when the state of RBJob is the task creation state.

[0126] The second state acquisition unit is used to enter the confirmation state if the result of the check query meets the rollback condition.

[0127] The third state acquisition unit is used to execute the deletion of storage resources and enter the deletion state after sending the deletion request.

[0128] The fourth state acquisition unit is used to store that resource deletion is being executed and enter the end state after successful execution.

[0129] In some optional embodiments, the device further comprises:

[0130] The second judgment module is used to judge whether the request result is successful when receiving the asynchronous request result of checking RBJob.

[0131] The third judgment module is used to judge whether a timeout error occurs in the creation request if the check request result is unsuccessful.

[0132] The second cache module is used to add the RBJob to the cache if a timeout error occurs in the creation request.

[0133] In some optional embodiments, the device further comprises:

[0134] The delete module is used to delete the RBJob if the creation request does not time out.

[0135] In some optional implementations, the deletion module includes:

[0136] The locking unit is used to obtain the corresponding RBJob according to the key and lock the RBJob.

[0137] Setting unit, used to set the cancel state of RBJob to true.

[0138] Unlock unit, used to unlock RBJob.

[0139] The blocking unit is used to block until the deletion operation receives the result if the RBJob is in the deletion state.

[0140] In some optional embodiments, the device further comprises:

[0141] The setting module is used to set the initial value of the interval of RBJob.

[0142] The subtraction module is used to reduce the interval value by one each time a task is executed.

[0143] The rollback module is used to roll back if the interval value is less than the initial value.

[0144] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.

[0145] The finite state machine-based rollback device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0146] The embodiment of the present invention also provides a computer device having the above Figure 5 The finite state machine based rollback device is shown.

[0147] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6 As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.

[0148] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0149] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0150] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0151] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.

[0152] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.

[0153] The input device 30 can receive input digital or character information and generate key signal input related to user settings and function control of the computer device, such as a touch screen, etc. The output device 40 can include a display device, etc.

[0154] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0155] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.

[0156] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations all fall within the scope of the present application.

Claims

1. A rollback method based on a finite state machine, characterized in that: The method comprises: Get the RBJob in the queue and determine whether the status of the RBJob is canceled; If the RBJob is in a non-cancel state, the RBJob state is obtained in sequence based on the finite state machine to perform rollback task abstraction. The RBJob state includes task creation state, check query state, confirmation state, deletion state, and end state. Use the RBDict data structure to cache RBJobs and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

2. The method according to claim 1, characterized in that The step of sequentially obtaining the status of RBJob includes: When the RBJob status is the task creation status, a query request is sent to enter the check query status; If the query result meets the rollback condition, the confirmation state is entered; Execute the deletion of storage resources and enter the deletion state after sending the deletion request; Storage resource deletion is in progress and will enter the end state after successful execution.

3. The method according to claim 1, characterized in that The method further comprises: When receiving the asynchronous request result of checking RBJob, determine whether the request result is successful; If the check request result is unsuccessful, determine whether a timeout error occurs in the creation request; If a timeout error occurs during the creation request, the RBJob is added to the cache.

4. The method according to claim 3, characterized in that If the request result is unsuccessful, after determining whether a timeout error occurs in the creation request, the method further includes: If the creation request does not time out, the RBJob is deleted.

5. The method according to claim 4, characterized in that Deleting RBJob includes: Get the corresponding RBJob according to the key and lock the RBJob; Set the cancel status of RBJob to true; Unlock RBJob; If RBJob is in the delete state, it blocks until the delete operation receives the result.

6. The method according to claim 1, characterized in that The method further comprises: Set the initial interval value of RBJob; Each time a task is created, the interval value decreases by one; If the interval value is smaller than the initial value, rollback is performed.

7. A rollback device based on a finite state machine, characterized in that: The device comprises: The judgment module is used to obtain the RBJob in the queue and determine whether the status of the RBJob is canceled; The acquisition module is used to acquire the status of RBJob in sequence based on the finite state machine and perform rollback task abstraction if RBJob is in a non-cancel state. The status of RBJob includes task creation status, check query status, confirmation status, deletion status, and end status; The cache module is used to cache RBJobs using the RBDict data structure and traverse all RBJobs until the interval value is greater than or equal to the initial interval value.

8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the finite state machine-based rollback method described in any one of claims 1 to 6 by executing the computer instructions.

9. 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 computer to execute the finite state machine-based rollback method according to any one of claims 1 to 6.

10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the finite state machine-based rollback method according to any one of claims 1 to 6.