Order inventory updating method and system for lock-free concurrent transaction processing

Through lock-free concurrent transaction processing method, the inventory update record table is created and timed tasks are used to replace the lock-up update operation, which solves the system delay and resource waste problems in high concurrency environments and achieves efficient order inventory updates.

CN120336338APending Publication Date: 2025-07-18SHANDONG INSPUR DIGITAL BUSINESS TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510353784.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-25
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

In the high concurrency environment, when using locking strategies or message queue serialization processing in the prior art, there are problems such as system throughput drop, response delay increases and server resource waste, making it difficult to balance performance and user experience.

Method used

The lock-free concurrent transaction processing method is adopted, and the inventory update record table is created and the reserved inventory operation and compensation logic is performed using two timing tasks, instead of the lock-up update operation, and the lock-free processing is achieved using the INSERT operation instead of the UPDATE operation.

Benefits of technology

It effectively solves the problem of shared resource competition, reduces system latency and resource waste, improves system throughput and user experience, and has small changes and is easy to implement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120336338A_ABST
    Figure CN120336338A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of database transaction processing, and particularly provides a lock-free concurrent transaction processing order inventory updating method and system, and the method comprises the steps: firstly, creating a table which stores reserved inventory information of added commodities, and the table name is an inventory updating record table; original order inventory record updating information is stored in an inventory updating record table, then two timed tasks need to be started, one timed task is used for executing the operation of increasing the reserved inventory of commodities, and the other timed task scans to reach the maximum compensation frequency. Compared with the prior art, the method and the device have the advantages that the shared resources can be destroyed by replacing a locking updating operation with a lock-free newly-added operation, the defect that the shared resource competition is solved by adopting a locking strategy or using a message queue serialization processing strategy is overcome, and the scheme is small in change of an original program and easy to implement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database transaction processing, and particularly provides a method and system for updating order inventory in a lock-free concurrent transaction processing manner. Background Art

[0002] In a concurrent environment, for multiple requests to update the same order inventory record, a locking strategy or message queue serialization processing is usually adopted. However, the existing two strategies have the following problems in solving the competition of shared resources:

[0003] Timeout risk: As the concurrency increases, the lock competition will also increase exponentially, and the system throughput will drop sharply. The average waiting time of transactions is prolonged, and a large number of requests are likely to time out.

[0004] Waste of server resources: Queuing requests for processing, although there is no problem of shared resource competition, will cause a large amount of server resources to be idle.

[0005] Prolonged average processing time of requests: The serialization processing of requests will also cause the average processing time of requests to be prolonged. If the subsequent process is based on the completion of the current process, the processing time of the entire process will be prolonged, affecting the user experience.

[0006] The existing solutions are difficult to balance performance, user experience and consistency issues in high-concurrency scenarios. Locking and message queue serialization processing will lead to a decrease in system throughput, an increase in response latency and waste of server resources. Summary of the Invention

[0007] The present invention aims at the above-mentioned deficiencies of the prior art and provides a practical method for updating order inventory in a lock-free concurrent transaction processing manner.

[0008] A further technical task of the present invention is to provide a lock-free concurrent transaction processing order inventory update system with reasonable design, safety and applicability.

[0009] The technical solution adopted by the present invention to solve its technical problems is:

[0010] A method for updating order inventory in a lock-free concurrent transaction processing manner. First, create a table named inventory update record table to store the reserved inventory information of added commodities.

[0011] Save the original order inventory record update information into the inventory update record table. Then, two timed tasks need to be started. One timed task is used to perform the operation of increasing the reserved inventory of commodities, and the other timed task scans to reach the maximum compensation times.

[0012] Further, the inventory update record table includes business data fields, related fields for inventory update, compensation times field, execution result field, creation time and update time fields. Among them, the execution result is defaulted to failure and compensation, and the number of times is defaulted to 0 times.

[0013] Further, when performing the operation of increasing the reserved inventory of goods, a batch of records with a compensation times of 0 and a status of failure are retrieved in reverse order of the creation time. Then, according to the reserved inventory information of the increased goods saved in the records, the update statement is reorganized and the update statement is executed. If the execution is successful, the corresponding record in the inventory update record table is modified in reverse. If the execution fails, it enters the asynchronous compensation logic.

[0014] Further, if the same request parameters are called multiple times, a conditional DELETE operation is first performed on the inventory update record table before using the INSERT operation to replace the UPDATE operation for updating the inventory record.

[0015] Further, another timing task scans the inventory update record table records that have reached the maximum compensation times and whose status is still failure. If there is relevant information, it notifies the relevant personnel for handling.

