Deadlock optimization methods, devices, equipment and media

By binding the same key to insurance applications and processing them sequentially, the problem of frequent deadlocks in batch data processing was solved, achieving more efficient system stability and business continuity.

CN123114784APending Publication Date: 2026-11-17CHINA PING AN PROPERTY INSURANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611486888.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-22
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

When processing large volumes of data, especially in business systems in the fintech and healthcare sectors, deadlocks can easily be triggered, leading to issues with business stability and continuity.

Method used

By obtaining the notification number of the notification form, the corresponding lock key of the insurance policy is determined, and the policy is processed in the target order. At least two threads are used to obtain the insurance policy and the lock key in turn, ensuring that the lock key is held by only one thread at any given time, thus avoiding circular waiting and lock conflicts.

Benefits of technology

It reduces the probability of deadlock when processing batch data, improves system stability and processing efficiency, and reduces the risk of deadlock caused by inconsistent lock order.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114784A_ABST
    Figure CN123114784A_ABST
Patent Text Reader

Abstract

This application relates to the field of data processing technology, applicable to policy update scenarios in fintech and healthcare, and discloses a deadlock optimization method, apparatus, device, and medium, including: obtaining the notification number of a notification and obtaining at least two insurance policies corresponding to the notification; wherein the notification is used to instruct the execution of a target operation on the insurance policies; determining the notification number as the lock key for each insurance policy corresponding to the notification; sorting the insurance policies to obtain a target insurance policy list; wherein the insurance policies in the target insurance policy list are arranged in a target order; using at least two threads, sequentially obtaining insurance policies and their corresponding lock keys from the target insurance policy list in the target order; for each thread, in response to the thread holding the lock key and obtaining an insurance policy, the thread performs the target operation on the insurance policy. This application can reduce the probability of deadlock when processing batch data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, applicable to the fields of fintech and healthcare, and particularly to a deadlock optimization method, apparatus, device, and medium. Background Technology

[0002] In data processing, it is often necessary to perform batch operations on multiple data sets. For example, in the insurance business scenario of fintech, it is frequently necessary to perform batch cancellation operations on multiple insurance policies from the same batch within the financial insurance business system. Another example is in the medical insurance business scenario of healthcare, where it is necessary to perform batch update operations on multiple medical insurance policies.

[0003] Currently, processing batch data can easily trigger deadlocks. For example, in the insurance business scenario of fintech, when processing the cancellation of batches of pending premium payment insurance applications, a serial traversal approach is typically used, that is, different threads sequentially execute the cancellation operation for each batch of applications. However, multiple applications within the same batch may overlap, and currently, multiple threads are prone to processing the same application simultaneously, leading to frequent deadlocks. Especially in scenarios with large-volume cancellations, the probability of deadlocks increases significantly, affecting business stability. Summary of the Invention

[0004] This application provides a deadlock optimization method, apparatus, device, and medium to solve the technical problem of deadlock easily triggered when processing batch data, aiming to reduce the deadlock probability when processing batch data.

[0005] Firstly, a deadlock optimization method is provided, including: Obtain the notification number of the notification and obtain at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the execution of the target operation on the insurance policies; The notification number is used as the key to lock each insurance policy corresponding to the notification; The application forms are sorted to obtain a target application form list; wherein the application forms in the target application form list are arranged in the target order. At least two threads retrieve the insurance application forms and their corresponding lock keys from the target application form list in target order; wherein, the lock key is held by only one thread at any given time. For each thread, in response to the thread holding the lock key and the thread acquiring the insurance policy, the thread performs the target operation on the insurance policy.

[0006] Secondly, a deadlock optimization device is provided, comprising: The data acquisition module is used to acquire the notification number of the notification and acquire at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the execution of a target operation on the insurance policy; The lock key determination module is used to determine the notification number as the lock key of each insurance policy corresponding to the notification; The sorting module is used to sort the various insurance applications to obtain a target insurance application list; wherein the insurance applications in the target insurance application list are arranged in a target order. The thread acquisition module is used to acquire the insurance application and the corresponding lock key of the insurance application in the target application list in the target order by using at least two threads; wherein the lock key is held by only one thread at any given time. The target operation module is configured to perform the target operation on the insurance policy through the thread in response to the thread holding the lock key and the thread obtaining the insurance policy.

