A mutual exclusion verification method, system and related equipment for multi-user operation of a database

Through distributed locks and mutual exclusion verification components, the data inconsistency problem caused by concurrent operations of multiple users in the database cluster is solved, efficient management and control of the database cluster is achieved, the consistency and integrity of the data are ensured, and the flexibility of the system and user experience are improved.

CN120407588BActive Publication Date: 2025-09-16TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510920544.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-04
Publication Date
2025-09-16
Estimated Expiration
2045-07-04

AI Technical Summary

Technical Problem

In the operation and maintenance of a database cluster, multi-user concurrent operations may lead to data inconsistency, especially in the absence of an effective concurrency control mechanism, which affects the use of the operation and maintenance system and the availability and data accuracy of the database cluster.

Method used

Distributed lock and mutual exclusion verification components are used to obtain the distributed lock status, and the aspect components are used to intercept or verify user operations to ensure the mutual exclusivity of user operations. The lock status is saved using the database persistence component, and flexible verification logic is implemented through the strategy pattern to reduce system coupling and improve scalability and maintainability.

Benefits of technology

It ensures the consistency and integrity of the database cluster under multi-user operation and maintenance operations, realizes the effective management and control of operation and maintenance operations, reduces data inconsistency and resource waste, and improves the flexibility of the system and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120407588B_ABST
    Figure CN120407588B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a mutual exclusion verification method, system and related equipment for multi-user operations in a database. The method includes: in response to a user operation, obtaining a distributed lock state; in response to the distributed lock state being a locked state, intercepting the user operation using a section component; or, in response to the distributed lock state being a released state, modifying the distributed lock state to a locked state, and verifying the user operation; in response to the user operation and the target user operation being verified to be non-mutually exclusive, allowing the user operation; or, in response to the user operation and the target user operation being verified to be mutually exclusive, intercepting the user operation using a section component. The method provided by the embodiment of the present disclosure can ensure the consistency and integrity of the database cluster under multi-user operation and maintenance operations and different operation and maintenance operations of the same user through distributed locks and mutual exclusion verification components, thereby achieving effective management and control of operation and maintenance operations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of computer systems, and in particular to a mutual exclusion verification method, system, and related equipment for multi-user database operations. Background Art

[0002] With the rapid development of information technology, many enterprises and organizations are adopting database clusters for data storage and management. Furthermore, visual operations and maintenance systems are widely used for cluster management and maintenance operations. However, when performing operations and maintenance on database clusters, such as expansion, contraction, and upgrades, multiple users may be involved in performing operations on the same cluster simultaneously, or the same user may be performing different types of operations simultaneously. These concurrent operations can lead to data inconsistencies, especially without effective concurrency control mechanisms. This can hinder the use of the operations and maintenance system and even seriously affect the availability of the database cluster and data accuracy. Summary of the Invention

[0003] In order to solve the above technical problems, the present disclosure provides a mutual exclusion verification method, system and related equipment for multi-user operations on a database.

[0004] The present disclosure provides a mutual exclusion verification method for multi-user operations in a database, comprising: in response to a user operation, obtaining a distributed lock state; in response to the distributed lock state being in a locked state, intercepting the user operation using a section component; or, in response to the distributed lock state being in a released state, modifying the distributed lock state to a locked state and verifying the user operation; in response to the user operation and a target user operation being verified as not mutually exclusive, allowing the user operation and modifying the distributed lock state to a released state; or, in response to the user operation and a target user operation being verified as mutually exclusive, intercepting the user operation using a section component and modifying the distributed lock state to a released state.

[0005] Optionally, verifying the user operation includes: verifying the user name and operation type of the user operation; in response to the verification that the user operation and the target user operation are not mutually exclusive, including: in response to the user name of the user operation being consistent with the target user name, and the operation type of the user operation being consistent with the target operation type, determining that the user operation and the target user operation are not mutually exclusive; or, in response to the absence of the target user operation, determining that the user operation and the target user operation are not mutually exclusive; in response to the verification that the user operation and the target user operation are mutually exclusive, including: in response to the user name of the user operation being inconsistent with the target user name, and / or the operation type of the user operation being inconsistent with the target operation type, determining that the user operation and the target user operation are mutually exclusive.

[0006] Optionally, the above method further includes: using a database persistence component to save the distributed lock state and user operations.

[0007] Optionally, before verifying the operation type of the user operation, it also includes: encapsulating multiple different operation types through enumeration, and defining multiple different strategy interfaces, wherein different strategy interfaces correspond to different verification logic; managing the strategy interface through a container, and storing the correspondence between the enumeration of operation types and the verification logic through the container; creating a context object of the strategy interface; verifying the operation type of the user operation, including: calling the target verification logic in the container through the context object according to the operation type of the user operation, and using the target verification logic to verify the operation type of the user operation.