[0016] An order inventory update system for lock-free concurrent transaction processing. First, a table for saving the reserved inventory information of increased goods is created, and the table name is the inventory update record table;

[0017] The original order inventory record update information is saved into the inventory update record table. Then, two timing tasks need to be started. One timing task is used to perform the operation of increasing the reserved inventory of goods, and the other timing task scans to reach the maximum compensation times.

[0018] Further, the inventory update record table includes business data fields, related fields for inventory update, compensation times field, execution result field, creation time and update time fields. Among them, the execution result is defaulted to failure and compensation, and the number of times is defaulted to 0 times.

[0019] Further, when performing the operation of increasing the reserved inventory of goods, a batch of records with a compensation times of 0 and a status of failure are retrieved in reverse order of the creation time. Then, according to the reserved inventory information of the increased goods saved in the records, the update statement is reorganized and the update statement is executed. If the execution is successful, the corresponding record in the inventory update record table is modified in reverse. If the execution fails, it enters the asynchronous compensation logic.

[0020] Further, if the same request parameters are called multiple times, a conditional DELETE operation is first performed on the inventory update record table before using the INSERT operation to replace the UPDATE operation for updating the inventory record.

[0021] Further, another timing task scans the inventory update record table that has reached the maximum compensation times and whose status is still failed. If there is relevant information, it notifies the relevant personnel for handling.

[0022] Compared with the prior art, an order inventory update method and system for lock-free concurrent transaction processing according to the present invention have the following prominent beneficial effects:

[0023] The present invention replaces the locked update operation with a lock-free addition operation to disrupt shared resources, which not only solves the disadvantages of using a locking strategy or a message queue serialization processing strategy to solve shared resource competition, but also has less modification to the original program and is easy to implement. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0025] Attached Figure 1 is a flowchart showing a method for updating an order inventory with lock-free concurrent transaction processing;

[0026] Attached Figure 2 is a flowchart showing the process of adding reserved inventory for a product in a method for updating an order inventory with lock-free concurrent transaction processing;

[0027] Attached Figure 3 is a flowchart showing the process of scanning for the maximum compensation times in a method for updating an order inventory with lock-free concurrent transaction processing. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0028] In order to enable those skilled in the art of the present technology to better understand the solution of the present invention, the following further details the present invention in conjunction with specific embodiments. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

[0029] The following gives a best embodiment:

[0030] As Figures 1-3 shown, in a method for updating an order inventory with lock-free concurrent transaction processing in this embodiment, first, a table for storing reserved inventory information for added products is created, and the table name is the inventory update record table;

[0031] Add the position of the reserved inventory of goods in the original interface. First, delete the records in the inventory update record table according to the information in the order line table. This operation is to ensure that when the same request parameters are called again, it will not be affected by the previous failure of the inventory update record table execution.

[0032] Among them, the inventory update record table includes business data fields, relevant fields for inventory update, compensation times fields, execution result fields, creation time and update time fields. Among them, the execution result is defaulted to failure and compensation, and the number of times is defaulted to 0 times.

[0033] Save the original order inventory record update information to the inventory update record table. Then, two scheduled tasks need to be started. One scheduled task is used to perform the operation of adding the reserved inventory of goods, and the other scheduled task scans to reach the maximum compensation times.

[0034] The operation of adding the reserved inventory of goods is as follows:

[0035] Fetch a batch of records with a compensation times of 0 and a status of failure in reverse order of the creation time. Then, according to the information of adding the reserved inventory of goods saved in the records, reorganize the update statement and execute the update statement. If the execution is successful, modify the corresponding records in the inventory update record table in turn. If the execution fails, enter the asynchronous compensation logic.

[0036] Another scheduled task scans the records in the inventory update record table that reach the maximum compensation times and the status is still failure. If there is relevant information, notify the relevant personnel to handle it.

[0037] Based on the above method, in an order inventory update system for lock-free concurrent transaction processing in this embodiment, first, create a table named inventory update record table to save the information of adding the reserved inventory of goods;

[0038] Save the original order inventory record update information to the inventory update record table. Then, two scheduled tasks need to be started. One scheduled task is used to perform the operation of adding the reserved inventory of goods, and the other scheduled task scans to reach the maximum compensation times.

[0039] Among them, the inventory update record table includes business data fields, relevant fields for inventory update, compensation times fields, execution result fields, creation time and update time fields. Among them, the execution result is defaulted to failure and compensation, and the number of times is defaulted to 0 times.