[0007] Thirdly, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the above-described method.

[0008] Fourthly, a computer-readable storage medium is provided, which stores a computer program that, when executed by a processor, implements the steps of the above-described method.

[0009] The deadlock optimization methods, devices, equipment, and media described above can achieve the following: Obtain the notification number of the notification slip and at least two corresponding insurance policies. Then, use the notification number as the lock key for each insurance policy corresponding to the notification slip. This allows all insurance policies under the same notification slip (i.e., insurance policies in the same batch) to be bound to the same lock key. The insurance policies are sorted to obtain a target insurance policy list. At least two threads then sequentially retrieve insurance policies and their corresponding lock keys from this list in the target order. This ensures that all threads retrieve insurance policies and lock keys in the target order, guaranteeing a globally consistent locking order and reducing the risk of circular wait deadlocks caused by inconsistent lock orders. Furthermore, only one thread holds the lock key at a time, ensuring that multiple insurance policies in the same batch are not operated on by multiple threads simultaneously, reducing the risk of lock conflicts caused by multiple threads competing for the same insurance policy. By holding the lock and acquiring the insurance application before performing the target operation on it, we can ensure that the thread processes the insurance applications in order while holding the exclusive lock. This reduces the probability of deadlock when processing batch data. Attached Figure Description

[0010] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0011] Figure 1 This is a schematic diagram of an application environment for a deadlock optimization method according to an embodiment of this application; Figure 2 This is a flowchart illustrating a deadlock optimization method in one embodiment of this application; Figure 3 yes Figure 2 A schematic diagram of a specific implementation of step S101; Figure 4 This is another flowchart illustrating the deadlock optimization method in one embodiment of this application; Figure 5 yes Figure 2 A flowchart illustrating another specific implementation of step S101; Figure 6 yes Figure 2 A schematic diagram of a specific implementation of step S104; Figure 7 yes Figure 6 A schematic diagram of a specific implementation of step S502; Figure 8 This is another flowchart illustrating the deadlock optimization method in one embodiment of this application; Figure 9 This is a schematic diagram of a deadlock optimization device in one embodiment of this application; Figure 10 This is a schematic diagram of the structure of a computer device according to one embodiment of this application; Figure 11 This is another structural schematic diagram of a computer device in one embodiment of this application. Detailed Implementation

[0012] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0013] The deadlock optimization method provided in this application embodiment can be applied to, for example, Figure 1In this application environment, the client communicates with the server via a network. The server can receive the notification number corresponding to the notification order and multiple insurance applications from the client, and perform multi-threaded batch processing on the multiple insurance applications based on the notification number, such as canceling orders. Then, the server can feed back the operation results of the insurance applications to the client. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The following detailed description of specific embodiments further illustrates this application.

[0014] Please see Figure 2 As shown, Figure 2 A flowchart illustrating the deadlock optimization method provided in this application embodiment includes the following steps: S101: Obtain the notification number of the notification and obtain at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the target operation to be performed on the insurance policies; S102: The notification number is used as the key for each insurance policy corresponding to the notification; S103: Sort the various insurance applications to obtain a target insurance application list; wherein, the insurance applications in the target insurance application list are arranged in the target order; S104: Using at least two threads, retrieve insurance applications and their corresponding lock keys from the target application list in target order; wherein, the lock key is held by only one thread at any given time. S105: For each thread, in response to the thread holding the lock and the thread obtaining the insurance policy, the thread performs the target operation on the insurance policy.

[0015] The beneficial effects of this application's embodiments include, but are not limited to: obtaining the notification number of the notification and at least two insurance policies corresponding to the notification, and then determining the notification number as the lock key for each insurance policy corresponding to the notification, thus enabling the binding of the same lock key to all insurance policies under the same notification (i.e., insurance policies in the same batch). Sorting is performed on each insurance policy to obtain a target insurance policy list, and at least two threads sequentially retrieve insurance policies and their corresponding lock keys from the target insurance policy list in the target order. This ensures that all threads retrieve insurance policies and lock keys in the target order, guaranteeing a globally consistent locking order for insurance policies and reducing the risk of circular waiting deadlocks caused by inconsistent lock orders; furthermore, only one thread holds the lock key at any given time, ensuring that multiple insurance policies in the same batch are not operated on by multiple threads simultaneously, reducing the risk of lock conflicts caused by multiple threads competing for the same insurance policy. By performing the target operation on the insurance policy only after the thread holds the lock key and obtains the insurance policy, it ensures that the thread processes the insurance policies in order while holding an exclusive lock key. This can reduce the probability of deadlock when processing batches of data.

[0016] In step S101 of some embodiments, the notification slip is a document indicating that a target operation needs to be performed on the insurance policy. The target operation may include operations such as updating or canceling. For example, in the insurance business scenario of fintech, the notification slip may be a document issued by a financial insurance company to indicate changes or cancellations of the financial insurance policy; for instance, the notification slip may instruct the cancellation of the policy. As another example, in the medical insurance business scenario of healthcare, the notification slip may be a document issued by a medical insurance company to indicate changes or cancellations of the medical insurance policy. It should be noted that the notification slip number refers to the unique identifier of the notification slip. At least two insurance policies corresponding to a notification slip refer to insurance policies recorded in the same notification slip that both require the target operation, i.e., multiple insurance policies in the same batch. In some embodiments, the insurance policies corresponding to the notification slip are insurance policies that paid in the same batch during batch cancellation.

[0017] In some embodiments, the deadlock optimization method provided in this application can be applied to intelligent business systems in various application scenarios. Intelligent business systems are typically implemented through a server that can receive notification orders in real time. For example, in insurance business systems within the insurance application field, batch cancellation operations are a high-frequency scenario, often requiring the insurance business system to perform batch cancellation operations on multiple insurance policies in the same batch. Specifically, the server can be an insurance company's server.

[0018] In step S102 of some embodiments, the lock key refers to the value of the distributed lock. It should be noted that a distributed lock is a technical means of controlling synchronized access to shared resources between distributed systems. It is used to coordinate mutual exclusion access to resources by different systems (or threads), prevent data conflicts, and ensure consistency. Specifically, the lock key (also called the lock key) can be a unique value of the Redis distributed lock. It should be noted that strongly binding the lock key to a business entity (such as an insurance policy) can avoid accidental locking and excessive locking.

[0019] In step S103 of some embodiments, the target insurance application list refers to the list obtained after sorting the various insurance applications. Specifically, the order of sorting can be either descending or ascending. In some embodiments, the insurance applications can be sorted according to their application numbers in the target order. In another embodiment, the applications can also be sorted according to other numbers or parameters of the insurance applications; this application does not limit this approach.

[0020] In some embodiments, individual insurance policies can be sorted using an artificial intelligence (AI) model. For example, the AI ​​model could be a Large Language Model (LLM). It should be noted that a LLM includes embedding layers and Transformer layers, and is trained in a supervised manner on large-scale natural language inference datasets and semantic similarity datasets. The LLM learns sentence-level semantic representations through contrastive learning, with the training objective of maximizing the similarity of positive sample pairs (sentences that are semantically similar or inferentially related) and minimizing the similarity of negative sample pairs (sentences that are semantically unrelated).

[0021] In step S104 of some embodiments, it should be noted that one of the necessary conditions for deadlock is "circular wait". For example, suppose there are threads T1 and T2, and resources R1 and R2; if thread T1 holds resource R1 and waits for resource R2, and thread T2 holds resource R2 and waits for resource R1, then it is a circular wait. To address the above situation, this embodiment of the application ensures that all threads acquire lock keys in the same target order by performing a globally consistent sorting (e.g., ascending order) on insurance applications in the same batch. Therefore, even if multiple threads process different insurance applications corresponding to the notification form simultaneously, a circular wait will not occur because the lock acquisition order within each notification form is fixed.

[0022] In some embodiments, it should be noted that in current insurance business systems, when processing the cancellation of batches of pending premium payment insurance applications, a serial traversal approach is typically used: for each application, the cancellation interface is called sequentially, first querying its associated notification number, then using the notification number to look up the list of all pending cancellation applications under that notification, and finally clearing the notification records of these applications. This process has serious concurrency defects. For example, when multiple applications in the same batch (such as application A and application B) belong to the same notification C, the processing logic of application A and application B highly overlaps. For instance, after thread T1 queries notification C, it finds the corresponding application A and application B and performs a database update operation to clear their records; at the same time, thread T2 also queries the same notification C, similarly finds application A and application B, and attempts to perform the same clearing operation. Since the two threads update the same batch of data rows simultaneously, and the update order is inconsistent, it is easy to trigger database row lock contention, leading to frequent deadlocks. Especially in scenarios involving large-scale order cancellations, the probability of deadlock increases significantly, leading to transaction rollbacks, interface timeouts, and a decline in user experience, which seriously affects system stability and business continuity.

[0023] In step S105 of some embodiments, a thread can only perform the target operation on the insurance policy corresponding to the lock key when it holds the lock key. Since the lock key can only be held by one thread at a time, this supports allowing only one thread to process all cancellation operations under a specific notification at the same time, eliminating circular wait conditions.

[0024] In some embodiments, the target operation on the insurance policy corresponding to the lock key can be performed by calling the financial cancellation interface of the insurance business system. In some embodiments, if the financial cancellation interface of the insurance business system returns an error message (such as the inability to perform the cancellation operation normally), business exception information with error details can be thrown to trigger a transaction rollback.

[0025] In some embodiments, such as Figure 3 As shown, step S101, which is to obtain the notification number of the notification, includes the following steps: S201: Perform a request to retrieve the notification number based on the notification order, and obtain the notification number retrieval result; S202: If the result of obtaining the order number indicates that the order number of the notification order has been obtained, determine whether the value of the order number is empty; S203: If the notification number is not empty, execute the step of determining the notification number as the lock key of each insurance policy corresponding to the notification.

[0026] The advantage of this embodiment lies in that it obtains the document number by performing a request operation based on the notification order, and then judges the result of the document number retrieval. This allows for validity verification of the document number retrieval process, avoiding the use of invalid or incorrect document numbers due to retrieval failure. If the document number retrieval result indicates that the notification order number of the notification order has been obtained, it is further determined whether the value of the notification order number is empty. If the value of the notification order number is not empty, the step of determining the notification order number as the lock key is executed. This ensures that only valid and non-empty document numbers are used as lock keys, thereby avoiding multiple insurance policies failing to correctly bind to the same lock key due to an empty or invalid lock key, or threads holding invalid lock keys causing locking exceptions, thus reducing the risk of thread contention and deadlock caused by unreliable lock keys. Therefore, it can further reduce the probability of deadlock when processing batch data.

[0027] In step S201 of some embodiments, the order number acquisition result refers to whether the order number of the notification order was successfully obtained. Specifically, the order number acquisition result can be either that the order number of the notification order was obtained, or that the order number of the notification order was not obtained.

[0028] In some embodiments, the latest notification number corresponding to the notification can be obtained by querying the database.

[0029] In some embodiments, if the order number retrieval result indicates that the order number of the notification order was not obtained, i.e., the lock acquisition failed, an audit log can be recorded immediately and the process can be terminated without performing any subsequent operations. This reduces unnecessary resource consumption and avoids invalid lock holding. For example, the audit log may include parameters such as thread ID and the current timestamp.

[0030] In step S202 of some embodiments, after the order number acquisition result indicates that the order number of the notification order has been successfully obtained, it is necessary to further determine whether the value of the notification order number is empty. Determining whether the value is empty is to verify whether the obtained notification order number is valid, and to avoid subsequent steps using an empty value as a lock key to bind to the insurance policy due to obtaining an empty or invalid value, thereby causing a locking logic error.

[0031] In step S203 of some embodiments, if the notification number is not empty, then the step of determining the notification number as the lock key for each insurance application corresponding to the notification is executed. This allows the insurance application to be bound to a valid and non-empty lock key.

[0032] In some embodiments, if the notification number is empty, no further operations are performed.

[0033] In some embodiments, such as Figure 4 As shown, after step S101, the deadlock optimization method further includes the following steps: S301: Business status for obtaining notification orders; S302: If the business status belongs to the preset target status, execute the step of determining the notification number as the lock key of each insurance policy corresponding to the notification; wherein, the target status includes the policy already issued status.

[0034] The advantage of this embodiment lies in obtaining the business status of the notification and determining whether it belongs to a preset target status (including the status of an already opened policy). Only when the business status belongs to the target status is the notification number determined as the locking key for each insurance policy. This ensures that subsequent locking key binding steps are only executed when the notification is in a valid business status, thereby avoiding unnecessary locking operations on insurance policies corresponding to invalid or closed notifications and reducing the ineffective use of lock resources. By reducing thread contention and waiting caused by invalid locking keys, the probability of deadlock when processing batch data is reduced.

