Document processing method, device, computer equipment and storage medium

By mutexing the to-process data rows in a multi-user distributed application, the modification conflict problem when multiple users modify shared data at the same time is solved, and the accuracy of document processing is improved.

CN114217979BActive Publication Date: 2025-03-18KINGDEE SOFTWARE(CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111559957.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-20
Publication Date
2025-03-18
Estimated Expiration
2041-12-20

AI Technical Summary

Technical Problem

In multi-user distributed applications, when multiple users modify the same shared data at the same time through different documents, modification conflicts are likely to occur, resulting in data modification errors and document processing errors.

Method used

By acquiring the acquisition lock request corresponding to each pending data row in the target pending document and allocating a mutex lock in the mutex pool, ensuring that the service processing is performed only when each pending data row acquires the mutex, and the mutex lock is released when the business processing is completed.

Benefits of technology

By locking shared data on the pending data row, it is ensured that only one thread is allowed to process during the locking period, which greatly reduces the probability of modification conflicts occur when modifying shared data and improves the accuracy of document processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114217979B_ABST
    Figure CN114217979B_ABST
Patent Text Reader

Abstract

The present application relates to a document processing method, device, computer equipment and storage medium. The above method includes: obtaining a lock acquisition request corresponding to each data row to be processed in the target document to be processed; for each lock acquisition request in at least one lock acquisition request, determining whether there is an allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current lock acquisition request; if not, the unallocated mutex lock in the mutex lock pool is allocated to the data row to be processed corresponding to the current row identifier in the target document to be processed; when each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed; when the business processing is completed, the mutex locks occupied by each data row in the processed document are released. The use of this method can improve the processing efficiency of documents to be processed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a document processing method, apparatus, computer equipment and storage medium. Background Art

[0002] With the development of computer technology, different users can modify the same shared data through different applications. For example, user A can submit document A through node A in a distributed application to modify the inventory of material C through document A. At the same time, user B can also submit document B through node B in a distributed application to modify the inventory of material C through document B.

[0003] However, when multiple users modify the same shared data at the same time through different documents, modification conflicts are likely to occur, resulting in shared data modification errors, and further resulting in document processing errors. Summary of the invention

[0004] Based on this, it is necessary to provide a document processing method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the accuracy of document processing in response to the above technical problems.

[0005] In a first aspect, the present application provides a document processing method. The method comprises:

[0006] Obtain a lock request corresponding to each pending data row in the target pending document;

[0007] For each of the at least one acquire lock request, determining whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current acquire lock request;

[0008] If not, an unassigned mutex in the mutex pool is assigned to the to-be-processed data row corresponding to the current row identifier in the target to-be-processed document;

[0009] When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed;

[0010] When the business processing is completed, the mutex locks occupied by each data row in the processed document are released.

[0011] In one of the embodiments, when a document submission request is obtained, the target document to be processed corresponding to the document submission request is determined; at least one data row to be processed included in the target document to be processed is determined; based on the row identifier of the data row to be processed and the document identifier of the target document to be processed, a lock acquisition request corresponding to each of the data rows to be processed is generated; the method also includes: storing the lock acquisition request in a storage queue.

[0012] In one of the embodiments, when at least one document submission request is obtained, the target to-be-processed document corresponding to each document submission request is determined, and a lock acquisition request corresponding to each to-be-processed data row in each target to-be-processed document is generated; the method also includes: determining the request authority corresponding to each of the target to-be-processed documents, and determining the arrangement order of each of the lock acquisition requests in the storage queue based on the request authority; and storing the lock acquisition requests in the storage queue according to the arrangement order.

[0013] In one of the embodiments, the acquire lock requests in the storage queue are traversed according to the arrangement order of the acquire lock requests in the storage queue; for the current acquire lock request currently traversed, it is determined whether there is an allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current acquire lock request.

[0014] In one of the embodiments, the data content of each data row to be processed in the target document to be processed is obtained; the data content includes at least one of the total inventory value, the inventory transfer amount, the total resource value, and the resource transfer value; for each data row to be processed in the multiple data rows to be processed, the business data in the preset business database is updated according to at least one of the total inventory value, the inventory transfer amount, the total resource value, and the resource transfer value in the current data row to be processed.

[0015] In one of the embodiments, it is determined whether each lock acquisition request corresponding to the target document to be processed acquires a mutex lock within a preset timeout period; if there is a lock acquisition request that does not acquire a mutex lock within the timeout period, the mutex lock occupied by the data row to be processed in the target document to be processed is released.

[0016] In one of the embodiments, a release time point for releasing the mutex lock is determined; a time interval between the current time point and the release time point is determined; when the time interval matches a preset waiting time, at least one lock acquisition request corresponding to the target to-be-processed document is responded to again to obtain the mutex lock corresponding to each to-be-processed data row in the target to-be-processed document.

[0017] In a second aspect, the present application also provides a document processing device. The device comprises:

[0018] A lock request acquisition module is used to acquire a lock request corresponding to each to-be-processed data row in a target to-be-processed document;

[0019] A mutex lock allocation module, for determining, for each of at least one acquire lock request, whether there is an allocated mutex lock in a mutex lock pool and corresponding to a current row identifier in a current acquire lock request; if not, allocating an unallocated mutex lock in the mutex lock pool to a to-be-processed data row corresponding to the current row identifier in the target to-be-processed document;

[0020] The business processing module is used to perform business processing on the target document to be processed when each data row to be processed in the target document to be processed obtains a mutex lock; when the business processing is completed, release the mutex locks occupied by each data row in the processed document.

[0021] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0022] Obtain a lock request corresponding to each pending data row in the target pending document;

