Rollback of services with global variable changes
By tracking the order of changes to global variables in a distributed system and generating a rollback execution plan for compensation services, the problem of inconsistent global variable recovery in a distributed system is solved, and the correct rollback of global variables is achieved, ensuring data consistency and correctness.
Patent Information
- Application Number
- CN202211210594.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-09-30
- Filing Date
- 2022-09-30
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2042-09-30
AI Technical Summary
In distributed systems, when business operations across multiple services fail, existing technologies struggle to ensure data consistency of global variables, especially when multiple services are executed in parallel or serially. The rollback process may prevent global variables from being restored to their initial state.
By tracking the order in which global variables are changed during service execution, a rollback execution plan for the compensation service is generated, ensuring that the compensation service is executed in the correct order to undo the changes to global variables.
It enables the correct restoration of global variables to their initial state in the event of business failure, ensuring data consistency and correctness across services.
Smart Images

Figure CN115904467B_ABST
Abstract
Description
Technical Field
[0001] This invention generally relates to distributed computing data consistency technology, and more specifically, to data rollback of global variables in a multi-service setup. Background Technology
[0002] Increasingly, service implementation involves multiple serial and / or parallel calls to other services in a distributed system. A business can be designed to include multiple services, where serial and / or parallel calls are possible. These service calls may succeed, fail due to errors, or enter an unknown state due to timeouts, in which case the business may succeed or fail. In distributed systems, businesses spanning multiple services require a mechanism to ensure data consistency across services, especially in the event of business failures. Typically, rollback mechanisms for managing failures provide compensatory services for each service within the business to ensure consistency and correctness across services. Summary of the Invention
[0003] According to one embodiment of this disclosure, a computer-implemented method is provided. According to the method, at least two of a plurality of services in a service are detected to be executed to change the value of a first global variable. Trace information is acquired to indicate a first order in which the at least two services changed the value of the first global variable during the execution of the plurality of services. In response to a service failure, a rollback execution plan for a plurality of compensation services is determined based on the trace information, wherein the plurality of compensation services are configured to compensate for the plurality of services respectively. The plurality of compensation services are then executed according to the rollback execution plan.
[0004] According to another embodiment of this disclosure, a system is provided. The system includes a processing unit and a memory coupled to the processing unit and storing instructions thereon. When the instructions are executed by the processing unit, the actions of any of the methods described above according to embodiments of this disclosure are performed.
[0005] According to yet another embodiment of this disclosure, a computer program product is provided, which is tangibly stored on a non-transitory machine-readable medium and includes machine-executable instructions. When executed on a device, the instructions cause the device to perform any of the methods described above according to embodiments of this disclosure. Attached Figure Description
[0006] The above and other objects, features and advantages of this disclosure will become more apparent from a more detailed description of some embodiments of this disclosure in the accompanying drawings, wherein like reference numerals refer to like components in the embodiments of this disclosure.
[0007] Figure 1 A cloud computing node according to some embodiments of the present disclosure is described.
[0008] Figure 2 A cloud computing environment according to some embodiments of the present disclosure is described.
[0009] Figure 3 An abstract model layer according to some embodiments of this disclosure is described.
[0010] Figure 4A and Figure 4B Examples of execution and rollback of business operations with the same global variables are described.
[0011] Figure 5 A block diagram depicts a computing architecture according to some embodiments of the present disclosure.
[0012] Figure 6A An example partitioning of services according to some embodiments of this disclosure is described.
[0013] Figure 6B Example correlations between service segments and compensation service segments according to some embodiments of this disclosure are described.
[0014] Figure 7 Compensation services generated for services according to some embodiments of this disclosure are described.
[0015] Figure 8 Example correlations between service segments and compensation service segments according to some embodiments of this disclosure are described.
[0016] Figure 9 Example execution of services according to some embodiments of this disclosure is described.
[0017] Figure 10 Examples of tracking information according to some embodiments of this disclosure are depicted.
[0018] Figure 11 Examples of rollback execution plans according to some embodiments of this disclosure are described.
[0019] Figure 12 Rollback execution of a compensation service for a business according to some embodiments of this disclosure is described.
[0020] Figure 13A Example correlations between service segments and compensation service segments according to some other embodiments of this disclosure are described.
[0021] Figure 13B Example execution of services according to some other embodiments of the present disclosure is described.
[0022] Figure 13C Examples of rollback execution plans according to some other embodiments of this disclosure are described.
[0023] Figure 13D An example rollback execution of a compensation service for a business according to some other embodiments of this disclosure is described.
[0024] Figure 14A Example correlations between service segments and compensation service segments according to further embodiments of this disclosure are described.
[0025] Figure 14B Example execution of services according to further embodiments of this disclosure is described.
[0026] Figure 14C Examples of rollback execution plans according to further embodiments of this disclosure are described.
[0027] Figure 14D Example rollback execution of a compensation service for a business according to further embodiments of this disclosure is described.
[0028] Figure 15 A flowchart illustrating example methods according to some embodiments of the present disclosure is provided. Detailed Implementation
[0029] Some embodiments will be described in more detail with reference to the accompanying drawings, which illustrate embodiments of the present disclosure. However, the present disclosure may be implemented in various ways and should not be construed as limited to the embodiments disclosed herein.
[0030] It should be understood that while this disclosure includes a detailed description of cloud computing, the implementation of the teachings described herein is not limited to cloud computing environments. Rather, embodiments of this disclosure can be implemented with any other type of computing environment now known or hereafter developed.
[0031] Cloud computing is a service delivery model that enables convenient, on-demand access to configurable computing resources (e.g., networks, network bandwidth, servers, processing power, storage devices, applications, virtual machines, and services) that can be rapidly provisioned and released with minimal management effort or interaction with the service provider. This cloud model may include at least five features, at least three service models, and at least four deployment models.
[0032] The features are as follows:
[0033] On-demand self-service: Cloud consumers can unilaterally and automatically provide computing power, such as server time and network storage, as needed, without requiring human interaction with the service provider.
[0034] Extensive network access: Capabilities are available through networks and accessed via standard mechanisms that facilitate the use of heterogeneous thin client platforms or thick client platforms (e.g., mobile phones, laptops, and PDAs).
[0035] Resource pooling: A provider's computing resources are pooled to serve multiple consumers using a multi-tenant model, where different physical and virtual resources are dynamically assigned and reassigned as needed. There is a sense of location independence because consumers typically do not have control or knowledge of the exact location of the resources provided, but may be able to specify the location at a higher level of abstraction (e.g., country, state, or data center).
[0036] Rapid flexibility: The ability to provide capacity quickly and flexibly, automatically scaling down and up rapidly in some situations to scale up rapidly. For consumers, the available supply capacity often appears unlimited and can be purchased in any quantity at any time.
[0037] Measuring services: Cloud systems automatically control and optimize resource usage by leveraging metering capabilities at a level of abstraction appropriate to the service type (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency to both service providers and consumers.
[0038] The service model is as follows:
[0039] Software as a Service (SaaS): This provides consumers with the ability to use the provider's applications running on cloud infrastructure. Applications can be accessed from different client devices through thin client interfaces such as web browsers (e.g., web-based email). Consumers do not manage or control the underlying cloud infrastructure, including the network, servers, operating system, storage, or even individual application capabilities, with possible exceptions such as limited user-specific application configuration settings.
[0040] Platform as a Service (PaaS): This provides consumers with the ability to deploy applications created or acquired by the consumer using programming languages and tools supported by the provider onto cloud infrastructure. Consumers do not manage or control the underlying cloud infrastructure, including networks, servers, operating systems, or storage, but they have control over the deployed applications and the configuration of any application hosting environment.
[0041] Infrastructure as a Service (IaaS): The capabilities offered to consumers are processing, storage, networking, and other basic computing resources that enable consumers to deploy and run arbitrary software, which may include operating systems and applications. Consumers do not manage or control the underlying cloud infrastructure, but rather have control over the operating system, storage, deployed applications, and potentially limited control over selected networking components (e.g., host firewalls).
[0042] The deployment model is as follows:
[0043] Private cloud: A cloud infrastructure that operates solely for an organization. It can be managed by the organization or a third party and can exist on-site or off-site.
[0044] Community cloud: A cloud infrastructure shared by several organizations and supporting a specific community with shared concerns (e.g., tasks, security requirements, policies, and compliance considerations). It can be managed by an organization or a third party and can exist on-site or off-site.
[0045] Public cloud: Makes cloud infrastructure available to the public or large industry groups and is owned by an organization that sells cloud services.
[0046] Hybrid cloud: A cloud infrastructure is a combination of two or more clouds (private, community, or public) that remain a single entity but are bound together by standardized or proprietary technologies that enable data and applications to be ported (e.g., cloud bursting for load balancing between clouds).
[0047] Cloud computing environments are service-oriented, focusing on statelessness, loose coupling, modularity, and semantic interoperability. At the heart of cloud computing is the infrastructure comprising a network of interconnected nodes.
[0048] See Figure 1 An example of a cloud computing node is shown. Cloud computing node 10 is merely an example of a suitable cloud computing node and is not intended to limit the scope of use or functionality of the embodiments described herein. In any case, cloud computing node 10 is capable of implementing and / or performing any of the functions described above.
[0049] In cloud computing, node 10 contains a computer system / server 12 or a portable electronic device such as a communication device, which may be suitable for use with a wide variety of other general-purpose or special-purpose computing system environments or configurations. Examples of known computing systems, environments, and / or configurations suitable for use with computer system / server 12 include, but are not limited to, personal computer systems, server computer systems, thin clients, fat clients, handheld or laptop devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics devices, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the above systems or devices, etc.
[0050] Computer system / server 12 can be described within the overall context of computer system executable instructions (such as program modules) executed by the computer system. Typically, program modules can include routines, programs, objects, components, logic, data structures, etc., that perform specific tasks or implement specific abstract data types. Computer system / server 12 can be implemented in a distributed cloud computing environment, where tasks are performed by remote processing devices linked via a communication network. In a distributed cloud computing environment, program modules can reside on local and remote computer system storage media, including memory storage devices.
[0051] like Figure 1 As shown, the computer system / server 12 in cloud computing node 10 is illustrated in the form of a general-purpose computing device. The components of the computer system / server 12 include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that couples various system components, including the system memory 28, to the processor 16.
[0052] Bus 18 represents one or more of various bus architectures, including memory buses or memory controllers, peripheral buses, accelerated graphics ports, and processor or local buses using various bus architectures. For example, without limitation, such architectures include Industry Standard Architecture (ISA) buses, Micro Channel Architecture (MCA) buses, Enhanced ISA (EISA) buses, Video Electronics Standard Associated (VESA) local buses, and Peripheral Component Interconnect (PCI) buses.
[0053] Computer system / server 12 typically includes various computer system readable media. Such media can be any available media that can be accessed by computer system / server 12, and includes volatile and non-volatile media, removable and non-removable media.
[0054] System memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer system / server 12 also includes other removable / non-removable, volatile / non-volatile computer system storage media. For example, storage system 34 may be provided for reading or writing to non-removable non-volatile magnetic media (not shown and generally referred to as a "hard disk drive"). Although not shown, a disk drive may be provided for reading or writing to removable non-volatile disks (e.g., "floppy disks"), and an optical disk drive may be provided for reading or writing to removable non-volatile optical discs (such as CD-ROMs, DVD-ROMs, or other optical media). In this case, each may be connected to bus 18 via one or more data media interfaces. Further description and illustration will follow, and memory 28 may include at least one program product having a collection of program modules (e.g., at least one program module) configured to perform the functions of embodiments of this disclosure.
[0055] A program / utility 40 having a collection of program modules 42 (at least one program module) may, for example but not limited to, be stored in memory 28 along with an operating system, one or more applications, other program modules, and program data. Each or some combination of the operating system, one or more applications, other program modules, and program data may include an implementation of a network environment. Program modules 42 typically perform the functions and / or methods of the disclosed embodiments as described herein.
[0056] The computer system / server 12 also communicates with one or more external devices 14, such as a keyboard, positioning device, display 24, etc.; one or more devices that enable a user to interact with the computer system / server 12; and / or any device that enables the computer system / server 12 to communicate with one or more other computing devices (e.g., network interface card, modem, etc.). This communication may be via input / output (I / O) interface 22. However, the computer system / server 12 may communicate with one or more networks (such as local area networks (LANs), general area networks (WANs), and / or public networks (e.g., the Internet) via network adapter 20. As described, network adapter 20 communicates with other components of the computer system / server 12 via bus 18. It should be understood that, although not shown, other hardware and / or software components may be used in conjunction with the computer system / server 12. Examples include, but are not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archiving storage systems.
[0057] refer to Figure 2This describes an illustrative cloud computing environment 50. As shown, the cloud computing environment 50 includes one or more cloud computing nodes 10 to which local computing devices used by cloud consumers can communicate. These local computing devices include, for example, personal digital assistants (PDAs) or cellular phones 54A, desktop computers 54B, laptop computers 54C, and / or automotive computer systems 54N. The nodes 10 can communicate with each other. They can be physically or virtually grouped (not shown) in one or more networks, such as private clouds, community clouds, public clouds, or hybrid clouds, or combinations thereof, as described above. This allows the cloud computing environment 50 to provide infrastructure, platforms, and / or software as services that cloud consumers do not need to maintain on their local computing devices. It should be understood that... Figure 2 The types of computing devices 54A-N shown are intended to be illustrative only, and computing node 10 and cloud computing environment 50 can communicate with any type of computerized device via any type of network and / or network-addressable connectivity (e.g., using a web browser).
[0058] Now for reference Figure 3 This demonstrates a cloud computing environment of 50 ( Figure 2 This provides a set of functional abstractions. It should be understood beforehand that... Figure 3 The components, layers, and functions shown are for illustrative purposes only, and embodiments of the invention are not limited thereto. As described, the following layers and corresponding functions are provided.
[0059] The hardware and software layer 60 includes hardware and software components. Examples of hardware components include: a host 61; a server 62 based on a RISC (Reduced Instruction Set Computer) architecture; a server 63; a blade server 64; a storage device 65; and network and networking components 66. In some embodiments, software components include network application server software 67 and database software 68.
[0060] The virtualization layer 70 provides an abstraction layer from which the following examples of virtual entities can be provided: virtual server 71; virtual storage device 72; virtual network 73, including virtual private network; virtual application and operating system 74; and virtual client 75.
[0061] In one example, management layer 80 can provide the functionality described below. Resource provisioning 81 provides dynamic procurement of computing resources and other resources used to perform tasks within the cloud computing environment. Metering and pricing 82 provides cost tracking when utilizing resources in the cloud computing environment, as well as billing or invoicing for the consumption of these resources. In one example, these resources may include application software licenses. Security provides authentication for cloud consumers and tasks, and protection for data and other resources. User portal 83 provides access to the cloud computing environment for consumers and system administrators. Service level management 84 provides cloud resource allocation and management to ensure the required service level is met. Service level agreement (SLA) planning and fulfillment 85 provides pre-scheduling and procurement of cloud resources, where future needs are anticipated according to the SLA.
[0062] Workload layer 90 provides examples of functionalities that can be leveraged in a cloud computing environment. Examples of workloads and functionalities that can be provided from this layer include: mapping and navigation 91; software development and lifecycle management 92; virtual classroom education delivery 93; data analytics and processing 94; transaction processing 95; and service rollback 96. The functionality of service rollback 96 will be described in the following embodiments of this disclosure.
[0063] In distributed systems, business processes spanning multiple services require a mechanism to ensure data consistency across services. The distributed "saga" pattern is a fault management pattern where each action has a compensating action for rollback, which can help ensure consistency and correctness across services. A "saga" represents a high-level business process composed of several low-level requests, each updating data within a single service. Each service has a compensating service that executes when a service fails or the saga aborts.
[0064] As used herein, the term "service" refers to a collection of any type of software program or software module that provides a certain function. As used herein, the term "business" refers to a high-level service comprising several low-level services that update data within a single service. Therefore, a business can include multiple services, which can be considered a saga. In some cases, a business with multiple services can be called a macro-business, and services can be called micro-businesses. In other cases, a "business" can be called a service, and the "services" included within a business can be called microservices.
[0065] As mentioned above, a rollback mechanism is needed to manage failures in businesses with distributed services. Typically, once a business starts, data can be accessed and modified by executing these services. Rolling back a business will undo any changes, allowing data modified during execution to be restored to its value before execution began. Individual compensation services can be provided to implement service rollbacks.
[0066] Traditional rollback processes are executed at the service level. However, in some cases, if two or more services are executed to modify the same variable, the rollback result may be incorrect. Figure 4A and Figure 4B Examples of execution and rollback of services with the same global variables are shown. Global variables are variables with global scope that are visible and / or accessible across multiple services (or multiple microservices within a single service).
[0067] As shown in the figure, the example business "Travel Booking" includes several services, including service 410 "Book a Trip" for starting the business, service 420 "Book a Flight" for booking flights, service 430 "Book a Hotel" for booking hotels, service 440 "Add Points" for adding reward points to the account after booking flights, and service 450 "Add Points" for adding reward points to the account after booking hotels. Service 440 "Add Points" is configured to increase reward points by 1000. Service 450 "Add Points" is configured to weight reward points with a coefficient of "1.01".
[0068] Figure 4A This illustrates the various time spans of the services provided during the execution of the business. Service 410 begins at T0, and then services 420 and 430 are invoked by service 410 at T1 to book flights and hotels, respectively. The execution of services 420 and 430 may continue for a certain duration. Figure 4A As shown, the execution of service 420 is completed first in T2. Once service 420 is complete, service 440 will be called and executed to update the global variable "reward points" from its initial value "5000" to "6000" in T3. The execution of service 440 is completed in T7. The execution of service 430 is completed in T4, which is later than the completion time of service 420 (T2). Once service 430 is complete, service 450 will be called and executed to change the global variable "reward points". Since the global variable "reward points" has already been updated by service 440 to have the value "6000", service 450 can continue to update the value "6000" to "6060" in T5. The execution of service 450 is completed in T6. After services 420, 430, 440, and 450 are completed, service 410 is completed in T8.
[0069] In some cases, if a service fails (or aborts) with a 402 error, a rollback of the 402 error can be performed by executing a compensation service on the services included in the 402 error. For example... Figure 4BAs shown, the rollback of service 402 starts from Tm0 (note the timeline from right to left). In Tm2, rollback 445 of service 440, "Add Point," is initiated. By undoing the operation of service 440 (e.g., canceling weighting), in Tm3, the global variable "Reward Points" changes from "6060" to "5060." Rollback 445 completes in Tm4, and then rollback 425 of service 420, "Book Flights," is invoked. Rollback 455 of service 450, "Add Point," also begins, and the global variable "Reward Points" is changed in Tm5, later than Tm3. Therefore, by undoing the operation of service 450 (e.g., canceling the add), the global variable "Reward Points" changes from "5060" to "5009." Rollback 455 completes in Tm6, and then rollback 435 of service 430, "Book Hotels," is invoked. After rollbacks 425 and 435 of services 420 and 430 were completed in Tm7, the entire rollback of service 410 "Book a Trip" was completed in 415.
[0070] However, after the rollback, the value of the global variable "reward points" will not change to its initial value of "5000" at the start of service 402. This is because during the rollback process, the global variable first changes in rollback 445 of service 450, and then changes again in the rollback of service 440. According to... Figure 4A Regarding the execution order of services 440 and 450, the correct order to undo the changes is to first change the global variable "reward points" by undoing the operation of service 450, and then change the global variable by undoing the operation of service 440 later.
[0071] Because services 420 and 440 execute in parallel with services 430 and 450, their execution may last for different durations and complete at different times, depending on the tasks performed during execution and the corresponding resources available to these two services. Therefore, in Figure 4A In the example, although service 450 is called before service 440 to change the global variable, in other cases, service 420 might complete before service 430, and then service 440 could be called before service 450 to change the global variable. Therefore, changes to the same global variable by different services may be applied in different orders under different circumstances.
[0072] Keeping global variables tracked is crucial. If a business operation fails, it's essential to always roll back to a consistent previous state—that is, restore them to their initial values when the business operation started. If the rollback order of changes to global variables isn't carefully controlled, it might be impossible to restore global variables to their initial state when rolling back the business operation, which is undesirable.
[0073] According to an example embodiment of this disclosure, a scheme for using global variables to modify service rollback is proposed. In this solution, if two or more services of a business are executed to modify the same global variable, the order in which the two or more services change the value of the global variable is tracked during the execution of the business services. In the event of a business failure, a rollback execution plan for multiple compensation services is determined based on the tracked order. Multiple compensation services are then executed according to the rollback execution plan.
[0074] By tracking the order in which global variables are changed during service execution, the rollback sequence of the compensation service can be controlled based on the timing of global variable modifications. Therefore, global variables can be correctly restored to their initial state.
[0075] Other advantages of this disclosure will be explained below with reference to embodiments and accompanying drawings.
[0076] Now for reference Figure 5 It shows a block diagram of a computing architecture 500 according to some embodiments of the present disclosure.
[0077] As shown in the figure, in the computing architecture 500, the service management system 502 is configured to control and manage the deployment, execution, and rollback of services for a business application. For illustrative purposes, an example business application 510 is shown. As shown, business application 510 includes multiple services, including service 512 (represented as "Service_A"), service 514 (represented as "Service_B"), service 516 (represented as "Service_C"), service 515 (represented as "Service_D"), and service 517 (represented as "Service_E"). These services of business application 510 can be deployed to the service execution environment 504 for execution. The services of business application 510 can make multiple serial and / or parallel calls to one or more other services. For example, service 512 can make parallel calls to services 514 and 516, while services 514 and 515 can be executed serially.
[0078] It should be understood that service 510 is provided as an example. In some examples, service 512 can make parallel calls to two or more services or call a single service. In some examples, one or more of services 514, 515, 516, and 517 can make serial and / or parallel calls to one or more other services.
[0079] In some embodiments, the service management system 502 may, for example, deploy various services of service 510 to service execution environment 504 in response to a user request or other event. Service execution environment 504 may include various infrastructure devices to provide a pool of physical resources to support the services executed thereon. Resources provided in service execution environment 504 may include processing resources, memory, storage devices, network resources, etc. In some embodiments, service execution environment 504 may be a cloud computing environment, such as a public cloud or a private cloud.
[0080] The service management system 502 includes a coordinator 520, which is configured to deploy the various services of business 510 in a distributed manner within the service execution environment 504. As a specific example, the services of business 510 may be deployed in a container-based service execution environment 504. Figure 5 As shown, service 512 is deployed in container 550, service 514 in container 552, service 515 in container 554, service 516 in container 556, and service 517 in container 558. In some examples, depending on deployment requirements and the configuration of the service management system 502, one or more containers may be launched and formed into a collection of containers (pods) to run one or more services within them. In some examples, services implemented in containers within service execution environment 504 can communicate with each other, for example, through proxies provided within the containers and application programming interfaces (APIs) configured for the services. It should be understood that in other implementations, services may not be deployed based on containers, and therefore, service execution environment 504 does not contain any containers.
[0081] The distributed implementation of service 510 can be referred to as the saga pattern. In some embodiments, during operation, the services of service 510 can be executed in a command / orchestration mode, wherein the coordinator 520 is configured to centralize the decision-making and sequencing logic among services. In some embodiments, during operation, the services of service 510 can be executed in an event-driven orchestration, wherein there is no central coordination, and each service is running and listening for events from other services to determine whether to take action.
[0082] According to embodiments of this disclosure, the business management system 502 is also configured to implement a rollback mechanism for services (such as service 510). Figure 5 As shown, in addition to the coordinator 520, the business management system 502 also includes a global variable inspector 530 and a tracking server 540.
[0083] Global variable inspector 530 is configured to detect the presence of one or more global variables in service 510. As used herein, a global variable refers to a variable whose value will be changed by two or more services of the service. Such variables may be defined based on services and services. In some embodiments, global variable inspector 530 may detect such global variables by examining the code or deployment specifications of the individual services of service 510. Global variable inspector 530 may perform the global variable check when service 510 is to be deployed, during deployment, or after deployment.
[0084] If one or more global variables are detected, the tracing server 540 is configured to collect tracing information 542 during the execution of the service performing business 510. In some embodiments, the tracing server 540 may communicate with a container in which the service is deployed, or with an agent within the container (if available), to collect the tracing information 542. In particular, for global variables detected in business 510, the collected tracing information 542 can be used to determine or indicate the order in which two or more services of business 510 change the value of the global variable during the execution of the service. If multiple global variables are detected, the tracing server 540 may be configured to acquire tracing information for each global variable. In some embodiments, the tracing information 542 may indicate the timing of changes made to the global variables by two or more services (one or more) during execution.
[0085] The service of business 510 in service execution environment 504 can be executed in response to requests from users, other services, and / or other events. Since business 510 may not complete successfully every time, in order to ensure data consistency across services, trace information 542 related to detected global variables(s) can be collected for use in the rollback of business 510.
[0086] Coordinator 520 is configured to generate a rollback execution plan 522 based at least on trace information 542 in the event of a failure of service 510. To support the rollback of service 510, multiple compensation services are configured to compensate multiple services of service 510 respectively. Rollback execution plan 522 indicates how the multiple compensation services should be executed when a rollback is performed on service 510. Compensation services will also be deployed in service execution environment 504 for execution.
[0087] As shown in the diagram, Compensation Service 562 (represented as "Service_A_C") is deployed for Compensation Service 512, where "C" stands for "Compensation". Compensation Service 562 can be deployed together with Service 512 in container 550. Compensation Service 564 (represented as "Service_B_C") is deployed for Compensation Service 514 and can be deployed in container 552. Compensation Service 566 (represented as "Service_C_C") is deployed for Compensation Service 516 and can be deployed in container 556. Compensation Service 565 (represented as "Service_D_C") is deployed for Compensation Service 515 and can be deployed in container 554. Compensation Service 567 (represented as "Service_E_C") is deployed for Compensation Service 517 and can be deployed in container 558.
[0088] It should be understood that, despite Figure 5 The compensation services shown are configured within the same container as the services of this business, but in other embodiments, they may be deployed in separate containers.
[0089] Since the tracing information acquired during service execution indicates the order in which two or more services of service 510 change the values of one or more global variables during each execution, a rollback execution plan 522 can be generated to specify the execution order of the compensation services. In some embodiments, for global variables, a rollback execution plan 522 can be generated to specify the order in which two or more compensation services are executed to change the value of a first global variable. The two or more compensation services are compensation services configured to compensate service 510 for the global variable in which it is detected. The changes made to the global variable by the two or more compensation services can be specified in the rollback execution plan 522 as the opposite of the changes made to the global variable by the corresponding service of service 510. Therefore, according to the rollback execution plan, the changes made to each global variable can be reversed sequentially.
[0090] When a rollback execution plan 522 is generated, the coordinator 520 is configured to execute compensation services in the service execution environment 504 according to the rollback execution plan 522. The compensation services can then be controlled to execute in the order specified by the rollback execution plan 522. By using the trace information 542 collected during the service execution, the execution order of the compensation services can be well controlled to achieve proper rollback of one or more global variables(s). Therefore, the service 510 can be correctly rolled back to its initial state.
[0091] It should be understood that a service management system 502 can be implemented by one or more computing systems or devices with computing and storage capabilities. For example, a service management system 502 can be implemented by one or more computing platforms, servers, mainframes, general-purpose computing devices, cloud environments, etc.
[0092] It should also be understood that, Figure 5 The components of the service management system 502 shown can be implemented as one or more software engines, components, etc., configured with logic for implementing functions belonging to a specific module. Each component can be implemented using one or more such software engines, components, etc. The software engines, components, etc. execute on one or more processors of one or more computing systems or devices, and utilize or manipulate data stored in one or more storage devices, memories, etc., on one or more computing systems. In some embodiments, the coordinator 520 can be implemented in the entry gateway of the service execution environment 504.
[0093] In some embodiments, the global variable inspector 530 can be implemented as a FaaS host. Although shown separately, the service management system 502 can be implemented in the same computing environment as the service execution environment 504, such as in a cloud environment.
[0094] In some embodiments, to control the order in which changes to global variables are applied in a more granular manner, one or more compensation services may be generated as service segments that can be invoked independently. One or more compensation services may be defined as services that compensate for changes to the values of one or more global variables(s). Some detailed embodiments will be discussed below. In some embodiments, the generation, deployment, and / or management of compensation services may be performed by coordinator 520.
[0095] In some examples, within services 512, 514, 515, 516, and 517 of service 510, it is assumed that services 515 and 517 (“Service_D” and “Service_E”) are executed to change the value of the same global variable (denoted as global variable “x”). In other examples, two or more services among services 512, 514, 515, 516, and 517 may be executed to change the value of another or more global variables, and examples will be illustrated subsequently.
[0096] To generate compensation services 565 and 567 for services 515 and 517, each of services 515 and 517 can be divided into a service segment sequence based on the location of the executable code segment that changes the value of the global value "x". Then, each of compensation services 565 and 567 can be generated as a sequence of compensation service segments to compensate the corresponding service's service segment sequence. During execution, the compensation service sequence can be invoked independently.
[0097] The generation of compensation service 515 is as follows Figure 6A and Figure 6B As shown. Figure 6A Example partitioning of service 515 according to some embodiments of this disclosure is depicted. A global inspector 530 can detect code segment 605 from the code of service 515, which is executable to change the value of the global variable "x". The global inspector 530 can notify the coordinator 520 of the detection results. The coordinator 520 can partition service 515 into service segment sequences 610-1, 610-2, and 610-3, respectively denoted as "Service_D_P1", "Service_D_P2", and "Service_D_P3", as follows. Figure 6A As shown. These service segments 610-1, 610-2, and 610-3 are sometimes collectively referred to as service segment 610. Service segment 610-2 includes code segment 605, which can therefore be executed to change the value of the global variable "x".
[0098] In some embodiments, service segments 610-1, 610-2, and 610-3 are divided in order from the beginning to the end of the code of service 515. This division may be performed based on the location of code segment 605. In some embodiments, service segments 610-1, 610-2, and 610-3 are determined in such a way that the code segments contained within a single service segment may be executable when invoked. In some examples, service segment 610-2 is identified based on the code of service 515, the remaining code segments before service segment 610-2 may form service segment 610-1, and the remaining code segments after 610-2 may form service segment 610-3.
[0099] In some embodiments, to identify the start and end boundaries of each service segment 610, a label indicating the scope of the service segment 610 can be marked in the code of service 515. In some embodiments, to facilitate the collection of tracing information 542, a set of statements 608 can be added to service segment 610-2 to declare that service segment 610-2 includes a global variable, i.e., "x". Based on this set of statements 608, when service segment 610-2 is executed, the message "global_var_x changed" can be generated as output.
[0100] It should be understood that service segments can be divided at a finer granularity than those shown in the example for service 515. In some examples, if a service includes multiple code segments executable to change the values of global variables multiple times and / or if a service is executed to change the values of two or more global variables, a large number of service segments can be divided to generate corresponding compensating service segments. The following examples will illustrate and describe these examples.
[0101] To generate compensation service 565 for service 515, such as Figure 6B As shown, compensation service segment sequences 620-1, 620-2, and 630-3 can be included in compensation service 565, and are represented as "Service_D_C_P1", "Service_D_C_P2", and "Service_D_C_P3", respectively. Compensation services 620-1, 620-2, and 630-3 may sometimes be collectively referred to or individually as compensation service segment 620.
[0102] Compensation service 620-1 is configured as compensation service segment 610-3, compensation service 620-2 is configured as compensation service segment 610-2, and compensation service 620-3 is configured as compensation service segment 610-1. Compensation service segments 620-1, 620-2, and 620-3 are arranged in compensation service 565 in the reverse order of service segments 620-3, 620-2, and 620-1 in service 515. With this arrangement, compensation service segments 620-1, 620-2, and 620-3 can be invoked in the order they are arranged in compensation service 565.
[0103] In some embodiments, the entire compensation service 565 or one or more of the compensation service segments 620 can be input by a user, such as the user designing service 515. To facilitate user generation of compensation service 565 or one or more compensation service segments 620, in some embodiments, a compensation layout can be presented to the user, for example, by a coordinator 520. The compensation layout can indicate the structure of compensation service 565 and can specifically indicate the order of the sequence of compensation service segments 620. The order of the compensation segment sequence 620 can be the reverse of the order of the service segment sequence 610. With the compensation layout presented, the user conveniently inputs code segments to compensate the corresponding service segments in service service 515.
[0104] In some embodiments, the compensation layout can be as follows: Figure 6B The layout of service segment 610 in service 515 can be presented in a similar manner to that shown in compensation service 565. In some examples, the layout of service segment 610 in service 515 can be presented together with the compensation layout, as shown in the example. Figure 6B As shown in the image, the blank space for compensation service 630 can be displayed, and the user can enter code snippets into the corresponding blank spaces.
[0105] In some embodiments, the coordinator 520 may receive one or more of the compensation segment sequences 620 input by the user. For example, the user may input code segments for one or more compensation service segments 620 via a user terminal, and the input code segments may then be transmitted to the coordinator 520. Figure 7 An example of compensation service 565 obtained from a user is depicted, wherein code segments in each compensation service segment are entered and arranged in the order indicated in the presented compensation layout.
[0106] In some embodiments, automated code generation methods may be applied to generate compensation service 565 or one or more compensation services 620 within compensation service 565. Automated code generation of compensation service segment 620 may be based on service segment 610 to compensate for or roll back operations / actions performed by service segment 610.
[0107] Some embodiments of compensation service 565 for generating service 515 have been discussed above. Compensation service 576 for performing services 517 that modify the same global variables can be generated in a similar manner. Compensation services for performing other services that modify the values of one or more global variables can also be generated in a manner similar to that described with respect to service 515.
[0108] Figure 8 The correlation between service segments and compensation service segments according to some embodiments is depicted, wherein Table 800 indicates the correlation of service 515 "Service_D" and Table 810 indicates the correlation of service 517 "Service_E".
[0109] In Tables 800 and 810, the “Segment Name” column lists the compensated service segments in sequence, the “Global Variable” column indicates whether the compensated service segment includes rollback changes to the value of a global variable (in this example, global variable “x”), and the “Previous Segment” column lists the previous compensated service segment preceding the corresponding service segment. Table 800 also includes a “Compensation” column 610 indicating the service segment to be compensated.
[0110] For example, in Table 800, compensation service segment 620-1 "Service_D_C_P1" is configured to compensate service segment 610-3 "Service_D_P3" across lines 21 to 30 of service 515 "Service D", compensation service segment 620-2 "Service_D_C_P2" is configured to compensate service segment 610-2 "Service_D_P2" across lines 11 to 20, and compensation service segment 620-3 "Service_D_C_P3" is configured to compensate service segment 610-3 "Service_D_P1" across lines 1 to 10. Table 810 indicates similar compensation information for service segments of service 517 "Service_E" and its compensation service segment for service 567 "Service_E_C".
[0111] It should be understood that, in some embodiments, in addition to using Figure 6B In addition to, or as an alternative to, the compensation layout generated by similar representations shown in the table, Tables 800 and / or 810 may also be presented to the user to indicate the compensation layout of the compensation service segment.
[0112] For services 510 that are not executed to change the value of global variables, such as services 512, 514, or 516, the compensation service can be generated as a whole, without needing to generate a separate compensation service segment based on the location of the executable code segment to change the value of the global variable.
[0113] As described above, the compensation service of service 510 can be deployed to service execution environment 504 and can be executed based on trace information 542 captured during service execution according to rollback execution plan 522.
[0114] Figure 9 An example execution of the service of business 510 is depicted, during which tracing information 542 can be captured by tracing server 540. Along... Figure 9 The timeline depicts the execution time span of the services. As shown, service 512 starts at T0, and then services 514 and 516 are invoked in parallel by service 512 to execute at T1. The execution of services 514 and 516 can last for different durations. Figure 9 As shown, service 516 completes execution at T2. Service 514 completes execution at T3, which is later than the completion time of service 516. After service 514 completes at T3, it calls and executes service 515 to change the initial value of the global variable "x" at T4. After service 516 completes, it calls and executes service 517 to change the value of the global variable "x" at T5. Service 515 completes execution at T6. Service 517 completes execution at T7. After services 514, 516, 515, and 517 have all completed, service 512 completes.
[0115] depending on Figure 9 In the example, the execution of business 510 can be tracked by server 540 to obtain information such as... Figure 10 The trace information 542 shown indicates the timing of changes made by two or more services to one or more global variables during execution. Specifically, in Figure 10 In the example, the "Time" column indicates the corresponding point in time, the "Segment Name" column indicates the corresponding compensation service for the service (e.g., "Service_D" and "Service_E" in this example), the "Row" column indicates which line of code in compensation service segment 620 determines "global var.result", and the "global var" column indicates which global variable is included in the corresponding service. Furthermore, the "global var.result" column indicates whether the global variable "x" was changed by the corresponding service at the corresponding time, and the "Message" column indicates the message received during the service's execution, where the message "global_var_x_changed" indicates that the value of the corresponding global variable has changed.
[0116] In some embodiments, since the compensation service can be generated as a sequence of compensation service segments that include independent calls, the rollback execution plan 542 can be determined to specify the execution order of the compensation service segments. In particular, the execution order of the compensation service segments generated to undo changes made to global variables can be carefully specified according to the order indicated in the trace information 542.
[0117] Specifically, according to such Figure 10 The trace information 542 shown indicates that service 515 "Service_D" changed the value of the global variable "x" before service 517 "Service_E". Therefore, the correct rollback order of the global variable "x" is first changed by compensating service 567 "Service_E_C", and then by compensating service 565 "Service_D_C". In compensating services 567 and 565, as from... Figure 8 As can be seen from Tables 800 and 810, the compensation service segments “Service_E_C_P2” and “Service_D_C_P2” are generated to compensate for the two service segments 517 and 515 that are executed to change the value of the global variable “x”.
[0118] Based on the above information, when generating rollback execution plan 522 to indicate the correct rollback order for the global variable "x", the coordinator 520 can specify in rollback execution plan 522 that the compensation service segment "Service_E_C_P2" is called first, and the compensation service segment "Service_D_C_P2" is called after the compensation service segment "Service_E_C_P2" is executed to change the value of the global variable "x". In other words, the compensation service segment "Service_D_C_P2" is called after the completion of the execution of the compensation service segment "Service_E_C_P2".
[0119] By configuring the compensation segment, the entire compensation service 565 "Service_D_C" does not have to wait for the entire compensation service 567 "Service_E_C" to complete execution. For example, one or more compensation service segments can be executed before the compensation service segment "Service_D_C_P2" at an appropriate time. The invocation condition is applied to the compensation service segment "Service_D_C_P2".
[0120] In addition to specifying the execution order of the compensation service segments "Service_D_C_P2" and "Service_E_C_P2", the compensation service segments of the same compensation service can be executed in the arranged order. If the corresponding service of business 510 is called in parallel, the compensation service can be called in parallel. If the corresponding service of business 510 is called serially, the compensation service can be called serially in reverse order.
[0121] Figure 11 An example of rollback execution plan 522 for compensation services 562, 564, 565, 566, and 567 is depicted. In this example, the "Segment / Service Name" column lists the compensation service segment or service, and the "Previous Segment / Service" column indicates the invocation conditions of the compensation service segment or service in the same row. For example, for compensation service segments "Service_D_C_P1" and "Service_E_C_P1", no previous segment is indicated, and they can be invoked without requiring the invocation conditions to be met.
[0122] For the compensation service segment "Service_E_C_P2", its predecessor is designated as compensation service segment "Service_E_C_P1". This means that compensation service segment "Service_E_C_P2" is not invoked until compensation service segment "Service_E_C_P1" has fully executed. This is reasonable because compensation service segment "Service_E_C_P1" is located before compensation service segment "Service_E_C_P2" within compensation service "Service_E_C".
[0123] For the compensation service segment "Service_D_C_P2", its preceding compensation service segments are specified as including compensation service segments "Service_D_C_P1" and "Service_E_C_P2". Therefore, compensation service segment "Service_D_C_P2" is not invoked until compensation service segment "Service_D_C_P1" has fully executed, because this segment precedes compensation service segment "Service_D_C_P2" within compensation service "Service_D_C". Furthermore, compensation service segment "Service_D_C_P2" may still need to wait for compensation service segment "Service_E_C_P2" to fully execute, allowing the global variable "x" to be modified by compensation service segment "Service_E_C_P2" which precedes "Service_D_C_P2". Thus, the rollback order of the global variable "x" is correct.
[0124] Other compensation service segments and the conditions for invoking compensation services are also specifically indicated in rollback execution plan 522. Figure 12 Describing as Figure 11 The example rollback execution shown is of compensation services 562, 564, 565, 566, and 567 executed according to rollback execution plan 522. As shown, when the rollback of service 510 begins, compensation service segment 620-1 "Service_D_C_P1" and compensation service segment 1210-1 "Service_E_C_P1" are invoked to execute in Tm0.
[0125] The execution of compensation service segment 620-1 "Service_D_C_P1" is completed in Tm1. However, the following compensation service segment 620-2 "Service_D_C_P2" within the same compensation service 565 "Service_D_C" is not invoked in Tm0 because rollback execution plan 522 specifies that compensation service segment 620-1 "Service_D_C_P1" is invoked after compensation service segment 1210-2 "Service_E_C_P2" has been fully executed. The execution of compensation service segment 1210-1 "Service_E_C_P1" is completed in Tm2, and subsequently, compensation service segment 1210-2 "Service_E_C_P2" is invoked for execution. During the execution of compensation service segment 1210-2 "Service_E_C_P2", the value of the global variable "x" is modified to undo the changes applied by the execution of service 517 "Service_E" (in Figure 9 During the execution of business 510 (T5).
[0126] The execution of Compensation Service Segment 1210-2 "Service_E_C_P2" is completed in Tm3. At this time, according to Rollback Execution Plan 522, the invocation condition for Compensation Service Segment 620-2 "Service_D_C_P2" is met. Therefore, Compensation Service Segment 620-2 "Service_D_C_P2" is invoked to execute in Tm3. Compensation Service Segment 1210-3 "Service_E_C_P3" can also be invoked to execute in Tm3. During the execution of Compensation Service Segment 620-2 "Service_D_C_P2", the value of the global variable "x" is further modified to undo the changes applied by the execution of Service 515 "Service_D" (in Figure 9 During the execution of service segment 510 (T4), changes made to the value of the global variable "x" during the failed execution of service segment 510 are recursively applied to the global variable "x" during the rollback process, thereby ensuring that the global variable is rolled back to its initial state (value). The execution of compensation service segment 620-2 "Service_D_C_P2" is completed in Tm4.
[0127] Other compensation service segments and compensation services can also be invoked and executed according to rollback execution plan 522, and their invocation time and duration are within... Figure 12 As shown in the diagram. In Tm8, compensation service 562 "Service_A_C" is invoked because the concurrent compensation services 564 and 565 have both completed. In Tm9, compensation service 562 "Service_A_C" completes.
[0128] In the example above, the global variable is changed or updated once in one service of business 510. In some cases, the same global variable may be changed or updated more than once in one or more services of business 510. In this case, the compensation service segment and the rollback execution plan 522 can also be determined in a similar manner. To better understand the embodiment where the global variable is changed more than once, refer to... Figures 13A-13D The examples shown are illustrated. In those examples, it is assumed that the same global variable is detected to have been changed twice by service 515 during the execution of that service, and twice by service 517 during the execution of that service.
[0129] like Figure 13A As shown, the global inspector 530 can detect from the code of service 515 that the global variable "x" will be changed twice. Based on the location of the code segment defined as the one that will change the global variable "x", the coordinator 520 can divide service 515 into service segment sequences 1310-1, 1310-2, 1310-3, 1310-4, and 1310-5, respectively represented as "Service_D_P1", "Service_D_P2", "Service_D_P3", "Service_D_P4", and "Service_D_P5", as follows. Figure 13A As shown in the diagram. Service segments 1310-1, 1310-2, 1310-3, 1310-4, and 1310-5 may sometimes be collectively or individually referred to as service segment 1310. Within service segment 1310, service segment 1310-2 is configured to change the value of the global variable "x" for the first time, and service segment 1320 is configured to change the value of the global variable "x" a second time according to the configuration of service 515.
[0130] Therefore, compensation service 565 can be determined (automatically or by input from the user) as including the sequence of compensation service segments 1320-1, 1320-2, 1320-3, 1320-4, and 1320-5 (sometimes collectively or individually referred to as compensation service segment 1320), denoted as "Service_D_C_P1", "Service_D_C_P2", "Service_D_C_P3", "Service_D_C_P4", and "Service_D_C_P5", as follows. Figure 13AAs shown. The compensation service segment 1320 is arranged and invoked to the service segment 1310 in reverse order, wherein “Service_D_C_P1” compensates “Service_D_5”, “Service_D_C_P2” compensates “Service_D_4”, “Service_D_C_P3” compensates “Service_D_3”, “Service_D_C_P4” compensates “Service_D_2”, and “Service_D_C_P5” compensates “Service_D_1”.
[0131] Compensation service 567 "Service_E" can also be determined in a similar manner to include a sequence of compensation service segments. The compensation service segments of compensation service 517 can be represented as "Service_E_C_P1", "Service_E_C_P2", "Service_E_C_P3", "Service_E_C_P4", and "Service_E_C_P5", wherein "Service_E_C_P2" and "Service_E_C_P4" are configured to compensate for the service segments of service 517 that are executed to change the value of the global variable "x" twice.
[0132] Figure 13B The diagram depicts an example execution of service 510, showing the time span of service execution along a timeline. As shown, service 517 is invoked and executed at T2 to change the initial value of the global variable "x" for the first time within the service at T3. Service 515 is invoked and executed at T4 to change the initial value of the global variable "x" for the first time within the service at T5. Execution of service 515 continues to change the value of the global variable "x" for the second time within the service at T6. Execution of service 517 continues to change the value of the global variable "x" at T7 (T7 is later than T6). The execution of service 515 completes at T8, and the execution of service 517 completes at T9. The execution of service 515 completes at T9 after services 514, 516, 515, and 517 have all completed.
[0133] exist Figure 13B In the example, during execution, the value of the global variable "x" changes sequentially: by service 517 in T3, by service 515 in T5 and T6, and by service 517 in T7. The tracking server 540 can track the order in which the changes applied to the global variable "x" are performed and record them in trace information 542. Based on trace information 542, the coordinator 520 can generate a rollback execution plan 522 to, for example... Figure 13B In the event of execution failure, the rollback will be performed for business 510.
[0134] Figure 13C Described based on, for example Figure 13BThe example shown is a rollback execution plan 522 generated from trace information 542 tracked during execution. Figure 13C In the rollback execution plan 522 and others, the previous compensation service segment of the compensation service segment "Service_D_C_P2" is specified to include compensation service segments "Service_D_C_P1" and "Service_E_C_P2". Therefore, the compensation service segment "Service_D_C_P2" is invoked after the complete execution of both compensation service segments "Service_D_C_P1" and "Service_E_C_P2".
[0135] Furthermore, the compensation service segment "Service_D_C_P4" is specified to be called after the compensation service segment "Service_D_C_P3", and therefore also after the compensation service segment "Service_D_C_P2". For the compensation service segment "Service_E_C_P4", its preceding compensation service segment is specified to include both the compensation service segments "Service_E_C_P3" and "Service_D_C_P4". Therefore, the compensation service segment "Service_D_C_P4" is called completely after both the compensation service segments "Service_E_C_P3" and "Service_D_C_P4".
[0136] Figure 13D Depicting according to such Figure 13B The example rollback execution of compensation services 562, 564, 565, 566, and 567 shown in the rollback execution plan 522 is an example of rollback execution. As shown, compensation service segment 1330-2 "Service_E_C_P2" is invoked in Tm1 after the complete execution of compensation service segment 1330-1 "Service_E_C_P1". During the execution of "Service_E_C_P2", the value of the global variable "x" is changed to compensate for a second change made to that global variable during the execution of service 517 "Service_E".
[0137] After compensation service segment 1320-1 "Service_D_C_P1" and compensation service segment 1330-2 "Service_E_C_P2" have been fully executed, compensation service segment 1320-2 "Service_D_C_P2" is called in Tm2. During the execution of "Service_D_C_P2", the value of the global variable "x" is changed to compensate for the second change made to that global variable during the execution of service 515 "Service_D".
[0138] Compensation service segment 1320-4 "Service_D_C_P4" is invoked in Tm4 after compensation service segment 1320-3 "Service_D_C_P3" has completed execution. During the execution of "Service_D_C_P4", the value of the global variable "x" is changed to compensate for the first change made to that global variable during the execution of service segment 515 "Service_D".
[0139] After the full execution of compensation service segment 1330-3 "Service_E_C_P3" and compensation service segment 1320-4 "Service_D_C_P4", compensation service segment 1330-4 "Service_D_C_P4" is called in Tm5. During the execution of "Service_D_C_P4", the value of the global variable "x" is changed to compensate for the first change made to that global variable during the execution of service segment 517 "Service_E".
[0140] exist Figure 13D During the rollback execution in the example, the value of the global variable "x" is rolled back sequentially by the compensation service segments "Service_E_C_P2", "Service_D_C_P2", "Service_D_C_P4", and "Service_E_C_P4". Other compensation service segments and compensation services can also be called and executed according to rollback execution plan 522, with the number of calls and duration as follows: Figure 13D As shown.
[0141] In some cases, two or more global variables may be changed or updated once or multiple times in the service of business 510. The same or different services may be executed to change two or more global variables. In this case, the compensation service segment and rollback execution plan 522 can also be determined in a similar manner. For a better understanding of embodiments where global variables are changed more than once, refer to... Figures 14A-14D The examples shown are hypothetical. In these examples, it is assumed that two global variables "x" and "y" are detected to be changed by services 515 and 517. However, it is understandable that the same global variables "x" and "y" may also be detected to be changed by other different services.
[0142] like Figure 14AAs shown, the global inspector 530 can detect from the code of service 515 that two global variables "x" and "y" are to be changed in service 515. Based on the location of the code segment where the global variables "x" and "y" are to be changed, the coordinator 520 can divide service 515 into service segments 1410-1, 1410-2, 1410-3, 1410-4, and 1410-5, respectively denoted as "Service_D_P1", "Service_D_P2", "Service_D_P3", "Service_D_P4", and "Service_D_P5", as follows. Figure 14A As shown. These service segments 1410-1, 1410-2, 1410-3, 1410-4, and 1410-5 are sometimes collectively referred to as service segment 1410. Within service segment 1410, service segment 1410-2 is configured to change the value of the global variable "x", and service segment 1420 is configured to change the value of the global variable "y".
[0143] Accordingly, compensation service 565 can be determined (automatically or by user input) as including the sequence of compensation service segments 1420-1, 1420-2, 1420-3, 1420-4, and 1420-5 (sometimes collectively or individually referred to as compensation service segment 1420), denoted as "Service_D_C_P1", "Service_D_C_P2", "Service_D_C_P3", "Service_D_C_P4", and "Service_D_C_P5", as follows: Figure 14A As shown. The compensation service segment 1420 is arranged in reverse order to the service segment 1410, wherein “Service_D_C_P1” compensates “Service_D_5”, “Service_D_C_P2” compensates “Service_D_4”, “Service_D_C_P3” compensates “Service_D_3”, “Service_D_C_P4” compensates “Service_D_2”, and “Service_D_C_P5” compensates “Service_D_1”.
[0144] Compensation service 567 "Service_E" can also be determined in a similar manner to include a sequence of compensation service segments. The compensation service segments of compensation service 517 can be represented as "Service_E_C_P1", "Service_E_C_P2", "Service_E_C_P3", "Service_E_C_P4", and "Service_E_C_P5", where "Service_E_C_P2" and "Service_E_C_P4" are configured as service segments of compensation service 517, and these service segments are executed to change the values of global variable "x" and global variable "y", respectively.
[0145] Figure 14B An example of the execution of service 510 is described, with the execution time span depicted along a timeline. As shown, service 517 is called and executed at T2 to change the initial value of the global variable "x" for the first time. Service 515 is called and executed at T4 to change the initial value of the global variable "x" again at T5. Execution of service 515 continues, changing the value of the global variable "y" for the first time at T6. Execution of service 517 continues, changing the value of the global variable "y" for the second time at T7. The execution of service 515 completes at T8, and the execution of service 517 completes at T9. The execution of service 515 completes at T9 after services 514, 516, 515, and 517 have finished.
[0146] exist Figure 14B In the example, during execution, the value of the global variable "x" changes sequentially: by service 517 at T3, and by service 515 at T5; simultaneously, the value of the global variable "y" changes sequentially: by service 515 at T6, and by service 517 at T7. The tracking server 540 can track the order in which changes are applied to the global variable "x" and record it in trace information 542. Based on trace information 542, the coordinator 520 can generate a rollback execution plan 522. Figure 14B In the event of execution failure, rollback will be performed on business 510.
[0147] Figure 14C An example of a rollback execution plan 522 generated based on trace information 542 tracked during execution is depicted, such as... Figure 14B As shown. In Figure 14C In the rollback execution plan 522 and others, the previous compensation service segment of the compensation service segment "Service_D_C_P2" is specified to include compensation service segments "Service_D_C_P1" and "Service_E_C_P2". Therefore, the compensation service segment "Service_D_C_P2" is invoked after the execution of compensation service segments "Service_D_C_P1" and "Service_E_C_P2" is completed to ensure the correct rollback order of the global variable "y".
[0148] Furthermore, the compensation service segment "Service_D_C_P4" is specified to be called after the compensation service segment "Service_D_C_P3". For the compensation service segment "Service_E_C_P4", its preceding compensation service segments are specified to include both "Service_E_C_P3" and "Service_D_C_P4". Therefore, the compensation service segment "Service_E_C_P4" is called after the execution of the compensation service segments "Service_E_C_P3" and "Service_D_C_P4" is complete, to ensure the correct rollback order of the global variable "x".
[0149] Figure 14D Depicting according to Figure 14B The rollback execution plan 522 shown depicts the rollback execution of compensation services 562, 564, 565, 566, and 567. As shown, after the complete execution of compensation service segment 1430-1 "Service_E_C_P1", compensation service segment 1430-2 "Service_E_C_P2" is called in Tm1. During the execution of "Service_E_C_P2", the value of the global variable "y" is changed to compensate for a second change made to this global variable during the execution of service 517 "Service_E".
[0150] After the full execution of compensation service segment 1420-1 "Service_D_C_P1" and compensation service segment 1430-2 "Service_E_C_P2", compensation service segment 1420-2 "Service_D_C_P2" is called in Tm2. During the execution of "Service_D_C_P2", the value of the global variable "y" is changed to compensate for the first change made to this global variable during the execution of service 515 "Service_D".
[0151] After the full execution of Compensation Service Segment 1420-3 "Service_D_C_P3", Compensation Service Segment 1420-4 "Service_D_C_P4" is called in Tm4. During the execution of "Service_D_C_P4", the value of the global variable "x" is changed to compensate for the second change made to that global variable during the execution of Service 515 "Service_D".
[0152] After the full execution of compensation service segment 1430-3 "Service_E_C_P3" and compensation service segment 1420-4 "Service_D_C_P4", compensation service segment 1430-4 "Service_D_C_P4" is invoked in Tm5. During the execution of "Service_D_C_P4", the value of the global variable "x" is changed to compensate for the first change made to this global variable during the execution of service 517 "Service_E". In Tm6, after the full execution of compensation service segment 1430-5 "Service_E_C_P5", compensation service segment 1430-5 "Service_E_C_P5" is invoked.
[0153] exist Figure 14D During the rollback execution in the example, the value of the global variable "y" is rolled back sequentially by the compensation service segments "Service_E_C_P2" and "Service_D_C_P2", while the value of the global variable "x" is rolled back sequentially by the compensation service segments "Service_D_C_P4" and "Service_E_C_P4". Other compensation service segments and compensation services can also be called and executed according to the rollback execution plan 522, with the number of calls and duration as follows: Figure 14D As shown.
[0154] It should be understood that while the values of global variables changed in two services in the examples described and discussed above, in other examples, the same global variable may change in more than two services. Furthermore, in some examples, the same global variable may be updated more than twice within a single service, and more than two different global variables may be detected from the services of the business logic. In some alternative cases, a rollback execution plan can also be determined, and a compensating service can be generated to execute in a manner similar to that discussed above.
[0155] Figure 15 A flowchart of a method 1500 according to some embodiments of the present disclosure is shown. Method 1500 can be performed as follows: Figure 5 The business management system shown is implemented at location 502. For discussion purposes, method 1500 will refer to... Figure 5 To describe.
[0156] In box 1510, the service management system 502 detects that at least two of the multiple services in the business are executed to change the value of a first global variable. In box 1520, the service management system 502 obtains trace information indicating the first order in which the at least two services changed the value of the first global variable during the execution of the multiple services. In box 1530, in response to a business failure, the service management system 502 determines a rollback execution plan for multiple compensation services based at least on the trace information. The multiple compensation services are configured to compensate the multiple services separately. In box 1540, the business management system 502 causes the multiple compensation services to execute according to the rollback execution plan.
[0157] In some embodiments, determining the rollback execution plan includes: determining the rollback execution plan based at least on trace information to specify a second order in which at least two of a plurality of compensation services are executed to change the value of a first global variable, the second order being the reverse of the first order.
[0158] In some embodiments, the method further includes: for a first service among the at least two services, dividing the first service into a first service segment sequence, wherein a first service segment in the first service segment sequence is executed to change the value of the first global variable; and determining a first compensation service among a plurality of compensation services based on the first service segment sequence. In some embodiments, the first compensation service includes a first compensation service segment sequence that will be independently invoked to compensate the first service segment sequence separately.
[0159] In some embodiments, determining a first compensation service includes: displaying a layout of a first compensation service segment sequence to a user, the first compensation service segment sequence being the reverse of a first service segment sequence; and receiving input from the user for at least one of the first compensation service sequences.
[0160] In some embodiments, a first compensation service segment in a first compensation service segment sequence is determined to compensate for the first service segment. In some embodiments, determining a rollback execution plan includes: in response to trace information indicating that a first service changes the value of a first global variable before a second service among a plurality of services, generating a rollback execution plan to specify that the first compensation service segment of the first compensation service will be invoked after the compensation service segment of the second compensation service among a plurality of compensation services has been fully executed. In some embodiments, the compensation service segment of the second compensation service is determined to compensate for the service segment of the second service in which the value of the first global variable is changed.
[0161] In some embodiments, a first service segment first changes the value of a first global variable, wherein dividing the first service includes: identifying a second service segment from the first service, the second service segment executing after the first service segment to change the value of the first global variable a second time; and further dividing the first service into a sequence of first service segments based on the position of the second service segment, the sequence of first service segments including the second service segment. In some embodiments, a first compensation service is determined to further include a second compensation service segment to compensate the second service segment, the second compensation service segment being invoked before the first compensation service.
[0162] In some embodiments, determining the rollback execution plan includes: in response to trace information further indicating that a third service among a plurality of services changes the value of a first global variable before the first service, generating a rollback execution plan to further specify that a compensation service segment of the third compensation service among a plurality of compensation services will be invoked after the first and second compensation service segments of the first compensation service have been fully executed. In some embodiments, the compensation service segment of the third compensation service is determined to be a service segment that compensates for the change in the value of the first global variable in the third service.
[0163] In some embodiments, partitioning a first service includes: identifying a third service segment from the first service that is executed to change the value of the second global variable, based on a determination that at least one additional service among the first service and a plurality of services is executed to change the value of the second global variable; and further partitioning the first service into a sequence of first service segments, the sequence of first service segments including the third service segment, by one or more processors based on the position of the third service segment within the first service. In some embodiments, a first compensation service is determined to include a third compensation service segment to compensate for the third service segment.
[0164] In some embodiments, the tracking information further indicates a third order in which the first service and at least one other service change the value of the second global variable. In some embodiments, determining the rollback execution plan includes: in response to the third order indicating that the first service changes the value of the second global variable before a fourth service of at least one other service, generating a rollback execution plan to further specify that a third compensation service segment of the first compensation service will be invoked after the full execution of the compensation service segment of the fourth compensation service among a plurality of compensation services. In some embodiments, the compensation service segment of the fourth compensation service is determined to be the service segment of the fourth service in which the value of the second global variable is changed.
[0165] It should be noted that the rollback processing of services or service management systems 502 with global variable changes according to embodiments of the present invention can be performed by... Figure 1 The computer system / server 12 is implemented.
[0166] This invention can be applied to systems, methods, and / or computer program products at any level of technical detail integration. The computer program product may include a computer-readable storage medium (or medium) having computer-readable program instructions thereon for causing a processor to execute aspects of this disclosure.
[0167] Computer-readable storage media can be tangible devices that can retain and store instructions for use by an instruction execution device. Computer-readable storage media can be, for example, but not limited to, electronic storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of computer-readable storage media includes the following: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable optical disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punched cards or raised structures in recesses on which instructions are recorded, and any suitable combination of the foregoing. As used herein, computer-readable storage media should not be construed as being a transient signal, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.
[0168] The computer-readable program instructions described in this disclosure can be downloaded from a computer-readable storage medium to a suitable computing / processing device via a network, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network (LAN), a wide area network (WAN), and / or a wireless network. The network may include copper transmission cables, optical fiber transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to a computer-readable storage medium within the suitable computing / processing device.
[0169] Computer-readable program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set-architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, integrated circuit configuration data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk, C++, or similar programming languages such as the "C" programming language or similar programming languages. The computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as a standalone software package, partially on a user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or wide area network (WAN), or may be connected to an external computer (e.g., via the Internet provided by an Internet service provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs) may execute computer-readable program instructions by personalizing the electronic circuitry with state information from the computer-readable program instructions in order to perform aspects of this disclosure.
[0170] This document describes aspects of the invention with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.
[0171] These computer-readable program instructions can be provided to a processor of a computer or other programmable data processing apparatus to produce a machine, such that the instructions, which execute through the processor of the computer or other programmable data processing apparatus, can create means for implementing the functions / actions specified in the flowchart and / or block diagram blocks. These computer-readable program instructions can also be stored in a computer-readable storage medium that can instruct a computer, programmable data processing apparatus, and / or other equipment to operate in a particular manner, such that the computer-readable storage medium in which the instructions are stored includes an article of manufacture comprising instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.
[0172] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus or other apparatus to cause a series of operational steps to be performed on the computer, other programmable apparatus or other apparatus, thereby producing a computer-implemented process, such that the instructions, which are executed on the computer, other programmable apparatus or other apparatus, perform the functions / actions specified in one or more blocks of a flowchart and / or block diagram.
[0173] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of instructions, including one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the figures. For example, two blocks shown consecutively may actually be completed as a single step, executed simultaneously or substantially simultaneously with partial or complete time overlap, or these blocks may sometimes be executed in reverse order, depending on the functions involved. It will also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a system based on dedicated hardware that performs the specified function or action or executes a combination of dedicated hardware and computer instructions.
[0174] Various embodiments of the invention have been described for illustrative purposes, but are not intended to be exhaustive or limiting. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles of the embodiments, their practical application, or technical improvements to technologies found in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A computer-implemented method, comprising: One or more processors detect that at least two of the multiple services in the service are executed to change the value of a first global variable. The trace information is obtained by the one or more processors, the trace information indicating a first order in which the at least two services change the value of the first global variable during the execution of the plurality of services; In response to the failure of the service, the one or more processors determine a rollback execution plan for multiple compensation services based at least in part on the trace information, the multiple compensation services being configured to compensate the multiple services respectively; The one or more processors cause the plurality of compensation services to execute according to the rollback execution plan. For the first of the at least two services: The first service is divided into a first service segment sequence by the one or more processors, and the first service segment in the first service segment sequence is executed to change the value of the first global variable; as well as The one or more processors determine the first compensation service among the plurality of compensation services based on the first service segment sequence. The first compensation service includes a first compensation service segment sequence, which will be invoked independently to compensate the first service segment sequence separately.
2. The method of claim 1, wherein determining the rollback execution plan comprises: The rollback execution plan is determined by the one or more processors based at least in part on the trace information to specify a second order in which at least two of the plurality of compensation services are executed to change the value of the first global variable, the second order being the reverse of the first order.
3. The method as described in claim 1, wherein, The first compensation service is determined to include: The layout of the first compensated service segment sequence is presented to the user by the one or more processors, wherein the first compensated service segment sequence is in the reverse order of the first service segment sequence; and The one or more processors receive input from the user for at least one of the first compensation service segment sequences.
4. The method of claim 1, wherein a first compensation service segment in the first compensation service segment sequence is determined to compensate the first service segment, and wherein determining the rollback execution plan includes: In response to the tracking information instructing the first service to change the value of the first global variable before the second service among the plurality of services, The rollback execution plan is generated by the one or more processors to specify that the first compensation service segment of the first compensation service will be invoked after the full execution of the compensation service segment of the second compensation service among the plurality of compensation services. The compensation service segment of the second compensation service is determined to compensate the service segment of the second service in which the value of the first global variable is changed.
5. The method of claim 1, wherein the first service segment changes the value of the first global variable for the first time, and wherein dividing the first service includes: The one or more processors identify a second service segment from the first service, and the second service segment is executed to change the value of the first global variable for the second time after the first service segment; as well as The one or more processors further divide the first service into a sequence of first service segments based on the location of the second service segment, the sequence of first service segments including the second service segment, and The first compensation service is determined to further include a second compensation service segment to compensate for the second service segment, the second compensation service segment being invoked before the first compensation service segment.
6. The method of claim 5, wherein determining the rollback execution plan comprises: In response to the tracking information further instructing a third service among the plurality of services to change the value of the first global variable before the first service, The rollback execution plan is generated by the one or more processors to further specify that the compensation service segment of the third compensation service among the plurality of compensation services will be invoked after the first compensation service segment and the second compensation service segment of the first compensation service have been fully executed. The compensation service segment of the third compensation service is defined as the service segment of the third service that compensates for the change in the value of the first global variable.
7. The method of claim 1, wherein dividing the first service comprises: Based on the determination that at least one of the first services and multiple services is executed to change the value of the second global variable, the one or more processors identify from the first service a third service segment that is executed to change the value of the second global variable; as well as The one or more processors further divide the first service into a first service segment sequence based on the position of the third service segment within the first service, the first service segment sequence including the third service segment, and The first compensation service is defined as including a third compensation service segment to compensate the third service segment.
8. The method of claim 7, wherein the tracing information further indicates a third order in which the first service and the at least one other service change the value of the second global variable, and wherein determining the rollback execution plan comprises: In response to the third sequential instruction, the first service changes the value of the second global variable before the fourth service of the at least one other service. The rollback execution plan is generated by the one or more processors to further specify that the third compensation service segment of the first compensation service is invoked after the full execution of the compensation service segment of the fourth compensation service among the plurality of compensation services. The compensation service segment of the fourth compensation service is determined to compensate for the service segment of the fourth service in which the value of the second global variable is changed.
9. A system comprising: Processing unit; as well as A memory coupled to the processing unit and storing instructions thereon, which, when executed by the processing unit, perform the operation of the method according to any one of claims 1 to 8.
10. A computer program product having program instructions contained therein, the program instructions being executable by an electronic device to cause the electronic device to perform the operation of the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Business processing method, device and equipment
CN112766829A