[0035] In step S301 of some embodiments, the business status of the notification order is the current order status. For example, the business status of the notification order can be either "order issued" or "order not issued". In another embodiment, the business status of the notification order may also include other statuses, and is not limited thereto.

[0036] In step S302 of some embodiments, the business status of the notification order is checked to see if it is the target status (order has been issued). If it is not the target status, the lock resource is released immediately to reduce invalid lock contention and improve the overall throughput of the insurance business system.

[0037] In some embodiments, such as Figure 5 As shown, step S101, which involves obtaining at least two insurance policies corresponding to the notification slip, specifically includes the following steps: S401: Based on the preset list of associated insurance policies, perform a policy query on the notification to obtain the initial list of insurance policies corresponding to the notification; wherein, the list of insurance policies includes at least two insurance policies; S402: If the initial insurance application list is empty, generate an exception log based on the notification number and display the exception log to the user.

[0038] The advantage of this embodiment is that it queries the notification order based on a preset list of associated insurance policies to obtain the initial list of insurance policies corresponding to the notification order. This allows for the identification of multiple insurance policies associated with the same notification order, i.e., insurance policies from the same batch. If the initial list of insurance policies is empty, an exception log is generated based on the notification order number and displayed to the user. This enables the user to receive an exception alert when no insurance policy associated with the notification order is found, thereby improving the reliability of the deadlock optimization method.

[0039] In step S401 of some embodiments, the initial application list refers to a list of application forms corresponding to the notification form. In some embodiments, the initial application list may be empty.

[0040] In step S402 of some embodiments, if the initial insurance application list is empty, the processing of insurance applications can be exited after generating the exception log, thereby intercepting operations without actual business significance in advance and reducing the invalid occupation of the database and interfaces of the business system. In some embodiments, the exception log may include the number of associated insurance applications, notification number, etc. Specifically, the exception log is also called the audit log. In some embodiments, the audit log may record different data at different stages. For example, in the lock acquisition stage, the audit log may record thread ID, request parameters, acquisition time, etc. In the business processing stage, the audit log may record notification status, number of associated insurance applications, interface response status, etc. In the lock release stage, the audit log may record the final result, total time consumption, exception information, etc. In the monitoring indicator stage, the audit log may record lock waiting time, average processing time, failure rate, etc.

[0041] In some embodiments, such as Figure 6 As shown, in step S104, which involves retrieving insurance applications and their corresponding lock keys from the target application list in target order using at least two threads, the specific steps include the following: S501: If the number of insurance policies is greater than or equal to the preset number threshold, the target insurance policy list is segmented into sequences to obtain at least two insurance policy sub-sequences. S502: Using at least two threads, retrieve insurance applications sequentially from each insurance application subsequence in the target order, and retrieve the lock key corresponding to the insurance application.

[0042] The advantage of this embodiment lies in that, when the number of insurance applications exceeds or equals a preset threshold, the target insurance application list is sequentially divided into at least two insurance application sub-sequences. Then, at least two threads sequentially retrieve insurance applications from each insurance application sub-sequence in the target order and acquire the corresponding lock keys. This breaks down a long transaction with an excessive number of insurance applications (e.g., thousands) into smaller transactions with fewer applications (e.g., only dozens). Then, by using multiple threads to sequentially retrieve insurance applications and their corresponding lock keys from each insurance application sub-sequence in the target order, concurrency processing capabilities are improved, thereby enhancing the stability of the deadlock optimization method.

[0043] In step S501 of some embodiments, the preset quantity threshold is a threshold used to determine whether there are too many insurance application data in the same batch. The quantity threshold can characterize the maximum number of insurance applications that can be processed in each batch. For example, the preset quantity threshold can be 50. The quantity threshold can also be set or updated to other values ​​to balance the size of a single transaction with processing efficiency.

[0044] In step S502 of some embodiments, if the number of insurance applications is greater than or equal to a preset threshold, the target insurance application list is segmented to obtain at least two insurance application subsequences. It should be noted that the number of insurance applications in each subsequence is less than or equal to the threshold. In this way, a long transaction that would originally require locking thousands of rows of database rows (i.e., the number of insurance applications) in the insurance business system is broken down into multiple smaller transactions that only lock dozens of rows. This reduces the impact of long transactions on the database connection pool of the insurance business system and improves the concurrent processing capability of the insurance business system.

[0045] In some embodiments, such as Figure 7 As shown, step S502, which involves obtaining the lock key corresponding to the insurance application, specifically includes the following steps: S601: The time when the request to obtain the lock key corresponding to the insurance policy is sent is determined as the start time. The timer starts from the start time and ends when the lock key is obtained, thus obtaining the lock key acquisition time. S602: If the lock acquisition time is greater than or equal to the preset lock timeout reading time threshold, send a lock acquisition timeout error message to the user.

[0046] The advantage of this embodiment is that by defining the moment when the request to acquire the lock key corresponding to the insurance policy is sent as the start time, and starting the timer from the start time and ending the timer when the lock key is acquired, the lock key acquisition time can be obtained. This allows for precise quantification of the time a thread waits for the lock key. When the lock key acquisition time is greater than or equal to a preset lock timeout read time threshold, a lock acquisition timeout exception message is sent to the user. This can promptly expose the abnormal state of threads being blocked for a long time due to lock contention, preventing threads from getting stuck in deadlocks by waiting for the lock key indefinitely, and preventing permanent lock occupancy due to abnormal scenarios such as service downtime or network partitions, thereby reducing the probability of deadlocks when processing batch data.

[0047] In step S601 of some embodiments, the start time is the moment when the request to acquire the lock key begins. The lock key acquisition duration refers to the time from the start time to the successful acquisition of the lock key.

[0048] In step S602 of some embodiments, the timeout exception notification can be sent to the user via SMS, email, pop-up notification, or other means, but is not limited to these. For example, the timeout exception notification can be an exception log. Specifically, the exception log can record data such as thread ID, request parameters, and acquisition time.

[0049] In some embodiments, the lock timeout period can be preset by reading the configuration item to obtain the lock timeout threshold. Specifically, the lock timeout threshold can be 5 seconds. It should be noted that the lock timeout threshold is greater than a preset security duration threshold, where the security duration threshold characterizes the time taken for business operations to be performed on the database containing the insurance policy. This avoids the lock timeout threshold being too short, reducing the risk of lock failure. Specifically, the security duration threshold can be set based on the average business processing time. For example, assuming the average processing time for financial interface calls is 2 seconds and the average processing time for database updates is 1 second, then the average business processing time is 3 seconds.

[0050] In some embodiments, such as Figure 8 As shown, before step S602, the deadlock optimization method may further include the following steps: S701: Calculate the average lock key acquisition time based on the average lock key acquisition time corresponding to each insurance policy; S702: Update the preset lock timeout reading time threshold based on the average lock key acquisition time to obtain the updated safe time, and determine the updated safe time as the lock timeout reading time threshold.

[0051] The advantage of this embodiment lies in that it calculates the average lock key acquisition time based on the average acquisition time corresponding to each insurance policy, and then updates the preset lock timeout read time threshold based on the average lock key acquisition time to obtain an updated safe time, which is then determined as the lock timeout read time threshold. This allows for dynamic adjustment of the timeout judgment standard based on the actual time a thread waits for the lock key, enabling the lock timeout read time threshold to adaptively reflect the real-time state of lock contention. Furthermore, this avoids frequent false timeouts due to a fixed threshold being too small or deadlock detection delays due to a fixed threshold being too large, thereby reducing the probability of deadlock when processing batch data.

[0052] In step S701 of some embodiments, the average lock acquisition time is calculated by averaging the lock acquisition times corresponding to each insurance policy. The average lock acquisition time is used to characterize the average time for a thread to acquire locks for each insurance policy.

[0053] In step S702 of some embodiments, the updated security duration is the duration obtained after updating a preset lock timeout read time threshold. Specifically, in some embodiments, the updated security duration can be obtained by weighted summing the average lock key acquisition duration and the original lock timeout read time threshold. In another embodiment, for example, the original average lock key acquisition duration (e.g., 3 seconds) can be obtained. Assuming the current average lock key acquisition duration is 8 seconds, meaning the average lock key acquisition duration of the notification has changed from 3 seconds to 8 seconds, the change in the average lock key acquisition duration is 5 seconds. Assuming the original lock timeout read time threshold is 5 seconds, the original lock timeout read time threshold and the change in the average lock key acquisition duration can be added together, that is, the lock timeout read time threshold is adjusted from 5 seconds to 10 seconds to obtain the updated security duration.