[0008] Optionally, before obtaining the distributed lock state in response to a user operation, the method further includes: creating a custom annotation for the target operation object and the user operation; and creating an around notification, wherein the aspect component executes the around notification in response to the custom annotation.

[0009] Optionally, the surround notification includes pre-call processing and post-call processing, wherein: the pre-call processing is used to change the distributed lock state to a locked state and verify user operations, and the post-call processing is used to change the distributed lock state to a released state.

[0010] Optionally, after intercepting the user operation by using the aspect component, the method further includes: displaying interception information to the user.

[0011] Based on the same inventive concept, the present disclosure also provides a mutual exclusion verification system for multi-user operations in a database, including: a distributed lock component; a section component for obtaining a distributed lock state in response to a user operation; intercepting the user operation in response to the distributed lock state being a locked state; or, in response to the distributed lock state being a released state, modifying the distributed lock state to a locked state; in response to the verification that the user operation and the target user operation are not mutually exclusive, allowing the user operation and modifying the distributed lock state to a released state; or, in response to the verification that the user operation and the target user operation are mutually exclusive, intercepting the user operation and modifying the distributed lock state to a released state; a mutual exclusion verification component for verifying the user operation in response to the distributed lock state being a released state.

[0012] Based on the same inventive concept, the present disclosure also provides an electronic device, comprising: a processor; a memory for storing executable instructions; wherein the processor is used to read the executable instructions from the memory and execute the executable instructions to implement any one of the methods.

[0013] Based on the same inventive concept, the present disclosure also provides a computer-readable storage medium on which a computer program is stored. The storage medium stores the computer program, and when the computer program is executed by a processor, the processor implements any one of the methods.

[0014] Compared with the existing technology, the technical solution provided by the present disclosure has the following advantages: the method provided by the embodiment of the present disclosure can ensure the consistency and integrity of the database cluster under multi-user operation and maintenance operations and different operation and maintenance operations of the same user through distributed locks and mutual exclusion verification components, thereby realizing effective management and control of operation and maintenance operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0016] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0017] Figure 1 A flowchart of a mutual exclusion verification method for multi-user operations on a database provided by an embodiment of the present disclosure;

[0018] Figure 2 A schematic diagram of the architecture of a mutually exclusive verification system for multi-user database operations provided by an embodiment of the present disclosure;

[0019] Figure 3 A flowchart of another method for mutual exclusion verification of multi-user operations on a database provided by an embodiment of the present disclosure;

[0020] Figure 4 A schematic diagram of the architecture of another mutually exclusive verification system for multi-user database operations provided by an embodiment of the present disclosure;

[0021] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0022] In order to more clearly understand the above-mentioned purposes, features and advantages of the embodiments of the present disclosure, the scheme of the embodiments of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features therein can be combined with each other in the absence of conflict.

[0023] In the following description, many specific details are set forth to facilitate a full understanding of the embodiments of the present disclosure, but the embodiments of the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, not all of the embodiments.

[0024] In related technologies, for concurrent operation and maintenance operations by multiple users, mutual exclusion is achieved at the method level through locking (such as synchronized). This approach has some disadvantages, such as high performance overhead, limited scalability, and insufficient flexibility. Related technologies lack an effective mutual exclusion mechanism, which leads to conflicts between operation and maintenance operations and waste of resources.

[0025] In view of this, an embodiment of the present disclosure provides a mutual exclusion verification method for multi-user operations in a database, such as Figure 1 As shown, including:

[0026] S1. Responding to a user operation, obtaining the distributed lock status. The user operation here can be an operation and maintenance operation performed by the user on the database cluster.

[0027] In response to the distributed lock state being the locked state, execute S2 and use the aspect component to intercept the user operation; or, in response to the distributed lock state being the released state, execute S3 and modify the distributed lock state to the locked state and verify the user operation.

[0028] In response to the verification that the user operation and the target user operation are not mutually exclusive, execute S4, allow the user operation, and change the distributed lock state to the released state; or, in response to the verification that the user operation and the target user operation are mutually exclusive, execute S5, use the aspect component to intercept the user operation, and change the distributed lock state to the released state.

[0029] The method provided by the embodiment of the present disclosure can ensure the consistency and integrity of the database cluster under multi-user operation and maintenance operations and different operation and maintenance operations of the same user through distributed locks and mutual exclusion verification components, thereby achieving effective management and control of operation and maintenance operations.

