CN116820790A - Delay processing method, device, equipment and medium for distributed lock - Google Patents

Delay processing method, device, equipment and medium for distributed lock Download PDF

Info

Publication number
CN116820790A
CN116820790A CN202310810926.6A CN202310810926A CN116820790A CN 116820790 A CN116820790 A CN 116820790A CN 202310810926 A CN202310810926 A CN 202310810926A CN 116820790 A CN116820790 A CN 116820790A
Authority
CN
China
Prior art keywords
key value
service processing
thread
processing thread
acquisition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310810926.6A
Other languages
Chinese (zh)
Inventor
祝鹏来
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kangjian Information Technology Shenzhen Co Ltd
Original Assignee
Kangjian Information Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kangjian Information Technology Shenzhen Co Ltd filed Critical Kangjian Information Technology Shenzhen Co Ltd
Priority to CN202310810926.6A priority Critical patent/CN116820790A/en
Publication of CN116820790A publication Critical patent/CN116820790A/en
Pending legal-status Critical Current

Links

Abstract

The application relates to the technical field of cloud deployment and medical health, and provides a delay processing method, device, equipment and medium of a distributed lock, wherein the method comprises the following steps: acquiring a service processing thread received in a distributed cache server; sending a locking request to a service processing thread to perform locking processing on the service processing thread; after the business processing thread is successfully locked, a corresponding key value monitoring thread is created, and the key value is obtained at regular time according to the obtaining time length so as to obtain a key value obtaining result; and when the key value acquisition result indicates that the key value exists, prolonging the residual effective time of the key value according to the acquisition duration. According to the technical scheme, under the condition of distributed locks such as hospital management, medical expense settlement and pharmacy system settlement, the problems of repeated data or disordered business logic and the like caused by releasing the business code logic after normal execution are avoided, and the normal operation of the data and the business logic is ensured.

Description