[0054] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0055] In one embodiment, a deadlock optimization apparatus is provided, which corresponds one-to-one with the deadlock optimization methods described in the above embodiments. For example... Figure 9 As shown, the deadlock optimization device includes a data acquisition module 801, a lock / key determination module 802, a sorting processing module 803, a thread acquisition module 804, and a target operation module 805. Detailed descriptions of each functional module are as follows: The data acquisition module 801 is used to acquire the notification number of the notification and acquire at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the target operation to be performed on the insurance policies; The key determination module 802 is used to determine the notification number as the key for each insurance policy corresponding to the notification; The sorting module 803 is used to sort the various insurance applications to obtain a target insurance application list; wherein, the insurance applications in the target insurance application list are arranged in the target order. The thread acquisition module 804 is used to acquire insurance applications and their corresponding lock keys from the target insurance application list in target order through at least two threads; wherein the lock key is held by only one thread at a time. The target operation module 805 is used to perform target operations on the insurance policy by each thread in response to the thread holding the lock and the thread obtaining the insurance policy.

[0056] This application provides a deadlock optimization device. It obtains the notification number of a notification and at least two corresponding insurance policies. The notification number is then used as the lock key for each insurance policy corresponding to the notification, allowing all insurance policies under the same notification (i.e., policies in the same batch) to be bound to the same lock key. The insurance policies are sorted to obtain a target insurance policy list. At least two threads sequentially retrieve insurance policies and their corresponding lock keys from this list in the target order. This ensures that all threads acquire insurance policies and lock keys in the target order, guaranteeing a globally consistent locking order and reducing the risk of circular wait deadlocks caused by inconsistent lock order. Furthermore, only one thread holds the lock key at a time, ensuring that multiple insurance policies in the same batch are not operated on by multiple threads simultaneously, reducing the risk of lock conflicts caused by multiple threads competing for the same insurance policy. By holding the lock key and acquiring the insurance policy before performing the target operation, it ensures that threads process insurance policies sequentially while holding an exclusive lock key. This can reduce the probability of deadlock when processing batches of data.

[0057] Specific limitations regarding the deadlock optimization apparatus can be found in the limitations of the deadlock optimization method described above, and will not be repeated here. Each module in the aforementioned deadlock optimization apparatus can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in hardware or independently of the processor in the computer device, or stored in software in the memory of the computer device, so that the processor can call and execute the operations corresponding to each module.

[0058] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, the computer device includes a processor, memory, network interface, and database connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and database. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a deadlock optimization method on the server side.

[0059] In one embodiment, a computer device is provided, which may be a client, and its internal structure diagram may be as follows: Figure 11As shown, the computer device includes a processor, memory, network interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with an external server via a network connection. When executed by the processor, the computer program implements the client-side functions or steps of a deadlock optimization method.

[0060] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the following steps of a deadlock optimization method: Obtain the notification number of the notification and at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the target operation to be performed on the insurance policies; The notification number is used as the key to lock each insurance policy corresponding to the notification; The application forms are sorted to obtain a target application form list; the application forms in the target application form list are arranged in the target order. Using at least two threads, retrieve insurance applications and their corresponding lock keys from the target application list in target order; wherein, the lock key is held by only one thread at a time. For each thread, in response to the thread holding the lock and obtaining the insurance policy, the thread performs the target operation on the insurance policy.

[0061] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the following steps of a deadlock optimization method: Obtain the notification number of the notification and at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the target operation to be performed on the insurance policies; The notification number is used as the key to lock each insurance policy corresponding to the notification; The application forms are sorted to obtain a target application form list; the application forms in the target application form list are arranged in the target order. Using at least two threads, retrieve insurance applications and their corresponding lock keys from the target application list in target order; wherein, the lock key is held by only one thread at a time. For each thread, in response to the thread holding the lock and obtaining the insurance policy, the thread performs the target operation on the insurance policy.

[0062] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to the relevant descriptions on the server side and client side in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.