[0030] Specifically, the aforementioned verification of user operations is performed by the mutually exclusive verification component, which provides flexible business expansion capabilities throughout the entire system. The mutually exclusive verification component implements the mutually exclusive verification functionality using the strategy pattern. The strategy pattern is a behavioral design pattern that defines a series of algorithms (strategies) and encapsulates each algorithm so that they can be used interchangeably. The strategy pattern allows algorithm changes to be independent of the clients using the algorithms. This approach makes the expansion of verification logic very flexible. When adding new mutually exclusive verification rules, simply add a new strategy class without modifying the existing verification code. This complies with the open-closed principle and improves the scalability and maintainability of the code.

[0031] Furthermore, the horizontal interception of user operations through aspect components makes the methods provided by the embodiments of this disclosure non-invasive, eliminating the need to modify existing business logic code and reducing system coupling. The aspect component (AOP) is non-invasive primarily because it can dynamically insert additional functionality (i.e., the aforementioned mutual exclusion check functionality) into the business logic without modifying the existing business logic code. First, the aspect component separates additional functionality from the core business logic through separation of concerns. In one embodiment of this disclosure, the aforementioned mutual exclusion check functionality is defined as an independent aspect, and the main business logic code does not need to be aware of the existence of the mutual exclusion check functionality, thus maintaining code clarity and maintainability. Second, the aspect component automatically inserts the aspect logic into designated connection points at runtime through dynamic weaving, eliminating the need for the main business logic code to explicitly call these functions, further reducing code coupling. Finally, the non-invasive nature of the aspect component is also reflected in its flexible extensibility. When new functionality is needed, a new aspect can be defined without modifying the main business logic code.

[0032] Specifically, the distributed lock component is a technology for controlling access to shared resources in a distributed system, ensuring that only one client can access a specific resource or execute a specific code block at any given moment. The method provided by the embodiment of the present disclosure utilizes a distributed lock component for preliminary verification, first ensuring the mutual exclusivity of operations by different users, and avoiding data inconsistency problems caused by simultaneous operations of multiple users. In specific implementation, the distributed lock component is implemented using Redis, and its atomic operation characteristics are used to ensure the validity of the distributed lock. In specific implementation, a unique identifier can be generated by combining the mutually exclusive prefix "MUTEX" to splice the cluster ID, and the Lua script can be used to execute SETNX and EXPIRE commands to achieve locking and releasing of the lock. In a specific embodiment, when the distributed lock state is in a locked state, no user operation is always received, and the distributed lock changes to a released state after a preset time, and the released state can be one hour.

[0033] Although the distributed lock component and the mutual exclusion verification component are similar in some functions, for example, the aspect component intercepts user operations based on the feedback of these two components, the distributed lock component and the mutual exclusion verification component are used to perform different functions in the embodiments of the present disclosure. Specifically, the distributed lock component is used for preliminary verification to ensure that only one user is operating the database cluster at this time, avoiding data inconsistency caused by another user operating at the same time when a mutual exclusion verification is performed on a certain user's operation. The mutual exclusion verification component is used for further verification to avoid data loss caused by the same user performing other operations on the database cluster when a certain operation is not completed.

[0034] In some embodiments, the verification of the user operation in S3 includes:

[0035] Verify the user name and operation type of the user operation.

[0036] In the above method, responding to the user operation and verifying that the target user operation is not mutually exclusive include:

[0037] In response to the user name of the user operation being consistent with the target user name, and the operation type of the user operation being consistent with the target operation type, it is determined that the user operation and the target user operation are not mutually exclusive; or, in response to the absence of the target user operation, it is determined that the user operation and the target user operation are not mutually exclusive.

[0038] In the above method, in response to the user operation and the target user operation verifying mutual exclusion, the method includes:

[0039] In response to the user name of the user operation being inconsistent with the target user name, and / or the operation type of the user operation being inconsistent with the target operation type, it is determined that the user operation and the target user operation are mutually exclusive.

[0040] In a specific embodiment (hereinafter referred to as Example 1), users A and B, listed on the operation and maintenance platform's cluster list, simultaneously (user B slightly 100 milliseconds later) initiate a user configuration operation for cluster 1 to expand the capacity of the cluster. When user A begins the operation, the distributed lock is in the released state. The next step involves verifying the user operation and changing the distributed lock state to the locked state. However, when user B begins the operation, the distributed lock has already been locked due to user A's operation, and user B's operation is blocked.

[0041] Returning to user A, if all previous configuration operations for cluster 1 have been completed and no other users are currently performing configuration operations on cluster 1 when user A begins the configuration operation, then this falls under the aforementioned situation where no target user operation exists. User A's user operation and the target user operation verification are not mutually exclusive, and user A can begin the configuration operation on cluster 1. At this point, the distributed lock operation is also completed, and the distributed lock state is changed to released.

