A service data processing method and device, a storage medium and an electronic device
By creating a list of business entity locks in the business process and using a blocking queue and an internal lock list for parallel processing, the problem of difficult-to-understand and poor-maintain code caused by the mixing of concurrency control and business processing is solved, achieving more efficient concurrency control and better scalability.
Patent Information
- Application Number
- CN202210738228.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-27
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2042-06-27
AI Technical Summary
In existing technologies, concurrency control and business processing are mixed together, making the business processing code difficult to understand, maintainable, and extensible.
By intercepting multiple business requests, a list of business entity locks is created, and parallel processing is achieved using a blocking queue and an internal lock list, thus separating concurrency control from business processing.
It improves the efficiency of business processing and the performance of concurrency control, and enhances the maintainability and scalability of the code.
Smart Images

Figure CN117350731B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the field of business data consistency, in particular, to a business data processing method and device, a storage medium and an electronic device. BACKGROUND
[0002] Business data in concurrent operation will produce data consistency problems. For example, bank transfer, A account appears two transfer at the same time, A account initial amount of 10000 yuan, the first is A account to B account transfer 9000 yuan, the second is A account to C account transfer 5000 yuan, concurrent operation process is shown in the following table:
[0003] A transfer B A transfer C Step 1 Query from database A account current amount 10000 yuan Query from database A account current amount 10000 yuan Step 2 A account amount modified to 1000 yuan, save database A account amount modified to 5000 yuan, save database Step 3 B account amount increased by 9000 yuan, save database C account amount increased by 5000 yuan, save database
[0004] Account A final amount may be 1000 yuan or 5000 yuan, the result is incorrect, which is the problem of concurrent operation business data inconsistency.
[0005] For the problem of concurrent operation business data inconsistency, there are two main solutions in the prior art, database pessimistic lock and database optimistic lock: database pessimistic lock uses the lock mechanism provided by the database, locks when querying data, forces sequential execution of concurrent operation, and ensures business data consistency; database optimistic lock increases an identification field in the database table, checks whether there is conflict when submitting, and if there is conflict, the operation is invalid, and the operation is executed again.
[0006] However, the technical solutions of database pessimistic lock and database optimistic lock still have the following disadvantages: 1. implementation is very complex, business processing and concurrent control are intertwined, business processing code is difficult to understand, resulting in poor maintainability; 2. completely dependent on the underlying database, once the database is replaced, a large amount of program code needs to be modified, resulting in poor scalability; 3. database pessimistic lock database locking, which can easily affect the concurrent operation performance of the database, and can easily cause deadlock.
[0007] The related art also uses the lock of the programming language itself to solve the problem of data consistency, for example, the concurrent keyword synchronized of Java language, but the disadvantage of this method is that the concurrent control mechanism provided by the programming language is general, and there is a problem of direct use efficiency, for example, increasing the keyword synchronized in the transfer method will cause other account transfer operations to be blocked, and the performance is very poor.
[0008] In view of the problem that the related art mixes concurrent control and business processing together, resulting in business processing code being difficult to understand, poor maintainability and scalability, no solution has been proposed. SUMMARY
[0009] Embodiments of the present application provide a service data processing method and device, a storage medium and an electronic device to at least solve the problem that concurrent control and service processing are mixed together in related technologies, which makes it difficult to understand service processing code and poor in maintainability and scalability.
[0010] According to an embodiment of the present application, a service data processing method is provided, which comprises:
[0011] intercepting a plurality of service requests and creating a plurality of service entity lock lists for the plurality of service requests, wherein each service request corresponds to a service entity lock list, and each service entity lock list comprises a plurality of service entity locks for controlling service processing threads;
[0012] adding the plurality of service entity lock lists to a blocking queue and obtaining a to-be-processed service entity lock list from the blocking queue;
[0013] recording the to-be-processed service entity lock list to an internal lock list or a mutual exclusion table, wherein the internal lock list is used to record a target service entity lock list currently being executed, the mutual exclusion table is used to record service entity lock lists mutually exclusive with the target service entity lock list, and the internal lock list and the mutual exclusion table contain one or more service entity lock lists;
[0014] performing parallel processing on all target service entity lock lists in the internal lock list.
[0015] According to another embodiment of the present application, a service data processing device is provided, which comprises:
[0016] an intercepting module configured to intercept a plurality of service requests and create a plurality of service entity lock lists for the plurality of service requests, wherein each service request corresponds to a service entity lock list, and each service entity lock list comprises a plurality of service entity locks for controlling service processing threads;
[0017] a queue module configured to add the plurality of service entity lock lists to a blocking queue and obtain a to-be-processed service entity lock list from the blocking queue;
[0018] a recording module configured to record the to-be-processed service entity lock list to an internal lock list or a mutual exclusion table, wherein the internal lock list is used to record a target service entity lock list currently being executed, the mutual exclusion table is used to record service entity lock lists mutually exclusive with the target service entity lock list, and the internal lock list and the mutual exclusion table contain one or more service entity lock lists;
[0019] a parallel processing module configured to perform parallel processing on all target service entity lock lists in the internal lock list.
[0020] According to a further embodiment of the present application, a computer readable storage medium is also provided, and the storage medium stores a computer program, wherein the computer program is run by a processor to perform the steps in any of the method embodiments.
[0021] According to a further embodiment of the present application, an electronic device is also provided, comprising a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the method embodiments.
[0022] In the embodiments of the present application, a plurality of service request is intercepted, a plurality of service entity lock list is created for the plurality of service request, a to-be-processed service entity lock list is obtained through a blocking queue, and concurrent control is performed through an internal lock list and a mutual exclusion table. The service entity lock list in the internal lock list is processed in parallel, so that the concurrent control mechanism is separated from the service processing. Through the method, the problem that the concurrent control and the service processing are mixed together in the related art, so that the service processing code is difficult to understand, and the maintainability and the expansibility are poor can be solved. BRIEF DESCRIPTION OF DRAWINGS
[0023] Figure 1 FIG. 1 is a hardware structure block diagram of a mobile terminal of a service data processing method according to an embodiment of the present application;
[0024] Figure 2 FIG. 2 is a flowchart of a service data processing method according to an embodiment of the present application;
[0025] Figure 3 FIG. 3 is a schematic diagram of an overall flow of a service data processing method according to an embodiment of the present application;
[0026] Figure 4 FIG. 4 is a schematic diagram of adding a service entity lock list according to an embodiment of the present application;
[0027] Figure 5 FIG. 5 is a schematic diagram of mutual exclusion checking operation according to an embodiment of the present application;
[0028] Figure 6 FIG. 6 is a schematic diagram of releasing a lock according to an embodiment of the present application;
[0029] Figure 7 FIG. 7 is a schematic diagram of releasing a service entity lock list according to an embodiment of the present application;
[0030] Figure 8 FIG. 8 is a block diagram of a service data processing device according to an embodiment of the present application. DETAILED DESCRIPTION
[0031] The embodiments of this application will be described in detail below with reference to the accompanying drawings and examples.
[0032] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0033] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a business data processing method according to an embodiment of this application, such as... Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 (Only one is shown) Processor 102, which may include, but is not limited to, a microcontroller unit (MCU) or a field-programmable gate array (FPGA) and a memory 104 for storing data. The mobile terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0034] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the business data processing method in this embodiment. The processor 102 executes various functional applications and business chain address pool slicing processing by running the computer program stored in the memory 104, thus implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0035] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network interface controller (NIC) configured to connect to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module configured to communicate with the Internet via a wireless manner.
[0036] In the present embodiment, a service data processing method running on the mobile terminal or the network architecture is provided, Figure 2 is a flowchart of the service data processing method according to the present embodiment, as shown in Figure 2 The flowchart includes the following steps:
[0037] In step S202, a plurality of service requests are intercepted, and a plurality of service entity lock lists are created for the plurality of service requests. Each service request corresponds to one service entity lock list, and each service entity lock list includes a plurality of service entity locks, which are used to control service processing threads.
[0038] In step S204, the plurality of service entity lock lists are added to a blocking queue, and a to-be-processed service entity lock list is obtained from the blocking queue.
[0039] In step S206, the to-be-processed service entity lock list is recorded in an internal lock list or a mutual exclusion table. The internal lock list is used to record a target service entity lock list currently being executed, and the mutual exclusion table is used to record service entity lock lists mutually exclusive with the target service entity lock list. The internal lock list and the mutual exclusion table include one or more service entity lock lists.
[0040] In step S208, all target service entity lock lists in the internal lock list are processed in parallel.
[0041] In the present embodiment, in step S202, the AOP technology can be used to intercept the service requests. Specifically, a plurality of AOP agents can be created to intercept a plurality of service requests at the same time. The service operation of the client is first sent to the AOP agent.
[0042] In the embodiment, the step S202 can specifically include: acquiring service data identifiers of each piece of service data in the plurality of service requests respectively; and creating the service entity lock list according to all the service data identifiers in the plurality of service requests respectively, to obtain the plurality of service entity lock lists, wherein each piece of service data identifier in the service entity lock list corresponds to one service entity lock.
[0043] Specifically, each piece of service data has a unique identifier (ID), which can be a string, a number or an object. The service entity lock can also use the unique identifier of the service as a lock. When the service ID is used as a lock, only the same service ID will be mutually exclusive and wait, and different service IDs can be executed concurrently.
[0044] In the embodiment, the step S204 can specifically include: determining the service entity lock list as a to-be-processed service entity lock list; and adding the to-be-processed service entity lock list to the blocking queue in sequence.
[0045] Specifically, in the embodiment, there is only one blocking queue, and according to the characteristics of the blocking queue, when the blocking queue is full, the service entity lock list cannot be continuously added to the blocking queue.
[0046] In the embodiment, the blocking queue has a first-in-first-out characteristic in the step S204, and when the blocking queue is empty, the to-be-processed service entity lock list cannot be continuously obtained from the blocking queue. In addition to the to-be-processed service entity lock list obtained from the service interception point, the blocking queue can also include a to-be-released service entity lock list after service processing, and the to-be-released service entity lock list or the to-be-processed service entity lock list needs to be obtained from the blocking queue in sequence according to the nature of the queue.
[0047] In the embodiment, the step S206 can specifically include: performing mutual exclusion checking on the to-be-processed service entity lock list and the internal lock list; recording the to-be-processed service entity lock list to the mutual exclusion table when the checking result is mutual exclusion; and recording the to-be-processed service entity lock list to the internal lock list when the checking result is no mutual exclusion.
[0048] Further, the mutual exclusion checking on the to-be-processed service entity lock list and the internal lock list includes: judging whether the to-be-processed service entity lock list and the internal lock list have the same service entity lock; determining that the checking result is mutual exclusion when the judgment result is yes; and determining that the checking result is no mutual exclusion when the judgment result is no.
[0049] Specifically, mutual exclusion checking is performed according to mutual exclusion rules between the business entity lock lists. The mutual exclusion rules are that as long as there is a same business entity lock between two lists, the two lists are considered to be mutually exclusive, and only one of the business entity lock lists that are mutually exclusive can call the business processing, and the other business entity lock lists must wait. For example, a business entity lock list A = {lock1, lock2, lock3}, a business entity lock list B = {lock3, lock4, lock5}, because there is a same business entity lock lock3, the business entity lock lists A and B are mutually exclusive.
[0050] In the embodiment, the step S208 can specifically include: waking up the business processing thread corresponding to each business entity lock in the target business entity lock list; processing the corresponding business data by the business processing thread and returning the business processing result.
[0051] Specifically, because there is no mutual exclusion among the business entity lock lists in the internal lock list, the business requests corresponding to the business entity lock lists in the internal lock list can be processed in parallel, that is, concurrent control is performed before the step S208, and only business processing is performed in the step S208, so that separation of concurrent control and business processing is realized, and the performance of concurrent control and the efficiency of business processing are improved.
[0052] In another embodiment, after the step S208, the method further includes: creating a corresponding to-be-released business entity lock list for each target business entity lock list that has been processed; and adding the to-be-released business entity lock lists to the blocking queue.
[0053] Specifically, the blocking queue has both to-be-released business entity lock lists and to-be-processed business entity lock lists, which need to be added to the blocking queue in turn according to the characteristics of the blocking queue and be obtained from the blocking queue in turn. The two kinds of lists share the same blocking queue, so that the processing logic of concurrent control is ensured. The to-be-released business entity lock lists can be used to release the business entity lock lists that have been processed in the internal lock list, and can also be used to trigger mutual exclusion checking of the business entity lock lists in the mutual exclusion table.
[0054] Further, after the step S208, the method further includes: obtaining the to-be-released business entity lock list from the blocking queue; deleting the target business entity lock list corresponding to the to-be-released business entity lock list in the internal lock list to obtain an updated internal lock list; performing mutual exclusion checking on each business entity lock list in the mutual exclusion table and the updated internal lock list to determine whether there is mutual exclusion; and recording the business entity lock list in the mutual exclusion table that does not have mutual exclusion to the updated internal lock list, and deleting it from the mutual exclusion table.
[0055] Specifically, the specific operation of checking the business entity lock list in the mutual exclusion table is similar to the operation of checking the to-be-processed entity lock list.
[0056] Through the steps S202 to S208, the concurrent control mechanism can be separated from the business processing, and only the business itself needs to be considered when the business processing is performed, so that the efficiency of the business processing and the performance of the concurrent control are improved. In the embodiment, the concurrent control can be implemented only according to the mutual exclusion table and the internal lock list by creating the business entity lock list, without depending on a specific database or a specific product, and the embodiment has higher scalability.
[0057] According to another embodiment of the application, a business data processing flow is provided, and the flow specifically includes the following steps:
[0058] In step S1, a business entity lock is defined by using a programming language, and a unique identifier (ID) of business data is used as a judgment basis for lock mutual exclusion.
[0059] In step S2, an AOP technology is used to create a business flow interception point, and the business entity lock is accessed.
[0060] In step S3, a business entity lock list is created by using the ID of the business data of a business operation in the AOP interception point.
[0061] In step S4, the business entity lock list is passed to a lock manager in the AOP interception point, and a business operation thread enters a waiting state.
[0062] In step S5, a lock management table is used by a lock manager thread to determine whether there is mutual exclusion, if there is no mutual exclusion, the business entity lock list is recorded in an internal lock list, and the waiting business thread is awakened to perform a business operation; if there is mutual exclusion, the business entity lock list is recorded in a mutual exclusion table.
[0063] In step S6, the business thread performs a business operation, an AOP interceptor obtains a business execution end notification, and then notifies the lock manager to release the business entity lock list.
[0064] In step S7, the lock manager deletes the business entity lock list recorded in the lock management table.
[0065] In step S8, the lock manager wakes up the business thread waiting for mutual exclusion according to the mutual exclusion table.
[0066] In the embodiment, if there are N pieces of intercepted business data in step S3, a list containing N pieces of business entity locks is created, and if there are multiple AOP interception points, multiple lists of business entity locks are created.
[0067] In the embodiment, the lock manager in step S4 is used to control the business entity lock, and can be used as an interface of the concurrency control. The lock manager module includes a blocking queue, a mutual exclusion table, and an internal lock list. Through the lock manager, operations can be performed on the blocking queue, the mutual exclusion table, and the internal lock list.
[0068] In the embodiment, in step S6, the AOP agent has a one-to-one correspondence with each business entity lock list. The AOP agent can perceive the end of the process of mutual exclusion of the business entity lock list that the AOP agent proxies.
[0069] In the embodiment, through steps S1 to S8, the business entity lock is used for the concurrency control, better concurrency performance is obtained, the business request is converted into the business entity lock list through the AOP interception, and the lock manager is directly used for the lock control, the business control and the concurrency control are separated, and better maintainability and scalability are obtained.
[0070] Figure 3 FIG. 1 is a schematic diagram of the overall flow of the business data processing method according to the embodiment of the application. The time sequence diagram of the Unified Modeling Language (UML) is used for the description. As shown in FIG. 1, the business data processing flow mainly passes through the following nodes: a client 302, an AOP agent 304, a lock manager 306, and a business class 308. Figure 3
[0071] In the embodiment, the client 302 is an abstraction, representing a caller of a business operation.
[0072] In the embodiment, the AOP agent 304 is an existing Aspect Oriented Programming (AOP) technology, representing an interception of a business operation. The business operation of the client is first sent to the AOP agent. The AOP agent generates a business entity lock list according to the business request data, and adds the business lock list into the lock manager in an asynchronous calling mode. Then, the AOP agent performs a blocking waiting on the business lock list by using a synchronization waiting mechanism provided by a programming language or an operating system.
[0073] In the embodiment, the lock manager 306 has an independent processing thread, responsible for the lock mutual exclusion management operation. If it is found that the lock list does not have mutual exclusion, the AOP agent is awakened by using a concurrency control mechanism provided by a programming language or an operating system. The specific implementation details of the lock manager are described below.
[0074] In the embodiment, the AOP agent calls the business class 308 to perform specific business processing. After the business processing is completed, the AOP agent asynchronously calls the lock manager to release the business entity lock list, and returns the business processing result to the client.
[0075] In the embodiment, after receiving the asynchronous request of releasing the lock, the lock manager completes the release of the lock by a separate processing thread of the lock manager, and wakes up the AOP agent in the blocking waiting without mutual exclusion.
[0076] Figure 4 is a flowchart of adding a service entity lock list according to an embodiment of the present application, which is described by a UML timing diagram as shown in Figure 4 The flow of adding a service entity lock list includes the following steps:
[0077] Step S401, the AOP agent adds a service entity lock list to the lock manager;
[0078] Step S402, the lock manager adds the service entity lock list to the blocking queue;
[0079] Step S403, the lock manager task thread acquires the service entity lock list from the blocking queue;
[0080] Step S404, the lock manager task thread checks whether the service entity lock list is mutually exclusive according to the lock management table;
[0081] Step S405, the lock record operation is performed inside the lock management table according to the mutual exclusion checking result.
[0082] In the embodiment, after step S405, the flow further includes:
[0083] Step S406, the checking result is returned;
[0084] Step S407, the AOP agent in the blocking waiting is woken up.
[0085] In the embodiment, the blocking queue is a general technology, and the asynchronous operation of adding a service entity lock list is realized by using the blocking queue. The lock manager has a separate task thread, which is responsible for acquiring the service entity list to be processed from the blocking queue, calling the lock management table to judge whether there is mutual exclusion, and calling the synchronization mechanism provided by the programming language or the operating system to wake up the AOP agent in the blocking waiting if there is no mutual exclusion.
[0086] Figure 5 is a flowchart of mutual exclusion checking operation according to an embodiment of the present application, which is described by a UML timing diagram as shown in Figure 5 The flow of mutual exclusion checking operation includes the following steps:
[0087] Step S501, mutual exclusion detection is initiated by the lock manager task thread, and steps S502 to S504 are cyclically executed to check the service entity lock list;
[0088] Step S502, according to the internal lock list, check whether the service entity lock in the service lock list exists or not;
[0089] When the judgment result is that it exists, execute steps S503 and S504.
[0090] Step S503, in the case of the judgment result is that it exists, record the mutual exclusion situation to the mutual exclusion table;
[0091] Step S504, record the check result as mutual exclusion;
[0092] After the loop ends, if the check result is not mutual exclusion, execute step S505.
[0093] Step S505, add the service entity lock list to the internal lock list.
[0094] Step S506, return the check result.
[0095] In the embodiment, the internal lock list is a list recording all the service entity locks currently being executed. The lock manager calls the internal lock list to check whether the service lock exists or not, if it exists, it indicates that there is mutual exclusion of service operation, then record the mutual exclusion situation in the mutual exclusion table, and mark the check result as mutual exclusion. If there is no mutual exclusion at all, record the service entity lock list into the internal lock list.
[0096] Figure 6 is the flowchart of releasing lock of the embodiment of the present application, described by the time sequence diagram of UML, as shown in Figure 6 The flow of releasing lock includes the following steps:
[0097] Step S601, the AOP agent sends the releasing lock signal to the lock manager;
[0098] Step S602, the lock manager adds the service entity lock list to be released to the blocking queue;
[0099] Step S603, the lock manager task thread gets the service entity lock list to be released from the blocking queue;
[0100] Step S604, the lock manager task thread sends the service entity lock list to the lock management table.
[0101] Specifically, the AOP agent can be in the service entity lock list of the agent.
[0102] In the embodiment, the AOP agent asynchronously calls the lock management to release the lock after the specific service operation ends.
[0103] The lock manager inserts the service entity lock list to be released into the blocking queue, and the lock manager task management thread calls the lock manager to release the service entity lock list.
[0104] Figure 7 is a flowchart of releasing a service entity lock list according to an embodiment of the present application, which is described by a UML sequence diagram, as shown in Figure 7 The flow of releasing a service entity lock list includes the following steps:
[0105] Step S701, as described above in step S604, the lock manager task thread sends a release service entity lock list to the lock management table;
[0106] Step S702, the lock management table calls an internal lock list to delete a record of the service entity lock list;
[0107] Step S703, the lock management table queries a waiting service entity lock list in a mutual exclusion table;
[0108] Step S704, the lock management table cyclically judges whether each waiting service entity lock list has other mutually exclusive service entity lock lists, and wakes up the waiting service entity lock list in the case of no other mutually exclusive waiting;
[0109] Step S705, the lock management table deletes the woken-up service entity lock list from the mutual exclusion table.
[0110] In this embodiment, the lock management table queries all other service entity lock lists waiting for it according to the release service entity lock list, cyclically judges whether the waiting service entity lock list has other mutually exclusive waiting, and wakes up the waiting AOP agent if there is no other mutually exclusive waiting. The AOP agent is woken up and calls a business processing thread to execute business processing.
[0111] According to another aspect of the present application, a business data processing apparatus is also provided, Figure 8 is a block diagram of a business data processing apparatus according to an embodiment of the present application, as shown in Figure 8 The apparatus includes:
[0112] An intercepting module 802 is configured to intercept a plurality of service requests, and create a plurality of service entity lock lists for the plurality of service requests, wherein each service request corresponds to a service entity lock list, and each service entity lock list includes a plurality of service entity locks, and the service entity lock is used to control a business processing thread;
[0113] A queue module 804 is configured to add the plurality of service entity lock lists to a blocking queue, and acquire a to-be-processed service entity lock list from the blocking queue;
[0114] The recording module 806 is configured to record the to-be-processed business entity lock list into an internal lock list or a mutual exclusion table, where the internal lock list is used to record a target business entity lock list currently being executed, the mutual exclusion table is used to record a business entity lock list mutually exclusive with the target business entity lock list, and the internal lock list and the mutual exclusion table contain one or more business entity lock lists.
[0115] The parallel processing module 808 is configured to perform parallel processing on all target business entity lock lists in the internal lock list.
[0116] In this embodiment, the intercepting module 802 is further configured to acquire a business data identifier of each piece of business data in the plurality of business requests respectively, and create the business entity lock list according to all business data identifiers in the plurality of business requests respectively, to obtain the plurality of business entity lock lists, where each business data identifier in the business entity lock list corresponds to a business entity lock.
[0117] In this embodiment, the queue module 804 is further configured to determine that the business entity lock list is a to-be-processed business entity lock list, and add the to-be-processed business entity lock list into the blocking queue in sequence.
[0118] In this embodiment, the recording module 806 further includes:
[0119] The mutual exclusion checking module is configured to perform mutual exclusion checking on the to-be-processed business entity lock list and the internal lock list.
[0120] The first recording sub-module is configured to record the to-be-processed business entity lock list into the mutual exclusion table in a case where the checking result is that there is mutual exclusion.
[0121] The second recording sub-module is configured to record the to-be-processed business entity lock list into the internal lock list in a case where the checking result is that there is no mutual exclusion.
[0122] In this embodiment, the mutual exclusion checking module is further configured to determine whether the to-be-processed business entity lock list and the internal lock list have the same business entity lock, determine that the checking result is that there is mutual exclusion in a case where the determination result is yes, and determine that the checking result is that there is no mutual exclusion in a case where the determination result is no.
[0123] In this embodiment, the parallel processing module 808 is further configured to wake up a business processing thread corresponding to each business entity lock in the all target business entity lock lists, and process corresponding business data through the business processing thread and return a business processing result.
[0124] In the embodiment, the queue module 804 is further configured to create a corresponding to-be-released service entity lock list for each of the plurality of target service entity lock lists that have been processed.
[0125] In the embodiment, the queue module 804 is further configured to add the plurality of to-be-released service entity lock lists to the blocking queue.
[0126] In the embodiment, the device further includes:
[0127] The release module is configured to acquire the to-be-released service entity lock list from the blocking queue, delete the target service entity lock list corresponding to the to-be-released service entity lock list in the internal lock list, and obtain an updated internal lock list.
[0128] In the embodiment, the mutual exclusion checking module is further configured to perform mutual exclusion checking on each service entity lock list in the mutual exclusion table and the updated internal lock list to determine whether there is mutual exclusion.
[0129] In the embodiment, the second recording sub-module is further configured to record the service entity lock list in the mutual exclusion table that does not have mutual exclusion to the updated internal lock list and delete it from the mutual exclusion table.
[0130] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is run by a processor to perform the steps in any of the above method embodiments.
[0131] In an example embodiment, the above computer readable storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0132] Embodiments of the present application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0133] In an example embodiment, the above electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0134] The specific examples in the embodiments can refer to the examples described in the above embodiments and example implementations, which will not be described herein again.
[0135] It should be apparent to those skilled in the art that the modules or steps of the application described above can be implemented with general computing devices, which can be centralized on a single computing device or distributed on a network of multiple computing devices, and which can be implemented with program codes executable by the computing devices, so that they can be stored in storage devices and executed by the computing devices, and in some cases, the steps shown or described can be executed in different orders than shown, or made into individual integrated circuit modules, or made into a single integrated circuit module. Thus, the present application is not limited to any particular combination of hardware and software.
[0136] The preferred embodiments of the present application described above are only used to explain the principles of the present application and not limit the present application. Any modification, equivalent replacement, improvement, etc. within the principles of the present application should be included in the protection scope of the present application.
Claims
1. A service data processing method characterized by, The method comprises: intercepting a plurality of service requests, and creating a plurality of service entity lock lists for the plurality of service requests, wherein each service request corresponds to a service entity lock list, and each service entity lock list comprises a plurality of service entity locks for controlling service processing threads; adding the plurality of service entity lock lists to a blocking queue, and obtaining a to-be-processed service entity lock list from the blocking queue; recording the to-be-processed service entity lock list to an internal lock list or a mutual exclusion table, wherein the internal lock list is used to record target service entity lock lists currently being executed, the mutual exclusion table is used to record service entity lock lists mutually exclusive with the target service entity lock lists, and the internal lock list and the mutual exclusion table contain one or more service entity lock lists; performing parallel processing on all target service entity lock lists in the internal lock list.
2. The method of claim 1, wherein, The method for creating a plurality of service entity lock lists for the plurality of service requests comprises: respectively obtaining service data identifiers of each piece of service data in the plurality of service requests; respectively creating the service entity lock lists according to all service data identifiers in the plurality of service requests to obtain the plurality of service entity lock lists, wherein each piece of service data identifier in the service entity lock list corresponds to a service entity lock.
3. The method of claim 1, wherein, The method for adding the plurality of service entity lock lists to a blocking queue comprises: determining that the service entity lock list is a to-be-processed service entity lock list; adding the to-be-processed service entity lock list to the blocking queue in sequence.
4. The method of claim 1, wherein, The method for recording the to-be-processed service entity lock list to an internal lock list or a mutual exclusion table comprises: performing mutual exclusion checking on the to-be-processed service entity lock list and the internal lock list; in the case of checking result of existing mutual exclusion, recording the to-be-processed service entity lock list to the mutual exclusion table; in the case of checking result of non-existing mutual exclusion, recording the to-be-processed service entity lock list to the internal lock list.
5. The method of claim 4, wherein, The method for performing mutual exclusion checking on the to-be-processed service entity lock list and the internal lock list comprises: judging whether the to-be-processed service entity lock list and the internal lock list have the same service entity lock; in the case of judging result of yes, determining that the checking result is existing mutual exclusion; in the case of judging result of no, determining that the checking result is non-existing mutual exclusion.
6. The method of claim 1, wherein, The method for performing parallel processing on all target service entity lock lists in the internal lock list comprises: waking up service processing threads corresponding to each service entity lock in the all target service entity lock lists; processing corresponding service data by the service processing threads and returning service processing results.
7. The method of claim 1, wherein, After performing parallel processing on all target service entity lock lists in the internal lock list, the method further comprises: creating corresponding to-be-released service entity lock lists for a plurality of target service entity lock lists that have been processed; adding the plurality of to-be-released service entity lock lists to the blocking queue.
8. The method of claim 7, wherein, The method further comprises: obtaining the to-be-released service entity lock lists from the blocking queue; delete the target business entity lock list corresponding to the business entity lock list to be released from the internal lock list, to obtain an updated internal lock list; perform mutual exclusion checking between each business entity lock list in the mutual exclusion table and the updated internal lock list, to determine whether there is mutual exclusion; record the business entity lock list without mutual exclusion in the mutual exclusion table into the updated internal lock list, and delete it from the mutual exclusion table.
9. A service data processing apparatus characterized by comprising: The apparatus comprises: an intercepting module configured to intercept a plurality of service requests and create a plurality of business entity lock lists for the plurality of service requests, wherein each service request corresponds to a business entity lock list, and each business entity lock list comprises a plurality of business entity locks used to control a service processing thread; a queue module configured to add the plurality of business entity lock lists to a blocking queue and obtain a business entity lock list to be processed from the blocking queue; a recording module configured to record the business entity lock list to be processed into an internal lock list or a mutual exclusion table, wherein the internal lock list is used to record a target business entity lock list currently being executed, the mutual exclusion table is used to record a business entity lock list mutually exclusive with the target business entity lock list, and the internal lock list and the mutual exclusion table contain one or more business entity lock lists; a parallel processing module configured to perform parallel processing on all target business entity lock lists in the internal lock list.
10. A computer-readable storage medium having stored therein a computer program, wherein, The computer program is run by a processor to perform the method in any one of claims 1 to 8. 11.An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to perform the method in any one of claims 1 to 8.
Citation Information
Patent Citations
Business data processing method and device, storage medium and electronic device
CN111784329A
Operating systems, software, applications (apps) and services for receiving, processing and storing a plurality of commands bearing biometric inputs
US10621318B1