[0040] When performing the operation of adding the reserved inventory of goods, fetch a batch of records with a compensation times of 0 and a status of failure in reverse order of the creation time. Then, according to the information of adding the reserved inventory of goods saved in the records, reorganize the update statement and execute the update statement. If the execution is successful, modify the corresponding records in the inventory update record table in turn. If the execution fails, enter the asynchronous compensation logic.

[0041] If the same request parameters are called multiple times, a conditional DELETE operation is first performed on the inventory update record table before using the INSERT operation to replace the UPDATE operation for updating the inventory record.

[0042] Another scheduled task scans the inventory update record table records that have reached the maximum compensation times and whose status is still failed, and notifies the relevant personnel for handling if there is relevant information.

[0043] The above specific embodiments are only specific cases of the present invention. The patent protection scope of the present invention includes but is not limited to the above specific embodiments. Any technical solution that conforms to the technical solutions recorded in the above specific embodiments of the present invention and any appropriate changes or replacements made by those of ordinary skill in the art shall fall within the patent protection scope of the present invention.

[0044] Although the embodiments of the present invention have been shown and described, it will be understood by those of ordinary skill in the art that various changes, modifications, substitutions and variations can be made in these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A method for updating order inventory in a lock - free concurrent transaction processing, characterized in that, First, create a table named Inventory Update Record Table to store the reserved inventory information of added products; Save the updated information of the original order inventory record into the Inventory Update Record Table. Then, two scheduled tasks need to be started. One scheduled task is used to perform the operation of adding the reserved inventory of products, and the other scheduled task scans to reach the maximum compensation times.

2. The order inventory update method for lock-free concurrent transaction processing according to claim 1, wherein The Inventory Update Record Table includes business data fields, relevant fields for inventory update, compensation times fields, execution result fields, creation time and update time fields. Among them, the execution result is defaulted to failure and compensation, and the number of times is defaulted to 0 times.

3. The order inventory update method for lock-free concurrent transaction processing according to claim 2, characterized in that When performing the operation of adding the reserved inventory of products, fetch a batch of records with a compensation times of 0 and a status of failure in reverse order of the creation time. Then, according to the reserved inventory information of added products saved in the records, reorganize the update statement and execute the update statement. If the execution is successful, modify the corresponding records in the Inventory Update Record Table conversely. If the execution fails, enter the asynchronous compensation logic.

4. The order inventory update method for lock-free concurrent transaction processing according to claim 3, characterized in that, If the same request parameters are called multiple times, before using the INSERT operation to replace the UPDATE operation of updating the inventory record, first perform a conditional DELETE operation on the Inventory Update Record Table.

5. The order inventory update method for lock-free concurrent transaction processing according to claim 4, wherein, Another scheduled task scans the records in the Inventory Update Record Table that have reached the maximum compensation times and whose status is still failure. If there is relevant information, notify the relevant personnel for handling.

6. An order inventory update system for lock-free concurrent transaction processing, characterized in that, First, create a table named Inventory Update Record Table to store the reserved inventory information of added products; Save the updated information of the original order inventory record into the Inventory Update Record Table. Then, two scheduled tasks need to be started. One scheduled task is used to perform the operation of adding the reserved inventory of products, and the other scheduled task scans to reach the maximum compensation times.

7. An order inventory update system for lock-free concurrent transaction processing according to claim 6, characterized in that, The Inventory Update Record Table includes business data fields, relevant fields for inventory update, compensation times fields, execution result fields, creation time and update time fields. Among them, the execution result is defaulted to failure and compensation, and the number of times is defaulted to 0 times.

8. An order inventory update system for lock-free concurrent transaction processing according to claim 7, characterized in that, When performing the operation of adding the reserved inventory of products, fetch a batch of records with a compensation times of 0 and a status of failure in reverse order of the creation time. Then, according to the reserved inventory information of added products saved in the records, reorganize the update statement and execute the update statement. If the execution is successful, modify the corresponding records in the Inventory Update Record Table conversely. If the execution fails, enter the asynchronous compensation logic.

9. An order inventory update system for lock-free concurrent transaction processing according to claim 8, characterized in that, If the same request parameters are called multiple times, before using the INSERT operation to replace the UPDATE operation of updating the inventory record, first perform a conditional DELETE operation on the Inventory Update Record Table.

10. The order inventory update system for lock-free concurrent transaction processing according to claim 9, characterized in that, Another scheduled task scans the records in the Inventory Update Record Table that have reached the maximum compensation times and whose status is still failure. If there is relevant information, notify the relevant personnel for handling.