Delay processing method, device, equipment and medium for distributed lock
[ field of technology ]
The application relates to the technical fields of cloud deployment and medical health, in particular to a delay processing method, a device, equipment and a medium of a distributed lock.
[ background Art ]
In a software distributed system, it may be the case that components or modules having an association relationship are deployed on different processes, different servers, and even different devices. Because of business requirements, these components may operate on the same shared array, for example, for systems such as hospital management, hospital system settlement, and pharmacy settlement, and for medical inventory, examination, and treatment costs for a hospital pharmacy, different components may add or delete inventory and costs.
In order to ensure the safety of the shared data, that is, ensure that only one component operates the shared component at the same time, for example, for medicine inventory of a hospital, in order to ensure that a user cannot take medicine, a distributed lock is required in a software distributed system, that is, when one component operates the shared data, other components cannot operate the shared data through the distributed lock.
Specifically, when a certain component needs to operate shared data, a preset KEY (KEY) is pressed to apply for locking to the distributed lock center server, wherein the KEY is used for identifying the distributed locks, and KEYs corresponding to the distributed locks are different. The distributed lock center server determines the distributed lock to be locked according to the KEY, and locks the distributed lock, so that the shared data is locked, and other components cannot operate the shared data when the component operates the shared data.
For the distributed lock scheme of the tair distributed system, there is a significant drawback: for code logic of long-time service, the lock time cannot be estimated, if the lock is released by totally relying on the failure strategy of tair, the service code is possibly not executed, and once the failure time is reached, the lock is released, so that the execution right can be obtained for other threads, and data problems or service logic problems are caused.
For example, in the fields of medical system settlement, the transaction under the same statement needs to be guaranteed to be processed only once, so that the service processing thread of the statement needs to be locked, but after the locking, if the processing time is long and the lock is up to the expiration time, the lock release is automatically performed, and at the moment, other threads schedule or execute the service processing of the statement again, so that the problems of repeated data, disordered service logic and the like are caused.
[ application ]
The embodiment of the application provides a delay processing method, a delay processing device, delay processing equipment and delay processing media for a distributed lock, and aims to solve the technical problems of repeated data or disordered business logic and the like caused by discarding the lock due to a failure strategy under the condition of the distributed lock in hospital management, medical system settlement, pharmacy system settlement and the like in the related art.
In a first aspect, an embodiment of the present application provides a delay processing method for a distributed lock, including:
acquiring a service processing thread received in a distributed cache server;
sending a locking request to the service processing thread to perform locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time;
after the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result;
and when the key value acquisition result indicates that a key value exists, prolonging the residual effective time of the key value according to the acquisition duration.
In a second aspect, an embodiment of the present application provides a delay processing apparatus of a distributed lock, including:
the acquisition module is used for acquiring the service processing thread received in the distributed cache server;
the locking module is used for sending a locking request to the service processing thread to carry out locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time;
the monitoring module is used for creating a corresponding key value monitoring thread after the service processing thread is successfully locked so as to acquire a key value at regular time according to the acquisition duration to obtain a key value acquisition result;
and the delay module is used for prolonging the residual effective time of the key value according to the acquisition duration when the key value acquisition result indicates that the key value exists.
In a third aspect, a computer device is provided, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor executing the computer program to perform the steps of the method for delay processing of a distributed lock as described above.
In a fourth aspect, a computer readable storage medium is provided, the computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the delay processing method of a distributed lock described above.
In the scheme realized by the delay processing method, the device, the equipment and the medium of the distributed lock, the service processing thread received in the distributed cache server is obtained; sending a locking request to the service processing thread to perform locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time; after the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result; and when the key value acquisition result indicates that the key value exists, prolonging the residual effective time of the key value according to the acquisition duration. In the application, after locking processing is carried out on the business processing thread, the key value can be monitored at the same time, so that the key value of the lock which is about to be invalid is automatically delayed aiming at the thread which is still executing the task and is provided with the lock, thus, under the condition that the distributed lock is arranged in hospital management, medical expense settlement, pharmacy system settlement and the like, the problems of repeated data or disordered business logic and the like caused by releasing the lock due to invalid strategies instead of normally executing the business code logic are avoided, and the normal operation of the data and the business logic is ensured, thereby ensuring the accuracy and timeliness of calculation of medicine inventory, medical expense, medicine expense and the like.
[ description of the drawings ]
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1A is a schematic diagram of an application environment of a method for processing a delay of a distributed lock according to an embodiment of the present application.
Fig. 1B shows a schematic flow chart of a method of delay processing of a distributed lock according to one embodiment of the application.
Fig. 2 shows a schematic flow chart of a method of delay processing of a distributed lock according to another embodiment of the application.
Fig. 3 shows a schematic flow chart of a method of delay processing of a distributed lock according to a further embodiment of the application.
Fig. 4 shows a schematic flow chart of a method of delay processing of a distributed lock according to a further embodiment of the application.
Fig. 5 shows a block diagram of a delay processing device of a distributed lock according to an embodiment of the application.
FIG. 6 shows a schematic diagram of a computer device according to one embodiment of the application.
FIG. 7 shows another structural schematic diagram of a computer device according to one embodiment of the application.
[ detailed description ] of the application
For a better understanding of the technical solution of the present application, the following detailed description of the embodiments of the present application refers to the accompanying drawings.
It should be understood that the described embodiments are merely some, but not all, embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terminology used in the embodiments of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.
In order to solve the technical problems of repeated data or disordered business logic and the like caused by discarding locks due to failure strategies under the condition of distributed locks in hospital management, medical system settlement, pharmacy system settlement and the like in the related art, the application provides a delay processing method, a delay processing device, delay processing equipment and delay processing media for the distributed locks.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
It should be noted that, the embodiment of the present application may acquire and process related data based on artificial intelligence technology. Wherein artificial intelligence is the intelligence of simulating, extending and expanding a person using a digital computer or a machine controlled by a digital computer, sensing the environment, obtaining knowledge, and using knowledge to obtain optimal results.
Artificial intelligence infrastructure technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
The delay processing method of the distributed lock provided by the embodiment of the application can be applied to an application environment as shown in fig. 1A, wherein a client communicates with a distributed cache server through a network. The client acquires a service processing thread received in the distributed cache server; sending a locking request to a service processing thread to perform locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time; after the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result; and when the key value acquisition result indicates that the key value exists, prolonging the residual effective time of the key value according to the acquisition duration. In the application, after locking processing is carried out on the business processing thread, the key value can be monitored at the same time, so that the key value of the lock which is about to be invalid is automatically delayed aiming at the thread which is still executing the task and is provided with the lock, thus, under the condition that the distributed lock is arranged in hospital management, medical expense settlement, pharmacy system settlement and the like, the problems of repeated data or disordered business logic and the like caused by releasing the lock due to invalid strategies instead of normally executing the business code logic are avoided, and the normal operation of the data and the business logic is ensured, thereby ensuring the accuracy and timeliness of calculation of medicine inventory, medical expense, medicine expense and the like.
The clients may be, but are not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices. The server may be implemented by a stand-alone server or a server cluster formed by a plurality of servers. The present application will be described in detail with reference to specific examples.
Referring to FIG. 1B, FIG. 1B shows a schematic flow chart of a method of delay processing of a distributed lock according to one embodiment of the application. The delay processing method of the distributed lock is used for solving the technical problems of repeated data or disordered business logic and the like caused by discarding the lock due to a failure strategy under the condition of the distributed lock in the related technologies such as hospital management, medical system settlement, pharmacy system settlement and the like.
As shown in fig. 1B, a delay processing method of a distributed lock according to an embodiment of the present application may be used for a client, where the flow includes:
step S101, a service processing thread received in a distributed cache server is obtained.
The business processing thread may be a processing thread in the field of medical system settlement or the like, for example, transaction inquiry of a medical statement, processing of a pharmacy statement, or the like.
Wherein the distributed cache server includes, but is not limited to, a tair cache server.
the tair cache server is a solution of Key/Value structure data, and defaults to support two storage modes based on memory and files, which correspond to cache and persistent storage respectively. the function of tair is get, put, delete and batch interface. A tair cluster mainly includes 3 mandatory modules: configserver, dataserver and client, an optional module: an interval idserver. Typically, a cluster includes 2 configservers and multiple dataservers. Two configservers are active and standby, and the surviving available dataservers in the cluster are obtained through maintaining heartbeat between the two configservers, so that the distribution information (comparison table) of the data in the cluster is constructed. The dataserver is responsible for data storage, and replication and migration of the data are completed according to the configserver instruction. When the client is started, acquiring data distribution information from the configserver, and completing the request of the user according to the data distribution information and the corresponding dataserver interaction. The invalidiserver is mainly responsible for deleting and hiding the peer-to-peer clusters, and ensures the consistency of the data of the peer-to-peer clusters. From the architecture point of view, the role of configServer is similar to that of the central node of the traditional application system, and the whole cluster service depends on the normal operation of the configServer. In practice, however, tair's configserver is very lightweight and another one automatically takes over in seconds when the operating server is down. Moreover, if the worst case that two servers are down at the same time occurs, the tair still serves normally as long as the application server has no new changes. The benefit of having a configServer as a central node is that the application only needs to configure the address of the configServer (the direct key can now be configured) when in use, without knowing the internal node. the main advantages of the tair cache server include: high performance read-write, three storage engines (ddb/rdb/ldb) are supported, high availability is supported, and distributed sharded clustering is supported.
Step S102, a locking request is sent to the service processing thread to carry out locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time;
in the above embodiment, the distributed cache server and the client may communicate through a wired connection manner or a wireless connection manner, where the distributed cache server may receive a locking request sent by the client, and based on the locking request, find a distributed lock matching the distributed lock stored in the distributed cache server, return the distributed lock and the locking request to the client, and after the client receives the locking request, perform locking processing on the service processing thread.
In one embodiment, optionally, the acquisition duration is calculated using the following formula;
t=e/n
wherein t represents the acquisition duration, e represents the effective time, and n represents a positive integer.
Of course, the acquisition duration may also be other values, without limitation.
And (3) performing locking processing on the service processing thread, namely setting a key value for the service processing thread, setting the effective time extension (e) of the key, and if the key is set successfully, simultaneously starting a timing task with a period of time (e.g. e/5) for acquiring duration, monitoring the key in the tair, and returning that the locking is successful.
In one embodiment, optionally, the method further comprises:
the locking request is packaged in a packet data packet; or alternatively
The locking request uses a scripting language.
The valid time specifies the maximum occupied time of the distributed lock, and the distributed cache server can determine the release time of the distributed lock by using the valid time allocated by the distributed lock, that is, when the system time of the distributed cache server reaches the end of the valid time, the distributed lock is released, interrupts the service processing thread, and deletes the service processing thread from the thread pool to release the resource.
In this embodiment, the locking request may encapsulate a packet data packet, or use a scripting language to ensure as much as possible a data interaction, and ensure atomicity, so as to ensure data security.
Step S103, when the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result;
as in the above embodiment, assuming that the acquisition duration is e/5, the key value of the service processing thread is acquired every e/5.
In the above embodiment, after the distributed locks are allocated to the clients, the corresponding clients have access rights to the database shared resources corresponding to the distributed locks, after the clients receive the distributed locks, the clients lock the service processing threads and allocate a monitoring thread to the service processing threads, where the service processing threads are used to execute the service to be executed corresponding to the locking request, and the monitoring thread is used to monitor the key values in the service processing threads, that is, acquire the key values at regular intervals according to the acquiring time length, so as to obtain the key value acquiring result.
Step S104, when the key value acquisition result indicates that a key value exists, the remaining effective time of the key value is prolonged according to the acquisition duration.
If the key value exists, the thread still executes the service logic, the distributed lock is not released, and the residual effective time of the key value is prolonged according to the acquired time length, so that the service processing thread can be ensured to continue to execute, the normal operation of data and the service logic is ensured, and the problems of repeated data or disordered service logic and the like caused by releasing the lock due to a failure strategy instead of normal execution of the service code logic are avoided.
Specifically, the remaining effective duration may be extended to an acquisition duration, for example, the acquisition duration is e/5, and then the effective time of the key of the service processing thread is delayed by e/5.
As shown in fig. 2, in an embodiment, optionally, the method further includes:
step S201, when the key value obtaining result indicates that the key value does not exist, interrupting the service processing thread, and deleting the service processing thread from the thread pool.
In the above embodiment, the client needs to build a thread pool in advance according to the number of CPU cores, for example, build a thread pool with a number of CPU cores equal to 3, after receiving the distributed lock, put the service processing thread corresponding to the locking request into the thread pool, and after putting it into the thread pool, can execute the corresponding service processing. If the key does not exist, indicating that the distributed lock has been released, the thread is interrupted and resources are released from the thread pool.
As shown in fig. 3, in an embodiment, optionally, the method further comprises:
step S301, when the locking of the service processing thread fails, blocking the service processing thread.
Considering performance problems, the method can automatically loop and attempt to lock, namely repeat the step S102, and jump out if the locking is successful and block if the locking is failed.
As shown in fig. 4, in an embodiment, optionally, the method further includes:
and step S401, when the effective time of the business processing thread is used up, or when the business processing thread is processed, unlocking the business processing thread.
In one embodiment, optionally, the unlocking process includes the steps of:
deleting the key value corresponding to the service processing thread, interrupting the corresponding key value monitoring thread, waking up the blocked other service processing threads to acquire the locking request again, namely repeating the step S102.
In the above embodiment, after the locking processing is performed on the service processing thread, the key value can be monitored at the same time, so that the key value of the lock which is about to be invalidated is automatically delayed for the thread which is still executing the task and holds the lock, thus, under the condition that the lock is distributed in hospital management, medical expense settlement, pharmacy system settlement and the like, the problems of repeated data or disordered service logic and the like caused by releasing the lock due to invalidation strategy instead of normal execution of the service code logic are avoided, and the normal operation of the data and the service logic is ensured, thereby ensuring the accuracy and timeliness of calculation of medicine inventory, medical expense, medicine expense and the like.
For example, in the fields of medical system settlement and the like, only one transaction under the same statement needs to be processed, so that a service processing thread of the statement needs to be locked, and when the service processing thread of the statement is successfully locked, a corresponding key value monitoring thread is created, and a key value is acquired at regular time according to the acquisition duration to obtain a key value acquisition result; and when the key value acquisition result indicates that the key value exists, prolonging the residual effective time of the key value by the acquisition duration, and when the key value acquisition result indicates that the key value does not exist, interrupting the service processing thread and deleting the service processing thread from the thread pool. Therefore, the repeated data or the disordered business logic of the bill business can be avoided, and the accuracy and timeliness of the bill data are ensured.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Fig. 5 shows a block diagram of a delay processing device of a distributed lock according to an embodiment of the application.
As shown in fig. 5, in a second aspect, an embodiment of the present application provides a delay processing apparatus 50 of a distributed lock, including:
an obtaining module 51, configured to obtain a service processing thread received in the distributed cache server;
a locking module 52, configured to send a locking request to the service processing thread to perform locking processing on the service processing thread, where the locking request includes a key value, an effective time of the key value, and an acquisition duration associated with the effective time;
the monitoring module 53 is configured to create a corresponding key value monitoring thread after the service processing thread is successfully locked, so as to acquire a key value at regular time according to the acquiring duration, so as to obtain a key value acquiring result;
and a delay module 54, configured to, when the key value acquisition result indicates that a key value exists, extend the remaining valid time of the key value according to the acquisition duration.
In one embodiment, optionally, the apparatus further comprises:
and the deleting module is used for interrupting the service processing thread and deleting the service processing thread from the thread pool when the key value acquisition result indicates that the key value does not exist.
In one embodiment, optionally, the apparatus further comprises:
and the blocking module is used for blocking the service processing thread after the locking failure of the service processing thread.
In one embodiment, optionally, the apparatus further comprises:
and the unlocking module is used for unlocking the service processing thread when the effective time of the service processing thread is used up or the service processing thread is processed.
In one embodiment, optionally, the unlocking process includes the steps of:
deleting the key value corresponding to the service processing thread, interrupting the corresponding key value monitoring thread, and waking up the blocked other service processing threads to acquire locking requests again.
In one embodiment, optionally, the locking request is encapsulated in a packet; or the locking request uses a scripting language.
In one embodiment, optionally, the acquisition duration is calculated using the following formula;
t=e/n
wherein t represents the acquisition duration, e represents the effective time, and n represents a positive integer.
The delay processing device of the distributed lock firstly acquires a service processing thread received in a distributed cache server; sending a locking request to the service processing thread to perform locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time; after the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result; and when the key value acquisition result indicates that the key value exists, prolonging the residual effective time of the key value according to the acquisition duration. In the application, after locking processing is carried out on the business processing thread, the key value can be monitored at the same time, and then the key value of the lock which is about to be invalid is automatically delayed aiming at the thread which is still executing the task and is provided with the lock, so that under the condition that the distributed lock is arranged in hospital management, medical expense settlement, pharmacy system settlement and the like, the problems of repeated data or disordered business logic and the like caused by releasing the business code logic instead of normal execution are avoided, and the normal operation of the data and the business logic is ensured, thereby ensuring the accuracy and timeliness of calculation of medicine inventory, medical expense, medicine expense and the like.
For specific limitations on the delay processing device of the distributed lock, reference may be made to the above limitation on the delay processing method of the distributed lock, which is not described herein. The modules in the delay processing device of the distributed lock can be all or partially implemented by software, hardware and a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 6. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes non-volatile and/or volatile storage media and internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is for communicating with an external client via a network connection. The computer program, when executed by a processor, performs the functions or steps of a server side of a delay processing method of a distributed lock.
In one embodiment, a computer device is provided, which may be a client, the internal structure of which may be as shown in FIG. 7. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is for communicating with an external server via a network connection. The computer program, when executed by a processor, performs the functions or steps of a client side of a delay processing method of a distributed lock.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The computer device of embodiments of the present application exists in a variety of forms including, but not limited to:
(1) Mobile communication devices, which are characterized by mobile communication functionality and are aimed at providing voice, data communication. Such terminals include smart phones (e.g., iPhone), multimedia phones, functional phones, and low-end phones, among others.
(2) Ultra mobile personal computer equipment, which belongs to the category of personal computers, has the functions of calculation and processing and generally has the characteristic of mobile internet surfing. Such terminals include PDA, MID and UMPC devices, etc., such as iPad.
(3) Portable entertainment devices such devices can display and play multimedia content. Such devices include audio, video players (e.g., iPod), palm game consoles, electronic books, and smart toys and portable car navigation devices.
(4) The server is similar to a general computer architecture in that the server is provided with high-reliability services, and therefore, the server has high requirements on processing capacity, stability, reliability, safety, expandability, manageability and the like.
(5) Other electronic devices with data interaction function.
In one embodiment, a computer device is provided comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, the processor implementing the steps of when executing the computer program:
acquiring a service processing thread received in a distributed cache server;
sending a locking request to the service processing thread to perform locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time;
after the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result;
and when the key value acquisition result indicates that a key value exists, prolonging the residual effective time of the key value according to the acquisition duration.
In one embodiment, optionally, the method further comprises:
and when the key value acquisition result indicates that the key value does not exist, interrupting the service processing thread, and deleting the service processing thread from the thread pool.
In one embodiment, optionally, the method further comprises:
and blocking the service processing thread after the locking failure of the service processing thread.
In one embodiment, optionally, the method further comprises:
and when the effective time of the service processing thread is used up, or when the service processing thread is processed, unlocking the service processing thread.
In one embodiment, optionally, the unlocking process includes the steps of:
deleting the key value corresponding to the service processing thread, interrupting the corresponding key value monitoring thread, and waking up the blocked other service processing threads to acquire locking requests again.
In one embodiment, optionally, the method further comprises:
the locking request is packaged in a packet data packet; or alternatively
The locking request uses a scripting language.
In one embodiment, optionally, the acquisition duration is calculated using the following formula;
t=e/n
wherein t represents the acquisition duration, e represents the effective time, and n represents a positive integer.
It should be noted that, the functions or steps that can be implemented by the computer readable storage medium or the electronic device may correspond to the relevant descriptions in the foregoing method embodiments, and are not described herein for avoiding repetition.
It should be understood that the term "and/or" as used herein is merely one relationship describing the association of the associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
It should be understood that although the terms first, second, etc. may be used to describe the arrangement elements in the embodiments of the present application, these arrangement elements should not be limited to these terms. These terms are only used to distinguish the setting units from each other. For example, a first setting unit may also be referred to as a second setting unit, and similarly, a second setting unit may also be referred to as a first setting unit, without departing from the scope of embodiments of the present application.
Depending on the context, the word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to detection". Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
In the several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the elements is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple elements or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), memory bus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. A method for delay processing of a distributed lock, comprising:
acquiring a service processing thread received in a distributed cache server;
sending a locking request to the service processing thread to perform locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time;
after the business processing thread is successfully locked, a corresponding key value monitoring thread is created to acquire a key value at regular time according to the acquisition time length so as to obtain a key value acquisition result;
and when the key value acquisition result indicates that a key value exists, prolonging the residual effective time of the key value according to the acquisition duration.
2. The method of delay processing of a distributed lock of claim 1, further comprising:
and when the key value acquisition result indicates that the key value does not exist, interrupting the service processing thread, and deleting the service processing thread from the thread pool.
3. The method of delay processing of a distributed lock of claim 1, further comprising:
and blocking the service processing thread after the locking failure of the service processing thread.
4. The method of delay processing of a distributed lock of claim 1, further comprising:
and when the effective time of the service processing thread is used up, or when the service processing thread is processed, unlocking the service processing thread.
5. The delay processing method of a distributed lock according to claim 4, wherein the processing step of the unlocking process includes:
deleting the key value corresponding to the service processing thread, interrupting the corresponding key value monitoring thread, and waking up the blocked other service processing threads to acquire locking requests again.
6. The method of delay processing of a distributed lock of claim 1, further comprising:
the locking request is packaged in a packet data packet; or alternatively
The locking request uses a scripting language.
7. The method of delay processing of a distributed lock of claim 1, wherein the acquisition duration is calculated using the formula;
t=e/n
wherein t represents the acquisition duration, e represents the effective time, and n represents a positive integer.
8. A delay processing device for a distributed lock, comprising:
the acquisition module is used for acquiring the service processing thread received in the distributed cache server;
the locking module is used for sending a locking request to the service processing thread to carry out locking processing on the service processing thread, wherein the locking request comprises a key value, the effective time of the key value and the acquisition time associated with the effective time;
the monitoring module is used for creating a corresponding key value monitoring thread after the service processing thread is successfully locked so as to acquire a key value at regular time according to the acquisition duration to obtain a key value acquisition result;
and the delay module is used for prolonging the residual effective time of the key value according to the acquisition duration when the key value acquisition result indicates that the key value exists.
9. A computer device, comprising: at least one processor; and a memory communicatively coupled to the at least one processor;
wherein the memory stores instructions executable by the at least one processor, the instructions being arranged to perform the method of any of the preceding claims 1 to 7.
10. A computer readable storage medium storing computer executable instructions for performing the method of any one of claims 1 to 7.
CN202310810926.6A 2023-07-04 2023-07-04 Delay processing method, device, equipment and medium for distributed lock Pending CN116820790A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310810926.6A CN116820790A (en) 2023-07-04 2023-07-04 Delay processing method, device, equipment and medium for distributed lock

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310810926.6A CN116820790A (en) 2023-07-04 2023-07-04 Delay processing method, device, equipment and medium for distributed lock