[0042] After that, when user A is configuring cluster 1, user C also attempts to configure cluster 1. Since the distributed lock is in the released state, user C passes the initial verification of the distributed lock component and enters the mutual exclusion verification. At this point, the user name and operation type of the target user operation are user A and cluster expansion. Since user C's user name is mutually exclusive with user A, user C fails the mutual exclusion verification and the operation is intercepted.

[0043] While configuring cluster 1, user A saved a portion of the configuration and then logged out, executing the cluster upgrade configuration again from the cluster list. However, because user A's operation type at this time was mutually exclusive with the target user's cluster expansion operation, user A failed the mutual exclusion check and was intercepted. After being intercepted, user A attempted to configure cluster 1 again from the cluster list. This time, user A's user name matched the target user name, and user A's operation type matched the target operation type. User A passed the mutual exclusion check and was allowed to continue the unfinished expansion configuration.

[0044] In some embodiments, the above method further comprises:

[0045] Use database persistence components to save distributed lock status and user operations.

[0046] Specifically, the database persistence component uses the Mybatis persistence framework, utilizing a well-designed database table structure to store key information such as the cluster's operating user name and operation type. The mutual exclusion verification logic component relies on this component to query the distributed lock status and target user operations. Once a user's cluster operation passes mutual exclusion verification and begins, the operation system modifies the record, writing the current user's name and operation type as the target user's name and operation type. Once the operation is complete, the target user's operation information is cleared.

[0047] In some embodiments, before verifying the operation type of the user operation in S3, the process further includes:

[0048] Enumerate multiple different operation types and define multiple different strategy interfaces. Each strategy interface corresponds to different validation logic. Manage the strategy interfaces through a container, which also stores the correspondence between the operation type enumeration and the validation logic. Create a context object for the strategy interface.

[0049] In some embodiments, the operation type of the user operation verified in S3 above includes:

[0050] According to the operation type of the user operation, the target verification logic in the container is called through the context object, and the operation type of the user operation is verified using the target verification logic.

[0051] By enumerating operation types, we can clearly define the scope and meaning of each operation. Furthermore, by defining independent strategy interfaces for each operation type, each validation logic has a clear responsibility. This division of responsibilities makes the code more modular, with each module focusing on its specific logic, thereby improving code readability and maintainability. When adding new operation types or validation logic, simply add a new enumeration value and the corresponding strategy interface implementation class without modifying existing code, enabling flexible expansion.

[0052] This design also decouples the operation type from the validation logic, allowing them to vary independently. The corresponding validation logic can be dynamically selected at runtime based on the enumeration value, further enhancing the system's flexibility. Furthermore, the independently encapsulated validation logic facilitates unit testing, helping to improve the overall quality of the system. Therefore, this design approach effectively responds to changing requirements, improves code maintainability and testability, and offers significant flexibility and scalability.

[0053] This technology, which manages policy interfaces through containers and dynamically invokes target validation logic using context objects, offers high flexibility and scalability. Centralized container management makes policy registration and lookup more efficient, while the intermediary role of the context object further decouples client code from policy implementation, enabling the system to dynamically adapt to different operation types. This design adheres to the open-closed principle, facilitating expansion and maintenance. It also supports independent unit testing, effectively improving the overall quality and adaptability of the system.

[0054] In specific implementation, the above method can be executed in the following ways: classify the operation and maintenance operation types and enumerate them using the Operate Type Enum enumeration; define the strategy interface Operation Check Strategy, implement this interface for each verification logic, and hand it over to the IOC container for management; bind and store the strategy implementation class in the IOC container with the enumeration correspondence of the operation type, for example, inject the strategy class through the Spring framework dependency, and store the strategy implementation class in the Map container, where the Map key is the operation type enumeration Operate Type Enum; create a strategy context object and provide an external access method getStrategy (Operation Type operation Type). This method can extract the corresponding strategy implementation class from the binding relationship according to the operation type, thereby calling the corresponding verification method.

[0055] In some embodiments, before the above S1, the method provided by the embodiment of the present disclosure further includes:

[0056] Create custom annotations for the target operation object and the user operation; create an around advice, wherein the aspect component executes the around advice in response to the custom annotation.

[0057] In specific implementation, not all operations on the database cluster need to be verified and intercepted using the method provided by the embodiment of the present disclosure, and not all clusters need verification and interception. Therefore, the method provided by the above embodiment creates custom annotations for user operations and clusters (i.e., the above target operation objects) that need to be verified and intercepted, and creates surround notifications before and after the user operations. Then, the aspect component calls the distributed lock and mutual exclusion verification component based on the custom annotation to verify and intercept the specified user operations.

[0058] Specifically, the above database persistence component is also used to store the above custom annotations.

[0059] In some embodiments, the above-mentioned surround notification includes pre-call processing and post-call processing, wherein: the pre-call processing is used to modify the distributed lock state to a locked state and verify user operations, and the post-call processing is used to modify the distributed lock state to a released state.

[0060] In specific implementation, the above method can be executed in the following way: create a custom annotation @Mutex, internally declare the parameters to take over the operation object (cluster ID) and operation type in the request, and the custom annotation is used to mark the method that needs mutual exclusion verification in the control layer; create a section, first define the section, then declare the entry point in the section, and use the custom annotation as the entry point expression; finally, declare the surround notification, which consists of three parts: pre-call processing, target user operation, and post-call processing. Among them, the pre-call processing is responsible for scheduling the distributed lock component, mutual exclusion verification component and database persistence component, and the post-call processing is used to perform the finishing work after the request, such as changing the distributed lock state to the released state.

[0061] In actual application of the above method, when user A sends an HTTP request through the browser, the server receives and processes the request, and the backend framework forwards the request to the corresponding method in the control layer. If the method is marked with a custom annotation, the surround notification in the aspect component will be executed.

[0062] The process in the surround notification is as follows: get the operation object (cluster ID) from the custom annotation, splice the prefix "MUTEX:", and try to change the distributed lock state to the locked state; if the cluster lock already exists in the cache of the database persistence component (the distributed lock state is locked), the lock fails, the user prompt information processing component is called, and the corresponding lock failure prompt information is returned to the front end, and the process ends; if the cluster lock does not exist in the cache of the database persistence component (the distributed lock state is released), the lock is successful, and the mutual exclusion verification component is called for mutual exclusion verification; after the verification passes, the operation and maintenance operations in the control layer are executed, and the database persistence component is called to update the cluster occupancy status. If the verification fails, the user prompt information processing component is called and the current operation occupancy status of the front-end cluster is returned; finally, the distributed lock state is changed to the released state.

[0063] In some embodiments, after intercepting the user operation using the aspect component, it also includes: displaying the interception information to the user.

[0064] Specifically, the above method of displaying interception information to users is executed by the user prompt information processing component, which is responsible for generating prompt information for display to users. If the user mutual exclusion check fails, the user can see a toast message about the ongoing operation and maintenance of the cluster. This accurately informs the user of the cluster's operation and maintenance status through the interface, improving the user experience and further reducing the occurrence of operation conflicts and errors.

[0065] In specific implementation, the above method can be implemented by enumerating the operation types configured by the control layer, obtaining the description information of the operation type occupying the operation object, and assembling the text template to generate the prompt information.

[0066] In specific implementation, for Example 1 above, users A and B, listed on the operation and maintenance platform's cluster list, simultaneously (user B slightly 100 milliseconds later) initiate user configuration operations for cluster 1 to expand the capacity of the cluster. When user A begins the operation, the distributed lock is in the released state. The next step is to verify the user operation and change the distributed lock state to the locked state. When user B begins the operation, the distributed lock has already been locked due to user A's operation. At this point, user B's operation is blocked, and user B receives a prompt message: "The cluster is occupied. Please try again later."

[0067] Returning to user A, if all previous configuration operations for cluster 1 have been completed and no other users are currently performing configuration operations on cluster 1 when user A begins the configuration operation, then this falls under the aforementioned situation where no target user operation exists. User A's user operation and the target user operation verification are not mutually exclusive, and user A can begin the configuration operation on cluster 1. At this point, the distributed lock operation is also completed, and the distributed lock state is changed to released.

[0068] After that, when user A is configuring cluster 1, user C also wants to configure cluster 1. At this time, because the distributed lock is in the released state, user C passes the preliminary verification of the distributed lock component and enters the mutual exclusion verification. At this time, the user name and operation type of the target user operation are user A and cluster expansion. Because user C's user name is mutually exclusive with user A, user C cannot pass the mutual exclusion verification, and user C's operation is intercepted. User C receives a prompt message: "There is an incomplete cluster expansion configuration for this cluster. Please wait until it is completed before trying again."

[0069] While configuring cluster 1, user A saved a portion of the configuration and then exited. After retrying the cluster upgrade, user A attempted to upgrade cluster 1 again from the cluster list. However, because the type of operation performed by user A at this time was mutually exclusive with the target user's cluster expansion, user A failed the mutual exclusion check and was blocked. User A received the message, "An incomplete cluster expansion has been configured for this cluster. Please wait until it completes before attempting again." After being blocked, user A attempted to expand cluster 1 again from the cluster list. This time, user A's user name matched the target user name, and their operation type matched the target operation type. User A passed the mutual exclusion check and was allowed to continue the unfinished expansion. At this point, user D entered the mutual exclusion check and received the message, "An incomplete cluster expansion has been configured for this cluster. The current operation cannot be performed. Please visit the Task Management Center for details."