[0023] For each of the at least one acquire lock request, determining whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current acquire lock request;

[0024] If not, an unassigned mutex in the mutex pool is assigned to the to-be-processed data row corresponding to the current row identifier in the target to-be-processed document;

[0025] When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed;

[0026] When the business processing is completed, the mutex locks occupied by each data row in the processed document are released.

[0027] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0028] Obtain a lock request corresponding to each pending data row in the target pending document;

[0029] For each of the at least one acquire lock request, determining whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current acquire lock request;

[0030] If not, an unassigned mutex in the mutex pool is assigned to the to-be-processed data row corresponding to the current row identifier in the target to-be-processed document;

[0031] When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed;

[0032] When the business processing is completed, the mutex locks occupied by each data row in the processed document are released.

[0033] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:

[0034] Obtain a lock request corresponding to each pending data row in the target pending document;

[0035] For each of the at least one acquire lock request, determining whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current acquire lock request;

[0036] If not, an unassigned mutex in the mutex pool is assigned to the to-be-processed data row corresponding to the current row identifier in the target to-be-processed document;

[0037] When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed;

[0038] When the business processing is completed, the mutex locks occupied by each data row in the processed document are released.

[0039] The above-mentioned document processing method, device, computer equipment, storage medium and computer program product obtain a lock acquisition request corresponding to each data row to be processed in the target document to be processed, and for each lock acquisition request in at least one lock acquisition request, determine whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current lock acquisition request; if not, the unallocated mutex lock in the mutex lock pool is allocated to the data row to be processed corresponding to the current row identifier in the target document to be processed, so that when each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed, and when the business processing is completed, the mutex locks occupied by each data row in the processed document are released. Since a mutex lock is assigned to the current data row to be processed in the target document to be processed, only one thread is allowed to process the shared data pointed to by the current data row to be processed during the locking period, and the remaining threads are not allowed to process the shared data pointed to by the current data row to be processed based on the remaining documents, thereby greatly reducing the probability of modification conflicts when modifying shared data, thereby improving the accuracy of document processing.

[0040] In addition, since a mutex lock is allocated to each pending data row in the target pending document instead of the entire target pending document, the probability of forcibly locking content that does not need to be locked can be reduced, thereby improving the effectiveness of mutex lock allocation. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 An application environment diagram of a document processing method in an embodiment;

[0042] Figure 2 A schematic diagram of a process flow of a document processing method in one embodiment;

[0043] Figure 3 A schematic diagram of a structure for obtaining a mutex lock in one embodiment;

[0044] Figure 4 A schematic diagram of a process of acquiring a mutex lock for a document in one embodiment;

[0045] Figure 5 This is a schematic diagram of the structure of a target document to be processed in an embodiment;

[0046] Figure 6 is a structural block diagram of a document processing device in one embodiment;

[0047] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0049] The document processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 can communicate with the server 104 through the network. Among them, the terminal 102 and the server 104 can be used alone to execute the document processing method provided in the embodiment of the present application, and can also be used in collaboration to execute the document processing method provided in the embodiment of the present application. Take the terminal 102 and the server 104 for collaboratively executing the document processing method as an example for explanation, the terminal 102 is used to send the acquisition lock request corresponding to each pending data row in the target pending document and the target pending document to the server 104. The server 104 is used to allocate the unallocated mutex lock in the mutex lock pool to the pending data row corresponding to the current row identifier in the target pending document according to each acquisition lock request. When each pending data row obtains the mutex lock, the server 104 performs business processing on the target pending document and returns the business processing result to the terminal 102. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones and tablet computers and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster composed of multiple servers.

[0050] In one embodiment, Figure 2 As shown, a document processing method is provided, and the method is applied to a computer device as an example for explanation. The computer device can be Figure 1 The document processing method includes the following steps:

[0051] Step 202: Obtain a lock request corresponding to each to-be-processed data row in the target to-be-processed document.

[0052] The lock acquisition request can be used to acquire the mutual exclusion lock corresponding to the row identifier of the data row to be processed. The row identifier of the data row to be processed is generated based on the shared data pointed to by the data row to be processed. For example, when the data content of data row a in document 1 is "inventory of material c: 100; deduction: 10", the shared data pointed to by data row a can be considered as "inventory of material c"; when the data content of data row b in document 2 is "inventory of material d: 200; increase: 20", the shared data pointed to by data row b can be considered as "inventory of material d". It is easy to understand that when the shared data pointed to by the data rows in two documents are consistent, the row identifiers of the data rows in the two documents are also consistent.

[0053] In the scenario where multiple threads deduct amounts or inventories, after the pending data row obtains the mutex lock, only one thread can perform a deduction operation on the shared data pointed to by the pending data row according to the data content in the pending data row, while the remaining threads cannot perform a deduction operation on the shared data pointed to by the pending data row that has obtained the lock, thereby ensuring the integrity of the shared data. For example, when a user wants to modify shared data through a thread, the shared data is first locked through a mutex lock, and the state of the shared data is converted to "locked", at which point other threads cannot modify the shared data. Until the thread releases the mutex lock and converts the state of the shared data to "unlocked", other threads can modify the shared data again.

[0054] Specifically, after acquiring the target document to be processed, the computer device determines the data row in the target document to be processed, and uses the data row in the target document to be processed as the data row to be processed. When determining the data row to be processed in the target document to be processed, the computer device can generate a corresponding acquisition lock request for each data row to be processed according to the document identifier of the target document and the row identifier of the data row to be processed. The document identifier refers to information that uniquely identifies a document, for example, the document identifier can be the ID of the document.

[0055] In one embodiment, before submitting a document, the user can modify the document, for example, the user can modify some data rows in the document, and obtain a modified target document. When the user submits the modified target document, a document submission request carrying the target document is formed, wherein the target document is the target document to be processed mentioned above. The computer device performs business processing on the target document to be processed through the document submission request, obtains corresponding business data, and updates the target document through the business data.

[0056] Step 204: for each of the at least one lock acquisition request, determine whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current lock acquisition request.

[0057] Among them, the mutex lock pool contains multiple mutex locks in allocated state and mutex locks in unallocated state. When an unallocated mutex lock is randomly allocated to a data row, the computer device will record the allocated mutex lock as allocated, and record the lock identifier of the mutex lock and the row identifier of the data row, and obtain the correspondence between the allocated mutex lock and the data row that has acquired the lock, so that based on the correspondence, it can be determined whether there is an allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current lock acquisition request.

[0058] For example, if the second data row in document 2 and the first data row in document 1 point to the same shared data, that is, the second data row in document 2 and the first data row in document 1 have the same row identifier, the computer device may allocate mutex a to the second data row in document 2. At this time, the computer device records the lock identifier of mutex a and the row identifier of the second data row in document 2 to obtain the corresponding relationship between the allocated mutex and the acquired data row. When the computer device obtains the acquisition lock request corresponding to the first data row in document 1, the computer device can determine that there is an allocated mutex a in the mutex pool that corresponds to the row identifier of the first data row in document 1 through the above correspondence. At this time, mutex a has locked the shared data pointed to by the first data row in document 1. Therefore, the computer device no longer allocates the unallocated mutex in the mutex pool to the first data row in document 1.

[0059] Specifically, the computer device processes the lock acquisition requests stored in the storage queue in sequence, and for the current lock acquisition request stored in the storage queue, determines the current row identifier of the to-be-processed data row corresponding to the current lock acquisition request, and determines the mutex lock corresponding to the current row identifier in the current lock acquisition request. For the mutex lock corresponding to the current row identifier in the current lock acquisition request, determines whether it is in an allocated state in the mutex lock pool.

[0060] In one embodiment, the computer device may pre-generate a mutex lock corresponding to each shared data, and store the generated mutex locks in a mutex lock pool. The computer device processes the acquisition lock requests stored in the storage queue in turn, and for each of the multiple acquisition lock requests, searches the mutex lock pool for a current mutex lock that matches the current acquisition lock request, wherein the matching current mutex lock is a mutex lock corresponding to the shared data pointed to by the pending data row corresponding to the current acquisition lock request. Since different pending data rows in different documents may point to the same shared data, a single mutex lock may correspond to multiple acquisition lock requests. If the current mutex lock has been assigned to other pending data rows, the current pending data row cannot obtain the current mutex lock that matches the current acquisition lock request.

[0061] For example, Figure 3 As shown, Figure 3 The diagram is a structural diagram of obtaining a mutex lock. When the computer device obtains the acquisition lock request 2 of the pending data row A in document 2, if a mutex lock matching the acquisition lock request 2 can be found in the mutex lock pool, but the mutex lock has been allocated to the pending data row A in document 1, the pending data row A in document 2 cannot be allocated to the mutex lock matching the acquisition lock request 2.

[0062] Step 206: If it does not exist, an unassigned mutex in the mutex pool is assigned to the to-be-processed data row corresponding to the current row identifier in the target to-be-processed document.

[0063] Specifically, when there is no allocated mutex in the mutex pool that corresponds to the current row identifier in the current lock acquisition request, the computer device allocates the unallocated mutex in the mutex pool to the pending data row corresponding to the current row identifier in the target pending document.

[0064] In one of the embodiments, the computer device extracts the document ID and the row ID in the current lock acquisition request, and allocates the unallocated mutex lock to the corresponding data row to be processed in the target document to be processed according to the document ID and the row ID in the current lock acquisition request.

[0065] In one embodiment, when the computer device simultaneously obtains multiple target documents to be processed, the computer device may generate multiple lock acquisition requests corresponding to each target document to be processed, and store them in a storage queue according to the generation time of the lock acquisition request. Since the computer device can pre-generate a mutex lock corresponding to each shared data, and store the generated mutex lock in a mutex lock pool. Therefore, the computer device can traverse the lock acquisition requests in the storage queue according to the arrangement order of each lock acquisition request in the storage queue, obtain the current lock acquisition request currently traversed, and respond to the current lock acquisition request through the mutex lock pool.

[0066] For example, refer to Figure 3 , when the computer device obtains document 1 and document 2 at the same time, the computer device may first generate an acquisition lock request 1 for the pending data row A in document 1, and then generate an acquisition lock request 2 according to the pending data row A in document 2, and store the acquisition lock request 1 and the acquisition lock request 2 in the storage queue in sequence. Since the acquisition lock request 1 and the acquisition lock request 2 are stored in the storage queue in sequence, the computer device will first respond to the acquisition lock request 1, and search for a mutex lock matching the acquisition lock request 1 in the mutex lock pool, that is, search for a mutex lock generated for the shared data pointed to by the pending data row A in document 1, and assign the mutex lock to the pending data row A in document 1. The computer device then responds to the acquisition lock request 2, and at this time, the mutex lock matching the acquisition lock request 2 has been assigned to the pending data row A in document 1, so the computer device no longer assigns it to the pending data row A in document 2.

[0067] Step 208: When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed.

[0068] Specifically, the computer device determines whether each data row to be processed in the target document to be processed has obtained a mutex lock. When each data row to be processed in the target document to be processed has obtained a mutex lock, the computer device obtains the data content in each data row to be processed in the target document to be processed, and updates the business data in the preset business database according to the data content in each data row to be processed.

[0069] It is easy to understand that since a mutex lock is assigned to each data row to be processed, during the locking period, if the row identifier of the data row to be processed in other target documents to be processed is the same as the row identifier of the data row to be processed to which the mutex lock is assigned, the computer device cannot process the shared data pointed to by the data row to be processed in other target documents to be processed, thereby reducing the probability of modification conflicts when modifying shared data. By processing the target document to be processed only when each data row to be processed in the target document to be processed obtains a lock request, the shared data pointed to by each data row to be processed can be locked, and then the shared data pointed to by each data row to be processed can be modified only when they are in a locked state. In this way, the situation where some data rows to be processed in the target document to be processed fail to obtain a mutex lock, and the shared data pointed to by the data row to be processed is in an unlocked state but is modified, can be reduced, thereby reducing the probability of modification conflicts caused by shared data not being locked.

[0070] Step 210, when the business processing is completed, the mutex locks occupied by each data row in the processed document are released.

[0071] Specifically, when the computer device completes processing the target to-be-processed document and obtains a processed document, the computer device releases the mutex for each data row in the processed document that has obtained the mutex. At this time, the allocated mutex is updated to an unallocated state.

[0072] In one of the embodiments, when releasing a mutex lock, the computer device obtains the correspondence between the currently allocated mutex lock and the data row for which the lock has been acquired, and deletes the lock identification record of the currently released mutex lock and the row identification of the data row for releasing the mutex lock in the correspondence, at which time the released mutex lock is updated to an unallocated state.

[0073] In the above document processing method, by obtaining the lock acquisition request corresponding to each data row to be processed in the target document to be processed, and for each lock acquisition request in at least one lock acquisition request, it is determined whether there is an allocated lock corresponding to the current row identifier in the current lock acquisition request in the lock pool; if not, the unallocated lock in the lock pool is allocated to the data row to be processed corresponding to the current row identifier in the target document to be processed, so that when each data row to be processed in the target document to be processed obtains the lock, the target document to be processed is processed, and when the business processing is completed, the lock occupied by each data row in the processed document is released. Since the lock is allocated to the current data row to be processed in the target document to be processed, only one thread is allowed to process the shared data pointed to by the current data row to be processed during the lock period, and the remaining threads are not allowed to process the shared data pointed to by the current data row to be processed according to the remaining documents, thereby greatly reducing the probability of modification conflicts when modifying shared data, thereby improving the accuracy of document processing.

[0074] In one of the embodiments, when a document submission request is obtained, the target document to be processed corresponding to the document submission request is determined; at least one data row to be processed included in the target document to be processed is determined; based on the row identifier of the data row to be processed and the document identifier of the target document to be processed, a lock acquisition request corresponding to each data row to be processed is generated; the above method also includes: storing the lock acquisition request in a storage queue.

[0075] Specifically, when a user submits a document at a terminal, the terminal may generate a document submission request. The document submission request carries the document submitted by the user. The server may receive the document submission request sent by the terminal, extract the document in the document submission request, and use the document in the document submission request as the target to-be-processed document. The server generates a corresponding acquisition lock request for each to-be-processed data row according to the document identifier of the target to-be-processed document and the row identifier of each to-be-processed data row in the target to-be-processed document, and stores the generated acquisition lock request in the storage queue.

[0076] In one embodiment, the server may receive multiple document submission requests sent by multiple different terminals, extract the documents in the document submission requests, and use the documents in the document submission requests as the target documents to be processed. For each target document to be processed in the multiple target documents to be processed, the server determines the acquisition lock request associated with each pending data row in the current target document to be processed based on the document identifier of the current target document to be processed and the row identifier of each pending data row in the current target document to be processed. Each pending data row has only a unique associated acquisition lock request. The acquisition lock request corresponding to each pending data row is a thread, and the server can sequentially store the acquisition lock requests corresponding to different target documents to be processed in the storage queue, so that the acquisition lock requests in the storage queue can be responded to sequentially later.

[0077] In one embodiment, the computer device may store the acquisition lock requests in a storage queue according to the time sequence of their generation. For example, if document 1 is submitted before document 2, the acquisition lock requests corresponding to pending data row A, pending data row B, and pending data row C in document 1 are first stored in the storage queue in sequence, and then the acquisition lock requests corresponding to pending data row A, pending data row D, and pending data row E in document 2 are stored in the storage queue in sequence. If document 1 and document 2 are submitted at the same time, the acquisition lock requests corresponding to the pending data rows in document 1 and document 2 are randomly stored in the storage queue.

[0078] In this embodiment, by determining the document ID of the target document to be processed and the row ID of the data row to be processed in the target document to be processed, a lock acquisition request associated with the data row to be processed can be generated based on the document ID and the row ID, and the lock acquisition request is stored in the storage queue. By storing the lock acquisition request in the storage queue, the lock acquisition requests in the storage queue can be responded to in sequence later.

[0079] In one of the embodiments, when at least one document submission request is obtained, the target pending document corresponding to each document submission request is determined, and a lock acquisition request corresponding to each pending data row in each target pending document is generated. The above method also includes: determining the request authority corresponding to each target pending document, and determining the arrangement order of each lock acquisition request in the storage queue based on the request authority; and storing the lock acquisition request in the storage queue according to the arrangement order.

[0080] Specifically, when different users submit documents at their respective terminals, the terminals where the users are located generate corresponding document submission requests respectively. The server can receive the document submission requests sent by each terminal and determine the target documents to be processed corresponding to each document submission request. The server generates a corresponding acquisition lock request for each data row to be processed in each target document to be processed according to the document identifier of each target document to be processed and the row identifier of each data row to be processed in each target document to be processed. For each target document to be processed among multiple target documents to be processed, the server determines the request authority of the current target document to be processed and uses the request authority of the current target document to be processed as the request authority of the acquisition lock request corresponding to the current target document to be processed. In this way, the server can determine the request authority of each acquisition lock request corresponding to each target document to be processed, so that the server determines the arrangement order of each acquisition lock request in the multiple target documents to be processed in the storage queue according to the request authority size between the acquisition lock requests, and stores the acquisition lock request in each target document to be processed in the storage queue according to the arrangement order.

[0081] For example, in the above example, if document 1 includes data row A to be processed, document 2 also includes data row A to be processed, and the request authority of document 2 is higher than the request authority of document 1, then the arrangement order of lock request 2 for data row A to be processed in document 2 in the storage queue is earlier than the arrangement order of lock request 1 for data row A to be processed in document 1 in the storage queue. When the server obtains the document submission requests of documents 1 and 2 at the same time, the server first stores lock request 2 in the storage queue, and then stores lock request 1 in the storage queue.

[0082] In one embodiment, the request authority can be determined according to the urgency of the document submission request, for example, the request authority corresponding to a document submission request with a higher urgency is higher than the request authority corresponding to a document submission request with a lower urgency. The request authority can also be determined according to the user account that submits the document submission request, for example, the request authority of the document submission request generated by a high-level user account is higher than the request authority of the document submission request generated by a low-level user account.

[0083] In this embodiment, the order of the lock acquisition requests in each target pending document in the storage queue is confirmed and determined by the size of the request authority corresponding to each target pending document. This not only allows the server to give priority to lock acquisition requests with higher request authorities, but also reduces the probability of modification conflicts when multiple users modify shared data at the same time because the lock acquisition requests can be processed in sequence according to the order of arrangement.

[0084] In one embodiment, for each acquire lock request in at least one acquire lock request, it is determined whether there is an allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current acquire lock request, including: traversing the acquire lock requests in the storage queue according to the arrangement order of the acquire lock requests in the storage queue; for the current acquire lock request currently traversed, determining whether there is an allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current acquire lock request.

[0085] Specifically, the computer device responds to the acquisition lock requests in the storage queue in sequence according to the order in which the acquisition lock requests are arranged in the storage queue. For the current acquisition lock request currently responded to, the computer device searches the mutex lock pool for whether there is an allocated mutex lock corresponding to the current row identifier in the current acquisition lock request.

[0086] In one of the embodiments, since there may be multiple acquisition lock requests for target pending documents in the storage queue, when the computer device responds to the acquisition lock requests in the storage queue in sequence and determines that there is no allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current acquisition lock request, the computer device determines the current target pending document corresponding to the current acquisition lock request based on the document identifier in the current acquisition lock request, and allocates the unallocated mutex lock to the pending data row corresponding to the current row identifier in the current target pending document.

[0087] In one of the embodiments, when a computer device obtains a current acquisition lock request in a storage queue, other acquisition lock requests in the storage queue are in a waiting state. If a pending data row corresponding to the current acquisition lock request is assigned to a mutex lock, the next acquisition lock request in the storage queue is processed, and the next acquisition lock request is released from the waiting state; until the waiting state of all acquisition lock requests in the storage queue is released and the mutex lock corresponding to the row identifier in the acquisition lock request is successfully assigned.

[0088] In one of the embodiments, the computer device obtains the arrangement order of the lock acquisition requests in the storage queue according to the arrangement order of the row identifiers of each data row to be processed in the current document to be processed and the lock acquisition requests corresponding to the row identifiers of the data row to be processed.

[0089] For example, refer to Figure 3 When the computer device obtains multiple pending data rows in document 1, and the row identifiers of the pending data rows are arranged in the order of pending data row C, pending data row B, and pending data row A, the computer device obtains the acquisition lock request corresponding to each pending data row in turn.

[0090] In this embodiment, by determining the arrangement order of the acquisition lock requests in the storage queue, the computer device can process the acquisition lock requests in sequence according to the arrangement order, thereby reducing the probability of missing the acquisition lock requests.

[0091] In one embodiment, when each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed, including: obtaining the data content in each data row to be processed in the target document to be processed; the data content includes at least one of the total inventory value, inventory transfer amount, total resource value, and resource transfer value; for each data row to be processed in multiple data rows to be processed, the business data in the preset business database is updated according to at least one of the total inventory value, inventory transfer amount, total resource value, and resource transfer value in the current data row to be processed.

[0092] Specifically, when the user fills in the target document to be processed at the terminal and submits the target document to be processed, the terminal can generate a document submission request corresponding to the target document to be processed. The server determines the data content of each data row to be processed in the target document to be processed by obtaining the document submission request, and confirms the business data in the preset business database according to the data content of the data row to be processed, wherein the business data can be the shared data pointed to by the above-mentioned data row to be processed. Furthermore, the computer device updates the corresponding business data according to the data content corresponding to each data row to be processed, so as to realize the business processing of the target document to be processed.

[0093] For example, if the data line to be processed in a resource transfer project document is "Resource: A; Total resource value: 1 million yuan; Resource transfer value: 20,000 yuan", the computer equipment will update the total resource value of the business data "Resource A" in the preset business database from 100 to 98.

[0094] For example, if the data line to be processed in an inventory management document is "Inventory: B; Total inventory value: 100 pieces; Inventory transfer quantity: 5 pieces", the computer device will update the total inventory value of the business data "Inventory B" in the preset business database from 100 to 95.

[0095] In one of the embodiments, the computer device may display the update result in the corresponding data row to be processed in the target document to be processed.

[0096] In this embodiment, when the computer device determines that each data row to be processed in the target document to be processed has obtained a mutex lock, it updates the data content of the target document to be processed, avoiding modification conflicts that occur when multiple users modify the same shared data, thereby improving the accuracy of document processing.

[0097] In one embodiment, it is determined whether each lock acquisition request corresponding to the target to-be-processed document acquires the mutex lock within a preset timeout period; if there is a lock acquisition request that fails to acquire the mutex lock within the timeout period, the mutex lock occupied by the to-be-processed data row in the target to-be-processed document is released.

[0098] For example, Figure 4 As shown, Figure 4 Flow chart of acquiring a mutex lock for a document. After the user submits the target document to be processed at the terminal, the computer device determines multiple data rows to be processed in the target document to be processed according to the submission request, and determines the acquisition lock request corresponding to each data row to be processed, wherein each thread of the computer device executes an acquisition lock request, and the execution of the thread has a timeout limit. If the computer device fails to obtain a mutex lock through the acquisition lock request within the preset timeout, that is, if the execution of the thread exceeds the timeout, the computer device releases the mutex lock occupied by the data row to be processed in the target document to be processed; conversely, when each data row to be processed in the target document to be processed obtains a mutex lock, the target document to be processed can be processed. After the business processing is completed, the target document to be processed submitted by the user at the terminal is deemed to be submitted successfully. At this time, the computer device releases all mutex locks in the target document to be processed to the mutex lock pool so that the data rows to be processed in other documents can obtain the corresponding mutex locks.

[0099] In this embodiment, after determining that the data row to be processed has not obtained the mutex lock within the preset timeout period, the mutex lock occupied by the data row to be processed that has obtained the mutex lock is released, which can effectively reduce the invalid occupation of the mutex lock, so that each subsequent data row to be processed can successfully obtain the mutex lock.

[0100] In one embodiment, a release time point for releasing the mutex lock is determined; a time interval between the current time point and the release time point is determined; when the time interval matches a preset waiting time, at least one lock acquisition request corresponding to the target to-be-processed document is responded to again to obtain the mutex lock corresponding to each to-be-processed data row in the target to-be-processed document.

[0101] refer to Figure 4, after releasing the mutex locks acquired for each data row to be processed at the same time, the computer device records the release time of the mutex locks and waits for a preset time. After waiting for a preset time, the computer device obtains the lock acquisition request corresponding to each data row to be processed in the target document to be processed again. If each data row to be processed in the target document to be processed acquires the mutex lock, the target document to be processed can be processed; on the contrary, if there are still data rows to be processed that fail to acquire the mutex lock, it is considered that the submission request of the target document to be processed has failed. For example, in the above example, when the computer device obtains the lock acquisition request for each data row to be processed in document 1, within the timeout period of the mutex lock of 1.1 seconds, no mutex lock is allocated to data row A to be processed, then the computer device releases the mutex locks occupied by data rows B and C to be processed that have acquired the mutex locks in document 1. After executing a preset waiting time of 1 second, the computer device again obtains the lock acquisition request corresponding to each pending data row in document 1. If the pending data row A is still not assigned a mutex lock, the submission of document 1 fails.

[0102] In one embodiment, the timeout duration for a thread in a computer device to acquire a mutex lock is determined, and the waiting duration after the computer device releases the mutex lock is obtained based on the timeout duration and a preset time value is subtracted. For example, if the timeout duration for executing the current thread is 1.1 seconds and the preset time value is 0.1 seconds, the waiting duration after the computer device releases the mutex lock is 1 second.

[0103] In this embodiment, the computer device responds to at least one lock acquisition request corresponding to the target document to be processed after waiting for a preset period of time, which can effectively utilize computer device resources and avoid dynamic deadlock, thereby improving document processing efficiency.

[0104] In one embodiment, Figure 5 This is a schematic diagram of the structure of the target document to be processed. Figure 5 As shown, document 1 includes multiple data rows. If the first and second data rows are to-be-processed data rows, other data rows do not need to be processed. Therefore, the computer device only needs to allocate exclusive locks to the first and second data rows respectively, and other data rows do not need to be allocated exclusive locks, let alone directly allocate exclusive locks to the entire target to-be-processed document. This can reduce the probability of forcibly locking data rows that do not need to be locked, thereby improving the effectiveness of exclusive lock allocation.

[0105] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0106] Based on the same inventive concept, the embodiment of the present application also provides a document processing device for implementing the document processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more document processing device embodiments provided below can refer to the limitations on the document processing method above, and will not be repeated here.

[0107] In one embodiment, Figure 6 As shown, a document processing device 600 is provided, including: a lock request acquisition module 602, a mutex lock allocation module 604, a business processing module 606 and a duration determination module 608, wherein:

[0108] The lock request acquisition module 602 is used to acquire a lock request corresponding to each to-be-processed data row in the target to-be-processed document.

[0109] The mutex lock allocation module 604 is used to determine whether there is an allocated mutex lock in the mutex lock pool and corresponds to the current row identifier in the current lock acquisition request for each lock acquisition request in at least one lock acquisition request; if not, the unallocated mutex lock in the mutex lock pool is allocated to the to-be-processed data row corresponding to the current row identifier in the target to-be-processed document.

[0110] The business processing module 606 is used to perform business processing on the target document to be processed when each data row to be processed in the target document to be processed obtains a mutex lock; when the business processing is completed, release the mutex locks occupied by each data row in the processed document.

[0111] In one embodiment, the lock request acquisition module 602 is used to determine the target pending document corresponding to the document submission request when a document submission request is received; determine at least one pending data row included in the target pending document; generate a lock acquisition request corresponding to each pending data row according to the row identifier of the pending data row and the document identifier of the target pending document; and store the lock acquisition request in a storage queue.

[0112] In one embodiment, the lock request acquisition module 602 is used to determine the target pending document corresponding to each document submission request when at least one document submission request is obtained, and generate a lock acquisition request corresponding to each pending data row in each target pending document; determine the request authority corresponding to each target pending document, and determine the arrangement order of each lock acquisition request in the storage queue based on the request authority; and store the lock acquisition requests in the storage queue according to the arrangement order.

[0113] In one embodiment, the mutex lock allocation module 604 is used to traverse the acquisition lock requests in the storage queue according to the arrangement order of the acquisition lock requests in the storage queue; for the current acquisition lock request currently traversed, determine whether there is an allocated mutex lock in the mutex lock pool that corresponds to the current row identifier in the current acquisition lock request.

[0114] In one embodiment, the business processing module 606 is used to obtain the data content in each data row to be processed in the target document to be processed; for each of the multiple data rows to be processed, the business data in the preset business database is updated according to the data content in the current data row to be processed.

[0115] In one embodiment, the document processing device 600 also includes a duration judgment module 608, which is used to determine whether each lock acquisition request corresponding to the target document to be processed has acquired the mutex lock within a preset timeout period; if there is a lock acquisition request that has not acquired the mutex lock within the timeout period, the mutex lock occupied by the data row to be processed in the target document to be processed is released.

[0116] In one embodiment, the duration judgment module 608 is also used to determine the release time point of the mutex lock; determine the time interval between the current time point and the release time point; when the time interval matches the preset waiting time, re-respond to at least one lock acquisition request corresponding to the target to-be-processed document to obtain the mutex lock corresponding to each to-be-processed data row in the target to-be-processed document.

[0117] Each module in the above-mentioned document processing device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module above.

[0118] In one embodiment, a computer device is provided. The computer device may be a computer device, and its internal structure diagram may be as shown in FIG. Figure 7 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store document processing data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a document processing method is implemented.

[0119] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0120] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0121] In one embodiment, a computer-readable storage medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0122] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-mentioned method embodiments.

[0123] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0124] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0125] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A document processing method, characterized in that: The method comprises: Obtaining a lock acquisition request corresponding to each data row to be processed in a target document to be processed, comprising: when a document submission request is obtained, determining the target document to be processed corresponding to the document submission request; determining at least one data row to be processed included in the target document to be processed; generating a lock acquisition request corresponding to each data row to be processed according to a row identifier of the data row to be processed and a document identifier of the target document to be processed; wherein the row identifier of the data row to be processed is generated according to the shared data pointed to by the data row to be processed; For each of the at least one lock acquisition request, determining whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current lock acquisition request, including: for the current lock acquisition request stored in the storage queue, determining the current row identifier of the to-be-processed data row corresponding to the current lock acquisition request, and determining the mutex lock corresponding to the current row identifier in the current lock acquisition request; for the mutex lock corresponding to the current row identifier in the current lock acquisition request, determining whether it is in an allocated state in the mutex lock pool; If not, an unassigned mutex in the mutex pool is assigned to the data row to be processed corresponding to the current row identifier in the target document to be processed; When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed; When the business processing is completed, the mutex locks occupied by each data row in the processed document are released.

2. The method according to claim 1, characterized in that: The method further comprises: The lock acquisition request is stored in a storage queue.

3. The method according to claim 1, characterized in that The acquiring lock request corresponding to each to-be-processed data row in the target to-be-processed document includes: When at least one document submission request is obtained, the target to-be-processed document corresponding to each document submission request is determined, and a corresponding acquisition lock request for each to-be-processed data row in each target to-be-processed document is generated; The method further comprises: Determine the request authority corresponding to each of the target to-be-processed documents, and determine the arrangement order of each of the acquisition lock requests in the storage queue according to the request authority; The acquire lock requests are stored in a storage queue according to the arrangement order.

4. The method according to claim 2, characterized in that: The step of determining, for each of the at least one lock acquisition request, whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current lock acquisition request comprises: According to the arrangement order of the lock acquisition requests in the storage queue, traverse the lock acquisition requests in the storage queue; For the current lock acquisition request currently traversed, determine whether there is an allocated mutex lock in the mutex lock pool and corresponding to the current row identifier in the current lock acquisition request.

5. The method according to claim 1, characterized in that When each data row to be processed in the target document to be processed obtains a mutex lock, business processing is performed on the target document to be processed, including: Obtaining the data content in each data row to be processed in the target document to be processed; For each of the multiple data rows to be processed, the business data in the preset business database is updated according to the data content in the current data row to be processed.

6. The method according to claim 1, characterized in that The method further comprises: Determine whether each lock acquisition request corresponding to the target to-be-processed document acquires a mutex lock within a preset timeout period; If there is a lock acquisition request that fails to acquire the mutex lock within the timeout period, the mutex lock occupied by the to-be-processed data row in the target to-be-processed document is released.

7. The method according to claim 6, characterized in that The method further comprises: Determine a release time point for releasing the mutex lock; Determine the time interval between the current time point and the release time point; When the time interval matches the preset waiting time, at least one lock acquisition request corresponding to the target to-be-processed document is responded to again to obtain the mutual exclusive lock corresponding to each to-be-processed data row in the target to-be-processed document.

8. A document processing device, characterized in that: The device comprises: The lock acquisition request module is used to acquire the lock acquisition request corresponding to each pending data row in the target pending document; and is also used to determine the target pending document corresponding to the document submission request when a document submission request is obtained; determine at least one pending data row included in the target pending document; and generate the lock acquisition request corresponding to each pending data row according to the row identifier of the pending data row and the document identifier of the target pending document; wherein the row identifier of the pending data row is generated according to the shared data pointed to by the pending data row; A mutex lock allocation module, for determining, for each of at least one lock acquisition request, whether there is an allocated mutex lock in a mutex lock pool and corresponding to a current row identifier in a current lock acquisition request; and for determining, for a current lock acquisition request stored in a storage queue, a current row identifier of a pending data row corresponding to the current lock acquisition request, and a mutex lock corresponding to the current row identifier in the current lock acquisition request; for a mutex lock corresponding to the current row identifier in the current lock acquisition request, determining whether an allocated mutex lock corresponding to the current row identifier in the current lock acquisition request is in an allocated state in a mutex lock pool; if not, allocating an unallocated mutex lock in the mutex lock pool to a pending data row corresponding to the current row identifier in the target pending document; The business processing module is used to perform business processing on the target document to be processed when each data row to be processed in the target document to be processed obtains a mutex lock; when the business processing is completed, release the mutex locks occupied by each data row in the processed document.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method and system for processing distributed transaction

    CN106033437A

  • Implementation method and device of distributed lock and electronic equipment

    CN111782669A