[0063] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may 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), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0064] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is used as an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0065] It should be noted that any AI models, software tools, or components not belonging to this company appearing in the embodiments of this application are merely illustrative examples and do not represent actual use. All user personal information involved in the embodiments of this application has been authorized (with the knowledge and consent) by the relevant parties or has been fully authorized by all parties, and the executing entity may obtain it through various legal and compliant means. The collection, storage, use, processing, transmission, provision, and disclosure of the information, data, and signals involved all comply with relevant laws and regulations and do not violate public order and good morals.

[0066] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A deadlock optimization method, characterized by, include: Obtain the notification number of the notification and obtain at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the execution of the target operation on the insurance policies; The notification number is used as the key to lock each insurance policy corresponding to the notification; The application forms are sorted to obtain a target application form list; wherein the application forms in the target application form list are arranged in the target order. At least two threads retrieve the insurance application forms and their corresponding lock keys from the target application form list in target order; wherein, the lock key is held by only one thread at any given time. For each thread, in response to the thread holding the lock key and the thread acquiring the insurance policy, the thread performs the target operation on the insurance policy.

2. The method of claim 1, wherein, The step of retrieving the insurance application forms and the corresponding lock keys from the target insurance application list in target order through at least two threads includes: If the number of insurance applications is greater than or equal to a preset number threshold, the target insurance application list is segmented into at least two insurance application sub-sequences. Using at least two threads, the insurance application forms are retrieved sequentially from each of the insurance application form sub-sequences in the target order, and the lock key corresponding to the insurance application form is obtained.

3. The method of claim 2, wherein, The step of obtaining the lock key corresponding to the insurance policy includes: The time when the request to obtain the lock key corresponding to the insurance policy is sent is determined as the start time. The timer starts from the start time and ends when the lock key is obtained, thus obtaining the lock key acquisition time. If the lock key acquisition time is greater than or equal to the preset lock timeout reading time threshold, a lock acquisition timeout error message will be sent to the user.

4. The method of claim 3, wherein, Before sending a lock acquisition timeout error message to the user if the lock key acquisition time is greater than or equal to a preset lock timeout read time threshold, the method further includes: The average lock key acquisition time is calculated by averaging the lock key acquisition time corresponding to each of the insurance policies. The preset lock timeout reading time threshold is updated based on the average duration of the lock key acquisition to obtain the updated safe duration, and the updated safe duration is determined as the lock timeout reading time threshold.

5. The method according to any one of claims 1 to 4, characterized in that, The notification number for obtaining the notification includes: Perform a request to retrieve the notification number based on the notification order, and obtain the notification number retrieval result; If the result of obtaining the order number indicates that the order number of the order has been obtained, determine whether the value of the order number is empty; If the notification number is not empty, the step of determining the notification number as the lock key of each insurance policy corresponding to the notification is executed.

6. The method according to any one of claims 1 to 4, characterized in that, After obtaining the notification number, the method further includes: Obtain the business status of the notification form; If the business status belongs to a preset target status, the step of determining the notification number as the lock key of each of the insurance policies corresponding to the notification is executed; wherein, the target status includes the policy already issued status.

7. The method according to any one of claims 1 to 4, wherein The process of obtaining at least two insurance policies corresponding to the notification includes: The notification is queried according to a preset list of associated insurance policies to obtain an initial list of insurance policies corresponding to the notification; wherein the list of insurance policies includes at least two insurance policies. If the initial insurance application list is empty, an exception log is generated based on the notification number and displayed to the user.

8. A deadlock optimization apparatus, characterized by, include: The data acquisition module is used to acquire the notification number of the notification and acquire at least two insurance policies corresponding to the notification; wherein, the notification is used to instruct the execution of a target operation on the insurance policy; The lock key determination module is used to determine the notification number as the lock key of each insurance policy corresponding to the notification; The sorting module is used to sort the various insurance applications to obtain a target insurance application list; wherein the insurance applications in the target insurance application list are arranged in a target order. The thread acquisition module is used to acquire the insurance application and the corresponding lock key of the insurance application in the target application list in the target order by using at least two threads; wherein the lock key is held by only one thread at any given time. The target operation module is configured to perform the target operation on the insurance policy through the thread in response to the thread holding the lock key and the thread obtaining the insurance policy.

9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 7.