[0070] Figure 2 The dependency relationship among the above-mentioned distributed lock component 10, database persistence component 40, mutual exclusion verification component 30, user prompt information processing component 50 and aspect component 20 is shown, wherein the aspect component 20 depends on the other four components and implements the mutual exclusion verification function of operation and maintenance operations by calling the interfaces or methods provided by the other four components; the mutual exclusion verification component 30 depends on the database persistence component 40 to obtain data support; the user prompt information processing component 50 generates corresponding prompt information based on the results of the mutual exclusion verification component 30 and displays it to the user.

[0071] In a specific embodiment, Figure 3As shown in the figure, after a user initiates an operation and maintenance request, the user first enters the surrounding notification process of the aspect component. In the surrounding notification, an attempt is made to obtain the distributed lock status. If the lock acquisition fails (the distributed lock status is locked), a prompt message is directly returned to the user. If the lock acquisition succeeds (the distributed lock status is released), the mutual exclusion verification component is called for verification. The mutual exclusion verification component selects the appropriate verification strategy from the policy library of the policy mode based on the different operation types. If the verification fails, the user prompt information processing component is called to display the current cluster occupancy status to the user. If the verification passes and the current database cluster is not occupied or the operation is allowed to continue, the user operation is executed, the cluster occupancy status in the database is updated, and the distributed lock is finally released.

[0072] The present disclosure also provides another specific embodiment, the main process of which includes: defining an enumeration of operation types, Operate Type Enum, including enumeration code and description information; defining an annotation @Mutex, including operation type, operation object and cluster configuration ID, which is used to mark the operation and maintenance operation methods that require mutual exclusion verification in the control layer, for example: @interface Mutex { String cluster Id(); Operate Type Enum type(); Stringconfig Id();}; adding annotations to the interface method of the control layer, and configuring the operation object and current operation type. For example: @Mutex(type=Operate Type Enum. CONFIG_EXPAND, config Id="config Id")public void enter Check(String cluster Id, String config Id); define the Mutex Aspect, intercept the control layer method configured with the custom annotation, and use the surround notification method. In the surround notification, first try to lock the distributed lock. If the lock fails, a user prompt is returned (the generate User Tip method is called). If the lock is successful, subsequent processing is carried out. The current operation type is obtained from the operation enumeration type configured in the control layer. The corresponding mutual exclusion check strategy class Operation Check Strategy is executed according to the operation type, and the check method checking(String cluster Id, String operate Code) is called. If the mutual exclusion check fails, the current cluster occupancy status is accurately displayed to the user through the interface (the generate User Tip method is called). If the mutual exclusion check passes, based on the current database cluster occupancy type, the user is prompted whether to continue the operation based on this operation (implemented through interface interaction) or start the operation and maintenance configuration (calling the target method). At the same time, after the operation and maintenance operation is completed, the cluster occupancy status in the database is updated (calling update Cluster Occupied Status method) and release the distributed lock (call the unlock method).

[0073] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied in a distributed scenario, where multiple devices cooperate with each other to complete the method. In such a distributed scenario, one of the multiple devices may only perform one or more steps of the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the above method.

[0074] It should be noted that the above description is limited to some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in an order different from that described in the above embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0075] Based on the same inventive concept, corresponding to any of the above embodiments and methods, the present application also provides a mutual exclusion verification system for multi-user operations on a database, such as Figure 4 As shown, including:

[0076] Distributed lock component 10.

[0077] The aspect component 20 is used to obtain the distributed lock state in response to user operations; intercept the user operation in response to the distributed lock state being the locked state; or, in response to the distributed lock state being the released state, modify the distributed lock state to the locked state; in response to the user operation and the target user operation being verified to be non-mutually exclusive, allow the user operation and modify the distributed lock state to the released state; or, in response to the user operation and the target user operation being verified to be mutually exclusive, intercept the user operation and modify the distributed lock state to the released state.

[0078] The mutual exclusion verification component 30 is configured to verify a user operation in response to the distributed lock state being in the released state.

[0079] The system provided by the embodiment of the present disclosure can ensure the consistency and integrity of the database cluster under multi-user operation and maintenance operations and different operation and maintenance operations of the same user through distributed locks and mutual exclusion verification components, thereby achieving effective management and control of operation and maintenance operations.

[0080] In some embodiments, the mutual exclusion check component 30 is specifically used to:

[0081] Verify the user name and operation type of the user operation; in response to the user name of the user operation being consistent with the target user name, and the operation type of the user operation being consistent with the target operation type, determine that the verification of the user operation and the target user operation are not mutually exclusive; or, in response to the absence of the target user operation, determine that the verification of the user operation and the target user operation are not mutually exclusive; in response to the user name of the user operation being inconsistent with the target user name, and / or the operation type of the user operation being inconsistent with the target operation type, determine that the verification of the user operation and the target user operation are mutually exclusive.

[0082] In some embodiments, the mutual exclusion verification system for multi-user database operations further includes:

[0083] The database persistence component 40 is used to save the distributed lock status and user operations.

[0084] In some embodiments, the mutual exclusion check component 30 is specifically used to:

[0085] Multiple different operation types are encapsulated through enumeration, and multiple different strategy interfaces are defined, where different strategy interfaces correspond to different verification logic; the strategy interface is managed through a container, and the correspondence between the enumeration of operation types and the verification logic is stored through the container; a context object of the strategy interface is created; and the operation type of the user operation is verified, including: based on the operation type of the user operation, calling the target verification logic in the container through the context object, and using the target verification logic to verify the operation type of the user operation.

[0086] In some embodiments, the cutting surface component 20 is further used to:

[0087] Create custom annotations for the target operation object and the user operation; create an around advice, wherein the aspect component executes the around advice in response to the custom annotation.

[0088] In some embodiments, the above-mentioned surround notification includes pre-call processing and post-call processing, wherein: the pre-call processing is used to modify the distributed lock state to a locked state and verify user operations, and the post-call processing is used to modify the distributed lock state to a released state.

[0089] In some embodiments, the mutual exclusion verification system for multi-user database operations further includes:

[0090] The user prompt information processing component 50 is used to display the interception information to the user.

[0091] Figure 2 The dependency relationship among the above-mentioned distributed lock component 10, database persistence component 40, mutual exclusion verification component 30, user prompt information processing component 50 and aspect component 20 is shown, wherein the aspect component 20 depends on the other four components and implements the mutual exclusion verification function of operation and maintenance operations by calling the interfaces or methods provided by the other four components; the mutual exclusion verification component 30 depends on the database persistence component 40 to obtain data support; the user prompt information processing component 50 generates corresponding prompt information based on the results of the mutual exclusion verification component 30 and displays it to the user.

[0092] For the convenience of description, the above system is described as being divided into various modules according to their functions. Of course, when implementing this application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0093] The system of the above embodiment is used to implement the mutual exclusion verification method for multi-user operation of the database corresponding to any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0094] Figure 5 A schematic structural diagram of an electronic device provided by an embodiment of the present disclosure is shown.

[0095] like Figure 5 As shown, the electronic device may include a processor 1101 and a memory 1102 storing computer program instructions.

[0096] Specifically, the processor 1101 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0097] Memory 1102 may include a large-capacity memory for information or instructions. By way of example and not limitation, memory 1102 may include a hard disk drive (HDD), a floppy disk drive, flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 1102 may include removable or non-removable (or fixed) media. Where appropriate, memory 1102 may be internal or external to the integrated gateway device. In a specific embodiment, memory 1102 is a non-volatile solid-state memory. In a specific embodiment, memory 1102 includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically alterable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0098] The processor 1101 reads and executes the computer program instructions stored in the memory 1102 to perform the steps of the mutual exclusion verification method for multi-user operations on a database provided by the embodiment of the present disclosure.

[0099] In one example, the electronic device may further include a transceiver 1103 and a bus 1104. Figure 5 As shown, the processor 1101 , the memory 1102 and the transceiver 1103 are connected via a bus 1104 and communicate with each other.

[0100] The bus 1104 may include hardware, software, or both. By way of example, and not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a HyperTransport (HT) interconnect, an Industrial Standard Architecture (ISA) bus, an InfiniBand interconnect, a Low Pin Count (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local Bus (VLB) bus, or other suitable buses, or a combination of two or more of these. Where appropriate, the bus 1104 may include one or more buses. Although embodiments herein describe and illustrate a particular bus, this application contemplates any suitable bus or interconnect.

[0101] The following is an embodiment of a computer-readable storage medium provided in an embodiment of the present disclosure. The computer-readable storage medium and the mutually exclusive verification method for multi-user operations on a database in the above-mentioned embodiments belong to the same inventive concept. For details not fully described in the embodiment of the computer-readable storage medium, please refer to the embodiment of the mutually exclusive verification method for multi-user operations on a database in the above-mentioned embodiments.

[0102] This embodiment provides a storage medium containing computer-executable instructions. When the computer-executable instructions are executed by a computer processor, they are used to perform a mutual exclusion verification method for multi-user operations on a database.

[0103] Of course, the computer executable instructions of the storage medium provided by the embodiment of the present disclosure are not limited to the above method operations, but can also execute related operations in the mutual exclusion verification method for multi-user operations of the database provided by any embodiment of the present disclosure.

[0104] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present disclosure can be implemented with the help of software and necessary general-purpose hardware. Of course, it can also be implemented through hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the existing technology, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., and includes a number of instructions for enabling a computer cloud platform (which can be a personal computer, server, or network cloud platform, etc.) to execute the mutual exclusion verification method for multi-user database operations provided by various embodiments of the present disclosure.

[0105] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises", "includes" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprises a..." do not exclude the presence of other identical elements in the process, method, article or device that includes the above elements.

[0106] The foregoing are merely specific embodiments of the present disclosure, intended to enable those skilled in the art to understand and implement the present disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure is not limited to the foregoing embodiments, but is intended to be construed in the broadest manner consistent with the principles and novel features disclosed herein.

Claims

1. A mutual exclusion verification method for multi-user operation of a database, characterized in that: include: In response to user operations, obtain the distributed lock status; In response to the distributed lock state being a locked state, intercepting the user operation using a facet component; Alternatively, in response to the distributed lock state being in the released state, the distributed lock state is modified to the locked state, and the user operation is verified; In response to the verification that the user operation and the target user operation are not mutually exclusive, allowing the user operation and changing the state of the distributed lock to a released state; Alternatively, in response to the user operation and the target user operation being mutually exclusive, the user operation is intercepted by the aspect component, and the distributed lock state is modified to a released state; When the user passes the mutual exclusion check on the cluster's user operation and starts the user operation, the user name and operation type of the current user operation are written as the user name and operation type of the target user operation; When the user operation is completed, the relevant information of the target user operation will be cleared.

2. The method according to claim 1, characterized in that The verifying the user operation includes: Verify the user name and operation type of the user operation; The verifying that the user operation and the target user operation are not mutually exclusive in response to the user operation includes: In response to a user name of the user operation being consistent with a target user name, and an operation type of the user operation being consistent with a target operation type, determining that the user operation and the target user operation are not mutually exclusive; or, in response to the absence of the target user operation, determining that the user operation and the target user operation are not mutually exclusive; The verifying mutual exclusion of the user operation and the target user operation in response to the user operation includes: In response to the user name of the user operation being inconsistent with the target user name, and / or the operation type of the user operation being inconsistent with the target operation type, it is determined that the user operation and the target user operation are mutually exclusive.

3. The method according to claim 1, characterized in that Also includes: A database persistence component is used to save the distributed lock state and the user operation.

4. The method according to claim 2, characterized in that Before verifying the operation type of the user operation, the method further includes: Encapsulate multiple different operation types through enumeration and define multiple different strategy interfaces, where different strategy interfaces correspond to different verification logics; Managing the policy interface through a container, and storing the corresponding relationship between the enumeration of the operation type and the verification logic through the container; Create a context object for the strategy interface; Verifying the operation type of the user operation includes: According to the operation type of the user operation, the target verification logic in the container is called through the context object, and the operation type of the user operation is verified using the target verification logic.

5. The method according to claim 1, wherein Before obtaining the distributed lock status in response to a user operation, the following steps are also included: Create custom annotations for the target operation object and the user operation; An around advice is created, wherein the aspect component executes the around advice in response to the custom annotation.

6. The method according to claim 5, characterized in that The surround notification includes pre-call processing and post-call processing, where: The pre-call processing is used to modify the distributed lock state to a locked state and verify the user operation, and the post-call processing is used to modify the distributed lock state to a released state.

7. The method according to claim 1, characterized in that After intercepting the user operation by using the aspect component, the method further includes: Display blocking information to the user.

8. A mutual exclusion verification system for multi-user database operation, characterized in that: include: Distributed lock component; Aspect component, used to obtain the distributed lock status in response to user operations; In response to the distributed lock state being the locked state, intercepting the user operation; or, in response to the distributed lock state being the released state, modifying the distributed lock state to the locked state; In response to the verification that the user operation and the target user operation are not mutually exclusive, allowing the user operation and changing the state of the distributed lock to a released state; Alternatively, in response to the user operation and the target user operation being mutually exclusive, the user operation is intercepted, and the distributed lock state is modified to a released state; a mutual exclusion verification component, configured to verify the user operation in response to the distributed lock state being a released state; It also includes a database persistence component. In the database persistence component, when the user passes the mutual exclusion check of the user operation on the cluster and starts the user operation, the user name and operation type of the current user operation are written as the user name and operation type of the target user operation; When the user operation is completed, the relevant information of the target user operation will be cleared.

9. An electronic device, characterized in that: include: processor; A memory for storing executable instructions; wherein the processor is used to read the executable instructions from the memory and execute the executable instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Resource operation lock control method, system and device and readable storage medium

    CN111367682A

  • Distributed lock processing method, equipment, storage medium and system

    CN117608766A