Publications (1)

Publication Number Publication Date
CN116820790A true CN116820790A (en) 2023-09-29

Family

ID=88120044

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310810926.6A Pending CN116820790A (en) 2023-07-04 2023-07-04 Delay processing method, device, equipment and medium for distributed lock

Country Status (1)

Country Link
CN (1) CN116820790A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117472930A (en) * 2023-12-26 2024-01-30 成都大成均图科技有限公司 Storage method, device and equipment for high concurrency data

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117472930A (en) * 2023-12-26 2024-01-30 成都大成均图科技有限公司 Storage method, device and equipment for high concurrency data

Similar Documents

Publication Publication Date Title
US20220239602A1 (en) Scalable leadership election in a multi-processing computing environment
US7991822B2 (en) Propagation of updates for attributes of a storage object from an owner node of the storage object to other nodes
US9632828B1 (en) Computing and tracking client staleness using transaction responses
US11023446B2 (en) Method and device for processing distributed transaction
US20160364158A1 (en) Recovery in data centers
US10515067B2 (en) Distributed reservations systems and methods
CN108733496B (en) Event processing method and device
US8973117B2 (en) Propagating security identity information to components of a composite application
CN116820790A (en) Delay processing method, device, equipment and medium for distributed lock
US9170837B2 (en) Transaction concurrent execution control system, method and program for carrying out a control of concurrently executing a transaction, including measuring execution time from starting to ending of transaction execution
US20230281061A1 (en) Multi-phase distributed task coordination
WO2022048358A1 (en) Data processing method and device, and storage medium
CN110866011B (en) Data table synchronization method and device, computer equipment and storage medium
CN111966530A (en) Disaster recovery switching method and device for application system, computer equipment and storage medium
CN112015563A (en) Message queue switching method and device, electronic equipment and storage medium
CN111737021A (en) Parallel task processing method and device, electronic equipment and storage medium
US20050198005A1 (en) Systems and methods for controlling access to an object
US20150312165A1 (en) Temporal based collaborative mutual exclusion control of a shared resource
US20230333878A1 (en) Request processing methods and apparatuses, computing device and storage medium
JP2007264770A (en) Database access method and device
CN111385356B (en) Distributed session processing method, device and system
CN117472930A (en) Storage method, device and equipment for high concurrency data
CN117667421A (en) Method, device, computer equipment and storage medium for realizing distributed lock
CN117931427A (en) Resource data processing method and system based on local memory lock and distributed lock
CN114489956A (en) Instance starting method and device based on cloud platform

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination