Data updating method and device, computer device and storage medium
By generating transaction records and data merging records, the lock waiting problem caused by concurrent requests in the ERP system was solved, achieving efficient and low-latency data updates and ensuring data consistency and system performance.
Patent Information
- Application Number
- CN202311843218.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-28
- Publication Date
- 2026-07-14
- Estimated Expiration
- 2043-12-28
AI Technical Summary
In ERP systems, database lock waiting during multiple concurrent requests leads to inefficient system updates, affecting the accuracy and efficiency of data updates.
By receiving concurrent business operation requests, generating transaction records and data update records, correcting transaction identifiers based on operation results, and generating data merging records, the lock wait problem is resolved, ensuring data consistency and efficient updates.
It achieves high operability and low latency updates for multiple concurrent requests, ensuring high throughput of balance updates and eventual consistency with other business operations, thereby improving the system's update efficiency and performance.
Smart Images

Figure CN117785900B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data updating method, apparatus, computer equipment, storage medium, and computer program product. Background Technology
[0002] In ERP (Enterprise Resource Planning) products, balance updates, also known as accounting or posting, are very common business operations. This action is often not initiated as a standalone business operation, but rather as a sub-step within another business operation. In business systems, identical business requests frequently occur, such as the purchase receipt approval operation. When two or more requests are initiated simultaneously, they are called concurrent requests.
[0003] However, in scenarios with concurrent requests, to ensure data accuracy, the system serializes concurrent requests, meaning requests ① and ② are executed in a queue. While processing a request, the corresponding balance record is locked, a process known as a database row lock. The waiting process for request ② to complete is called database lock waiting. Because of lock waiting, when there are a large number of concurrent requests—for example, 100 concurrent requests, each completing in 1 second—although the business system sends requests to the database simultaneously, the database takes varying amounts of time to complete each request. The first request takes 1 second, the second takes 2 seconds, and so on, up to 100 seconds for the last one to complete. This ultimately leads to extremely low system update efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a data update method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the efficiency of system updates, in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a data updating method. The method includes:
[0006] The system receives at least two business operation requests, each corresponding to at least one business operation. The business operations include a data update operation that updates the data to be updated and regular business operations other than the data update operation. For the at least two business operation requests, the system executes the regular business operations and generates transaction records corresponding to the at least two business operation requests. Based on the data update information carried by each of the at least two business operation requests, the system generates a data update record corresponding to each transaction identifier in the transaction records.
[0007] Based on the operation results of the regular business operations corresponding to the at least two business operation requests, the transaction identifier in the transaction record is corrected.
[0008] A data merge record is generated based on the data update record corresponding to the transaction identifier in the corrected transaction record, and the data to be updated is updated based on the data merge record.
[0009] In one embodiment, generating a transaction record corresponding to the at least two business operation requests includes:
[0010] Generate transaction identifiers corresponding to each of the at least two business operation requests;
[0011] Obtain an initial transaction record, and write the transaction identifiers corresponding to each of the at least two business operation requests into the initial transaction record to obtain transaction records corresponding to the at least two business operation requests.
[0012] In one embodiment, generating a data update record corresponding to each transaction identifier in the transaction record based on the data update information carried by each of the at least two business operation requests includes:
[0013] For each of the at least two business operation requests, extract the balance record identifier and modified data from the data update information carried by the business operation request.
[0014] Obtain the initial update data record and determine the transaction identifier in the transaction record corresponding to the targeted business operation request;
[0015] The balance record identifier, the modified data, and the transaction identifier corresponding to the targeted business operation request are written into the initial update data record to obtain the corresponding update data record.
[0016] In one embodiment, correcting the transaction identifier in the transaction record based on the operation results of the regular business operations corresponding to the at least two business operation requests includes:
[0017] Based on the operation results of the regular business operations corresponding to the at least two business operation requests, determine the request execution results corresponding to the at least two business operation requests.
[0018] Based on the execution results of each request, the transaction identifier in the transaction record is corrected.
[0019] In one embodiment, determining the request execution result corresponding to each of the at least two business operation requests based on the operation results of the regular business operations corresponding to each of the at least two business operation requests includes:
[0020] For each of the at least two business operation requests, determine the operation execution result of each regular business operation corresponding to the targeted business operation request;
[0021] When the execution results of each routine business operation are determined to be successful, the execution result of the request corresponding to the business operation request is determined to be successful.
[0022] If, among the regular business operations corresponding to the targeted business operation request, there is a regular business operation that corresponds to a failure result, then the request execution result corresponding to the targeted business operation request is determined to be a failure result.
[0023] In one embodiment, correcting the transaction identifier in the transaction record based on the execution results of each of the requests includes:
[0024] Filter out the target business operation request corresponding to the request execution failure result from the at least two business operation requests;
[0025] Determine the target transaction identifier corresponding to each of the target business operation requests;
[0026] Delete the target transaction identifier from the transaction record to obtain the corrected transaction record.
[0027] In one embodiment, the data update record includes at least one balance record identifier and modified data corresponding to each balance record identifier;
[0028] The step of generating a data merge record based on the data update record corresponding to the transaction identifier in the corrected transaction record includes:
[0029] Based on the data update record corresponding to the transaction identifier in the corrected transaction record, determine the modified data corresponding to the same data record identifier;
[0030] The modified data corresponding to the same balance record identifier are merged to obtain the merged data corresponding to each balance record identifier;
[0031] A data merging record is generated based on each balance record identifier and the merging data corresponding to each balance record identifier.
[0032] Secondly, this application also provides a data updating device. The device includes:
[0033] The receiving module is used to receive at least two business operation requests, each business operation request corresponding to at least one business operation, the business operation including a data update operation to update the data to be updated and regular business operations other than the data update operation;
[0034] The generation module is used to execute the regular business operation for the at least two business operation requests, generate transaction records corresponding to the at least two business operation requests, and generate data update records corresponding to each transaction identifier in the transaction records according to the data update information carried by each of the at least two business operation requests.
[0035] The correction module is used to correct the transaction identifier in the transaction record based on the operation results of the regular business operations corresponding to the at least two business operation requests.
[0036] The update module is used to generate a data merge record based on the data update record corresponding to the transaction identifier in the corrected transaction record, and update the data to be updated based on the data merge record.
[0037] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0038] Receive at least two business operation requests, each business operation request corresponding to at least one business operation, the business operations including data update operations to update the data to be updated and regular business operations other than the data update operations;
[0039] For the at least two business operation requests, the regular business operation is executed, and a transaction record corresponding to the at least two business operation requests is generated. Based on the data update information carried by each of the at least two business operation requests, a data update record corresponding to each transaction identifier in the transaction record is generated.
[0040] Based on the operation results of the regular business operations corresponding to the at least two business operation requests, the transaction identifier in the transaction record is corrected.
[0041] A data merge record is generated based on the data update record corresponding to the transaction identifier in the corrected transaction record, and the data to be updated is updated based on the data merge record.
[0042] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0043] Receive at least two business operation requests, each business operation request corresponding to at least one business operation, the business operations including data update operations to update the data to be updated and regular business operations other than the data update operations;
[0044] For the at least two business operation requests, the regular business operation is executed, and a transaction record corresponding to the at least two business operation requests is generated. Based on the data update information carried by each of the at least two business operation requests, a data update record corresponding to each transaction identifier in the transaction record is generated.
[0045] Based on the operation results of the regular business operations corresponding to the at least two business operation requests, the transaction identifier in the transaction record is corrected.
[0046] A data merge record is generated based on the data update record corresponding to the transaction identifier in the corrected transaction record, and the data to be updated is updated based on the data merge record.
[0047] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0048] Receive at least two business operation requests, each business operation request corresponding to at least one business operation, the business operations including data update operations to update the data to be updated and regular business operations other than the data update operations;
[0049] For the at least two business operation requests, the regular business operation is executed, and a transaction record corresponding to the at least two business operation requests is generated. Based on the data update information carried by each of the at least two business operation requests, a data update record corresponding to each transaction identifier in the transaction record is generated.
[0050] Based on the operation results of the regular business operations corresponding to the at least two business operation requests, the transaction identifier in the transaction record is corrected.
[0051] A data merge record is generated based on the data update record corresponding to the transaction identifier in the corrected transaction record, and the data to be updated is updated based on the data merge record.
[0052] The aforementioned data update method, apparatus, computer equipment, storage medium, and computer program product, by receiving at least two business operation requests, each business operation request corresponding to at least one business operation, including data update operations that update the data to be updated and regular business operations other than data update operations; for the at least two business operation requests, executing regular business operations and generating transaction records corresponding to the at least two business operation requests, and generating data update records corresponding to each transaction identifier in the transaction records based on the data update information carried by each of the at least two business operation requests; correcting the transaction identifiers in the transaction records based on the operation results of the regular business operations corresponding to each of the at least two business operation requests; generating a data merge record based on the data update records corresponding to the transaction identifiers in the corrected transaction records, and updating the data to be updated based on the data merge record. This achieves high operability for multiple concurrent requests, meets the requirements for low latency and high efficiency updates, maximizes the high throughput of balance updates, and effectively achieves eventual consistency between balance updates and other business operations. Attached Figure Description
[0053] Figure 1 This is a diagram illustrating the application environment of a data update method in one embodiment.
[0054] Figure 2 This is a flowchart illustrating a data update method in one embodiment;
[0055] Figure 3 This is a schematic diagram illustrating an application scenario of the data update method in one embodiment;
[0056] Figure 4 This is a schematic diagram illustrating an application scenario of the data update method in one embodiment;
[0057] Figure 5 This is a schematic diagram illustrating an application scenario of the data update method in one embodiment;
[0058] Figure 6 This is a flowchart illustrating the data update method in another embodiment;
[0059] Figure 7 This is a structural block diagram of a data update device in one embodiment;
[0060] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0061] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0062] The data update method provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located in the cloud or on other network servers. Terminal 102 generates a data update request and sends it to server 104, causing server 104 to generate a data merging record and update the corresponding data to be updated based on the data merging record. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0063] In one embodiment, such as Figure 2 As shown, a data update method is provided, which is applied to... Figure 1 Taking 104 as an example, the explanation includes the following steps:
[0064] Step 202: Receive at least two business operation requests, each business operation request corresponding to at least one business operation. The business operations include data update operations that update the data to be updated and regular business operations other than data update operations.
[0065] In this application, no specific limitations are made on the business operation requests or the corresponding business operations, which can be set according to actual needs. Optionally, the business operation request is a purchase receipt audit operation request, which corresponds to business verification, balance update, settlement, and other stages, where "balance update" refers to the data update operation.
[0066] Specifically, in ERP (Enterprise Resource Planning) products, balance updates (also known as posting or accounting) are very common business operations. These actions are often not initiated as standalone business operations, but rather as a sub-step within a larger, routine business operation. For example, a purchase receipt approval request requires a series of operations including business verification, balance updates, and settlement. However, the most basic requirement is that the results of the approval and balance update operations must be consistent. Secondly, high performance is expected, especially during frequent balance updates. Here, balance updates correspond to data update operations, and the purchase receipt approval request corresponds to a business operation request, which in turn involves business verification, balance updates, and settlement.
[0067] Step 204: For at least two business operation requests, perform regular business operations and generate transaction records corresponding to the at least two business operation requests. Also, based on the data update information carried by each of the at least two business operation requests, generate a data update record corresponding to each transaction identifier in the transaction records.
[0068] This application does not limit the specific form of transaction records and data update records, and they can be set according to actual needs. Optionally, and understandably, the transaction record is used to record the transaction identifier of the specific transaction involved in the data update operation of each business operation request. Each business operation request corresponds to a transaction identifier. For example, the transaction identifier corresponding to business operation request A is transaction 1, and the transaction identifier corresponding to business operation request B is transaction 2. The data update record can optionally be a log record, used to record the data information that needs to be updated for each business operation request or each transaction identifier. This data information records the original data records that need to be updated and how to update the original data. For example, the data update record corresponding to business operation request A includes the need to update balance record 1 and balance record 2, and the update of balance record 1 needs to increase by 100, and the update of balance record 2 needs to decrease by 50.
[0069] Specifically, and easily understood, the main application scenarios of the embodiments of this application occur in concurrent scenarios. A concurrent scenario refers to a situation in a business system where, at the same time, two or more business operation requests, such as a purchase receipt approval operation, are initiated simultaneously; this is called a concurrent request. When at least two business operation requests are received from the system, each request includes a data update operation and a regular business operation, although the data update operation and the regular business operation may differ for different business operation requests. Therefore, for each business operation request, a transaction identifier is generated for the specific transaction involving the data update operation. The record used to record each transaction identifier is called a transaction record. For each business operation request, data information that needs to be updated for each business operation request or each transaction identifier is generated. This data information records the original data record that needs to be updated and how to update the original data. It is easy to understand that the data update record and the transaction record have a one-to-one correspondence; for example, transaction record 1 corresponds to data update record 1, and transaction record 2 corresponds to data update record 2.
[0070] Step 206: Based on the operation results of the regular business operations corresponding to at least two business operation requests, correct the transaction identifier in the transaction record.
[0071] In essence, to ensure data accuracy, database systems serialize concurrent requests when processing frequently requested balance updates. For example, requests ① and ② are queued and executed sequentially. During request processing, the corresponding balance record is locked, a process known as a database row lock. The waiting process for request ② to complete is called database lock waiting. Because of this lock waiting, if a large number of concurrent requests occur (e.g., 100 concurrent requests, each completing in 1 second), although the business system sends requests to the database simultaneously, the database takes varying amounts of time to complete each request, from 1 second for the first request to 2 seconds for the second, and so on, up to 100 seconds for the last. This database lock waiting phenomenon severely impacts data update speed. To address this lock waiting phenomenon while ensuring data accuracy, this application provides a design for automatically rolling back modified data.
[0072] Specifically, understandably, each business operation request includes a data update operation and multiple regular business operations. During the execution of a business operation request, not only the data update operation is executed, but also the regular business operations, and the result of each regular business operation affects the final update operation. For example, in the execution of business operation request A, it includes data update operation A and regular business operation B, including regular business operation 1, regular business operation 2, and regular business operation 3. In the above steps, based on business operation request A, transaction identifier 1 has been generated in the transaction record and in data update record 1. In the subsequent process of executing business operation request A, if regular business operations 1, 2, and 3 are all executed successfully, then there is no need to roll back transaction identifier 1 in the transaction record. If at least one of regular business operations 1, 2, and 3 fails to execute successfully, then a rollback operation is required for transaction identifier 1 in the transaction record. A rollback operation, in computer science, especially in database management systems, refers to the process of restoring a system or data to a previous, known correct state. This process is primarily used to undo invalid or unintentional operations caused by errors, anomalies, or unsatisfactory changes. In a database environment, rollback is typically implemented through transaction management. When a transaction begins, it records all modifications to the data. If an error occurs during transaction execution or the transaction is cancelled, a rollback operation is triggered. The system reverses the process based on the previously recorded modification information, restoring the data to its state before the transaction began, ensuring data consistency and integrity. Simply put, once transaction identifier 1 is rolled back, subsequent data updates will not be based on data update record 1 corresponding to transaction identifier 1.
[0073] Step 208: Generate a data merge record based on the data update record corresponding to the transaction identifier in the corrected transaction record, and update the data to be updated based on the data merge record.
[0074] In this context, it's easy to understand that when a transaction identifier is updated, the corresponding data update record will not change, but it will affect subsequent data updates. For example, if transaction identifier 1 is rolled back, the original data update record 1 corresponding to the transaction identifier will not change, but in the subsequent update process (the second stage), the data to be updated will not be updated based on data update record 1. If transaction identifier 1 is not rolled back and still exists in the transaction record, then in the subsequent update process (the second stage), the data to be updated will be updated based on data update record 1. This application includes two stages. The first stage mainly involves generating transaction records and data update records based on the business operation request before the results of the regular business operation are obtained. The second stage mainly involves updating the data to be updated based on the transaction identifier and data update record in the transaction record after the results of the regular business operation are obtained. The data merging record is used to record the data obtained after the data to be updated is updated based on the data update record.
[0075] Specifically, after rolling back the transaction identifiers in the transaction record based on the results of routine business operations, the data update records corresponding to the remaining transaction identifiers are found. Then, each data update record is merged to obtain a merged data record. Finally, the corresponding data to be updated is updated based on the merged data record. It is easy to understand that the specific method for merging each data update record to obtain the merged data record is not limited and can be set according to actual needs. Optionally, each merged data record contains information on updating different balance records. For example, merged data record C shows that balance record 1 was increased by 100 and balance record 2 was decreased by 30. The data to be updated is balance record 1 as 50 and balance record 2 as 50. Therefore, after updating the corresponding data to be updated based on the merged data record, balance record 1 becomes 150 and balance record 2 becomes 50.
[0076] In one embodiment, at least two transaction identifiers corresponding to each of the business operation requests are generated; an initial transaction record is obtained, and the transaction identifiers corresponding to each of the at least two business operation requests are written into the initial transaction record to obtain a transaction record corresponding to the at least two business operation requests.
[0077] It is easy to understand that this application does not limit the specific form of the initial transaction record, which can be set according to actual needs. Optionally, the initial transaction record is a blank record without recording any information.
[0078] Specifically, after receiving at least two business operation requests, a unique transaction identifier is generated for each request. One function of the transaction identifier is to mark each business operation request. Then, the unique transaction identifier for each business operation request is filled into a pre-set blank record, resulting in a transaction record containing the unique transaction identifier for each business operation request.
[0079] By writing the transaction identifier of each business operation request into the initial transaction record, a transaction record corresponding to at least two business operation requests is generated. This allows different business operations to be associated, forming a complete transaction execution record. The transaction record records the execution result and status of each business operation request. If a request fails or an error occurs, error handling and rollback operations can be performed based on the transaction record to ensure data integrity and consistency.
[0080] In one embodiment, for each of the at least two business operation requests, the balance record identifier and modified data are extracted from the data update information carried by the business operation request; an initial update data record is obtained, and the transaction identifier corresponding to the business operation request in the transaction record is determined; the balance record identifier, modified data, and the transaction identifier corresponding to the business operation request are written into the initial update data record to obtain the corresponding update data record.
[0081] In this application, the identification and modification of balance records are not specifically limited and can be set according to actual needs. Optionally, a balance record refers to a record that uses one or more columns to count a set of values. The multiple columns are called dimension columns, the value columns are called balance columns, and the entire record is called a balance record. Each balance record is determined by the value of the dimension columns and is unique. For example, balance record 1: A1 organization + B1 material + C1 warehouse basic quantity = 100, which is a balance record. In this case, organization, material, and warehouse are called dimension columns, and basic quantity is called balance column. A1 organization + B1 material + C1 warehouse is unique. Different values in any dimension column result in different records. For example, balance record 2: A2 organization + B1 material + C1 warehouse basic quantity = 200, which is a completely different balance record due to the different organization. The data update information carried in the business operation request includes "A1 Organization + B1 Material + C1 Warehouse Basic Quantity = 100" and "A2 Organization + B1 Material + C1 Warehouse Basic Quantity = 200". In addition, the data update information also includes information on modifications to the basic quantities in the balance records carried in a specific business operation request. The balance record identifier in this application is used to briefly identify "A1 Organization + B1 Material + C1 Warehouse Basic Quantity = 100" and "A2 Organization + B1 Material + C1 Warehouse Basic Quantity = 200", namely Balance Record 1, Balance Record 2, etc. The data modification mainly involves modifying the basic quantities in the balance records, such as "Basic Quantity + 100", "Basic Quantity + 0", "Basic Quantity - 50", etc.
[0082] Specifically, for each business operation request, the data update information carried in each business operation request is first obtained. For example, the data update information A1 organization + B1 material + C1 warehouse basic quantity = 100 carried in business operation request A is obtained. Then, from the data update information carried in business operation request A: balance record 1: A1 organization + B1 material + C1 warehouse basic quantity = 100 and the basic quantity in balance record 1 is increased by 100, the corresponding balance record identifier is extracted, which is balance record 1. Then, the corresponding modified data is extracted, which is +100. Next, the initial update data record is obtained. Similarly, the specific form of the initial update data record is not limited. Optionally, the initial update data record is a blank record. Then, the transaction identifier 'a' corresponding to business operation request A generated in the previous steps, the balance record identifier (balance record 1), and the corresponding modified data (+100) are filled into the initial update data record to obtain the update data record.
[0083] By identifying the transaction identifier corresponding to the business operation request in the transaction record and writing it into the update data record, different data update operations can be associated with their corresponding transactions, providing a complete transaction execution record. Furthermore, the balance record identifier and modified data are extracted from the business operation request and written into the update data record. This facilitates the classification and processing of different data update operations, simplifying subsequent data analysis and management.
[0084] In one embodiment, the request execution result corresponding to each of the at least two business operation requests is determined based on the operation result of the regular business operation corresponding to each of the at least two business operation requests; and the transaction identifier in the transaction record is corrected based on the execution result of each request.
[0085] In this context, it's easy to understand that each business operation request requires the execution of multiple regular business operations, and each regular business operation corresponds to an execution result. The execution result of each regular business operation, in turn, affects the correction of the transaction identifier.
[0086] Specifically, taking business operation request A as an example, which is one of at least two business operation requests, the transaction record corresponding to business operation request A is transaction record 1, the transaction identifier corresponding to transaction record 1 is transaction identifier 1, and the data update record corresponding to transaction identifier 1 is data update record 1. Business operation request A includes regular business operation 1, regular business operation 2, and regular business operation 3. If regular business operation 1, regular business operation 2, and regular business operation 3 all execute successfully, then there is no need to roll back transaction identifier 1 in transaction record 1. If at least one of the regular business operations 1, regular business operation 2, and regular business operation 3 fails to execute successfully, then a rollback operation is required for transaction identifier 1 in transaction record 1. It is easy to understand that when transaction identifier 1 is rolled back, data updates will not be performed based on data update record 1 corresponding to transaction identifier 1 during subsequent data updates. It is easy to understand that a rollback operation is a correction operation.
[0087] By correcting the transaction identifier in the transaction record, consistency between the transaction record and the actual business operation request execution result is ensured. This helps maintain data consistency and ensures data correctness and reliability. Furthermore, it completely resolves lock wait issues.
[0088] In one embodiment, for each of at least two business operation requests, the operation execution result of each regular business operation corresponding to the targeted business operation request is determined; when the operation execution results of each determined regular business operation are all successful operation results, the request execution result corresponding to the targeted business operation request is determined as a successful request execution result; when there is a regular business operation corresponding to a failed operation result among the regular business operations corresponding to the targeted business operation request, the request execution result corresponding to the targeted business operation request is determined as a failed request execution result.
[0089] A single business operation request comprises multiple routine business operations, and the execution result of each routine business operation includes both a failure result and a success result. The execution result of each routine business operation determines the success result of the business operation request, which in turn includes both a successful execution result and a failure result.
[0090] Specifically, taking business operation request A, one of at least two business operation requests, as an example, business operation request A includes regular business operation a, regular business operation b, and regular business operation c. If the execution results of regular business operations a, b, and c are all successful, then the execution result of business operation request A is a successful execution result. If at least one of the execution results of regular business operations a, b, and c is a failed execution result, then the execution result of business operation request A is a failed execution result.
[0091] By evaluating the results of routine business operations, decisions can be quickly made regarding whether to continue processing a request. For requests where operations fail, subsequent processing can be stopped early, saving resources and time and improving efficiency. Furthermore, requests can be prioritized or resources dynamically allocated based on the results of routine business operations. This helps to rationally utilize system resources, improve resource utilization, and enhance overall system performance.
[0092] In one embodiment, target business operation requests corresponding to the failure result of request execution are selected from at least two business operation requests; the target transaction identifier corresponding to each target business operation request is determined; the target transaction identifier is deleted from the transaction record to obtain the corrected transaction record.
[0093] Specifically, in the aforementioned steps, each business operation request corresponds to a request execution result, either a failure result or a success result. Therefore, from at least two business operation requests, the business operation requests with a failure result are selected and referred to as target business operation requests. Since each business operation request corresponds to a transaction identifier, the transaction identifier corresponding to the target business operation request is the target transaction identifier. The target transaction identifier is deleted from the transaction record, resulting in a corrected transaction record. It is easy to understand that the transaction identifiers included in the corrected transaction record are all the business identifiers corresponding to business operation requests with a success result.
[0094] By deleting the target transaction identifier from the corrected transaction record, invalid or erroneous data can be cleaned up. This helps optimize database performance and reduce unnecessary storage and computational overhead. Furthermore, by deleting the target transaction identifier from the corrected transaction record, it is possible to roll back or recover business operations that fail to execute. This facilitates rapid recovery to a stable state in the event of system failures or errors.
[0095] In one embodiment, modified data corresponding to the same data record identifier is determined based on the data update record corresponding to the transaction identifier in the corrected transaction record; the modified data corresponding to the same balance record identifier are merged to obtain the merged data corresponding to each balance record identifier; and a data merge record is generated based on each balance record identifier and the merged data corresponding to each balance record identifier.
[0096] Specifically, after rolling back the transaction identifiers in the transaction record based on the results of routine business operations, the data update records corresponding to the remaining transaction identifiers are found. Then, each data update record is merged to obtain a merged data record. For example, taking business operation request A as an example, business operation request A corresponds to transaction identifier 1 in the transaction record. Balance record 1 corresponding to business operation request A: A1 organization + B1 material + C1 warehouse basic quantity = 100, and the corresponding modified data is +100. And balance record 2: A2 organization + B2 material + C2 warehouse basic quantity = 200, and the corresponding modified data is +200. Taking business operation request B as an example, business operation request B corresponds to transaction identifier 2 in the transaction record. Balance record 1 corresponding to business operation request B: A1 organization + B1 material + C1 warehouse basic quantity = 100, and the corresponding modified data is +500. And balance record 2: A2 organization + B2 material + C2 warehouse basic quantity = 200, and the corresponding modified data is +300. After correction, only transaction identifier 1 and transaction identifier 2 remain in the corrected transaction records. Therefore, the data update records are balance record 1+600 and balance record 2+500. Balance record 1+600 and balance record 2+500 together constitute the data merge record for business operation requests A and B.
[0097] In one example, when a business operation request is used to increase the data to be updated, the corresponding modified data is a positive number; when a business operation request is used to decrease the data to be updated, the corresponding modified data is a negative number; the modified data corresponding to the same data record identifier are superimposed to obtain the merged data corresponding to each data record identifier.
[0098] By merging modified data corresponding to records with the same balance identifier, redundant calculations and merging operations during the data merging process can be reduced, improving the efficiency and performance of data merging. Furthermore, by generating merged data records, data updates in transaction records can be processed promptly, preventing errors or anomalies caused by failed update corrections. This helps improve system reliability and stability, and reduces data processing risks.
[0099] In one embodiment, for each balance record identifier in the merged record, the data to be updated corresponding to the corresponding balance record identifier in the preset balance table is determined; and the data to be updated corresponding to the corresponding data record identifier is updated according to the merged data corresponding to the corresponding balance record identifier.
[0100] In this application, a balance sheet refers to a table structure used to store balance records. It is typically stored in a database and consists of a header and a title. The header records the dimension columns and the balance column, while the title records the specific value of each balance record. It can also be called an account table. The data to be updated in the balance sheet refers to the initial balance data of each balance record that needs to be updated. For example, the initial balance data in the balance sheet might include balance record 1: 100 and balance record 2: 200. Understandably, each balance record identifier in the merged record has a one-to-one correspondence with the initial balance data in the balance sheet.
[0101] Specifically, firstly, based on the identifier of each balance record in the merged records, the data to be updated corresponding to each balance record identifier is determined in a preset balance table. Then, based on the merged data corresponding to the balance record identifiers in the aforementioned steps (i.e., the merged data records), the data to be updated is updated. For example, if the data to be updated is balance record 1: 50 and balance record 2: 20, and the merged data corresponding to the balance record identifiers (i.e., the merged data records) is balance record 1: +40 and balance record 2: -10, then the updated data will be balance record 1: 90 and balance record 2: 10.
[0102] By identifying the associated data to be updated based on the balance record identifiers in the merged records, the search and matching process for data updates can be reduced, improving the efficiency and performance of data updates. Furthermore, updating the data to be updated based on the balance record identifiers in the merged records ensures that the updated data is consistent with the corresponding data in the pre-defined balance table. This helps maintain data consistency and accuracy, avoiding data errors and inconsistencies.
[0103] In one embodiment, the application scenario of the data update method in this application is specifically described as follows: Transaction 1 and Transaction 2 both represent transaction identifiers. Balance update represents a data update operation. Service failure or audit failure both refer to the operation failing. Record 1 and Record 2 refer to data update records. Merging records refer to data merging records. Balance record 1 and Balance record 2 refer to balance record identifiers. The core devices involved in the data update method in this application mainly include a transaction manager, a record manager, and a message manager. The transaction manager is mainly used to manage which operations need to use the same database transaction to complete the addition and modification of data, which must rely on the database's inherent strong consistency mechanism. In the first stage of the operation, the transaction manager generates two database transactions. The first transaction consists of two business actions: audit operation and generation of transaction records. These two are strongly consistent; that is, if the audit operation is successful, the transaction record will definitely be generated successfully; if it fails, the transaction record will not be recorded successfully, and the corresponding transaction record data cannot be found. The second transaction is a batch of saved log records. For the same batch of log records, either all are recorded successfully or all fail. Meanwhile, the transaction manager implements transaction orchestration and exception notification rollback functionality. In the first phase, it controls the second transaction, nested within the first; that is, transaction 2 is initiated when transaction 1 has started but not yet marked as finished. Any exception encountered within the transaction will trigger a data rollback. In the second phase, the transaction manager generates only one database transaction, namely, updating balance records in batches based on the log merging results. The record manager is mainly used to manage the data produced in all phases, recording which database and location each record exists in. The recorded data includes transaction records, log records, and balance records. The message manager, acting as a message pipeline, is mainly used to receive messages and immediately send them to the corresponding thread. After receiving the message, the thread executes the response content according to the message content. Here, it notifies the second phase to start merging log records and updating balance records. The following are three application scenarios of the data update method in this application: Audit 1 and Audit 2, both concurrent requests. Balance updates are triggered during the audit process, and after the balance update is completed, regular business operations are executed, the result of which may affect the audit result.
[0104] refer to Figure 3 Both Audit 1 and Audit 2 were successful. Therefore, the corresponding transaction records and log records generated for Audit 1 and Audit 2 will definitely show successful entries. Upon receiving the notification in the second stage, the records for Transaction 1 and Transaction 2 can be found, their corresponding log records can be located, and the records can be merged and updated. This ensures the eventual consistency between the audit and balance update results, while the merged update reduces the number of updates, significantly improving update efficiency.
[0105] refer toFigure 4 The first review was successful, while the second review failed for an unknown reason. As mentioned in the transaction manager documentation, transaction records and review operations rely on strong consistency with database transactions; therefore, transaction 2 was automatically rolled back by the database. Only the transaction 1 record remains. Upon receiving the notification in the second phase, the system can verify the existence of the transaction 1 record, locate its corresponding log record, and merge and update it. This ensures eventual consistency between the review and balance update results, while the merged update reduces the number of updates, significantly improving update efficiency.
[0106] refer to Figure 5 In both Transaction 1 and Transaction 2, the service failed after the balance update was completed, as the transaction records were not logged as successful. However, these records were automatically rolled back by the database. In the second phase, upon receiving notification that neither Transaction 1 nor Transaction 2 records could be found, the database would not check the logs, and the balance would not be updated. This ensured eventual consistency between the audit and balance update results, while merging updates reduced the number of updates, significantly improving update efficiency.
[0107] In one embodiment, such as Figure 6 As shown, it includes the following steps:
[0108] Step 602: Receive at least two business operation requests, each business operation request corresponding to at least one business operation. The business operations include data update operations that update the data to be updated and regular business operations other than data update operations.
[0109] Step 604: Generate transaction identifiers corresponding to at least two business operation requests; obtain initial transaction records, and write the transaction identifiers corresponding to the at least two business operation requests into the initial transaction records to obtain transaction records corresponding to the at least two business operation requests; for each of the at least two business operation requests, extract the balance record identifier and modified data from the data update information carried by the targeted business operation request; obtain initial update data records and determine the transaction identifiers corresponding to the targeted business operation requests in the transaction records; write the balance record identifier, modified data, and the transaction identifiers corresponding to the targeted business operation requests into the initial update data records to obtain the corresponding update data records;
[0110] Step 606: For each of the at least two business operation requests, determine the execution result of each regular business operation corresponding to the targeted business operation request; if the execution results of each regular business operation are all successful, determine the execution result of the request corresponding to the targeted business operation request as a successful execution result; if among the regular business operations corresponding to the targeted business operation request, there is a regular business operation corresponding to a failed execution result, determine the execution result of the request corresponding to the targeted business operation request as a failed execution result; based on each execution result, filter out the target business operation request corresponding to the failed execution result from the at least two business operation requests; determine the target transaction identifier corresponding to each target business operation request; delete the target transaction identifier from the transaction record to obtain the corrected transaction record;
[0111] Step 608: Based on the data update records corresponding to the transaction identifiers in the corrected transaction records, determine the modified data corresponding to the same data record identifier; merge the modified data corresponding to the same balance record identifier to obtain the merged data corresponding to each balance record identifier; generate a data merge record based on each balance record identifier and its corresponding merged data; for each balance record identifier in the merged record, determine the data to be updated in the preset balance table corresponding to the targeted balance record identifier; update the data to be updated corresponding to the targeted data record identifier based on the merged data corresponding to the targeted balance record identifier.
[0112] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0113] Based on the same inventive concept, this application also provides a data update apparatus for implementing the data update method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more data update apparatus embodiments provided below can be found in the limitations of the data update method described above, and will not be repeated here.
[0114] In one embodiment, such as Figure 7 As shown, a data update device 700 is provided, including: a receiving module 702, a generating module 704, a correction module 706, and an update module 708, wherein:
[0115] The receiving module 702 is used to receive at least two service operation requests, each service operation request corresponding to at least one service operation, and the at least one service operation includes a data update operation to update the data to be updated and a regular service operation other than the data update operation.
[0116] The generation module 704 is used to perform regular business operations for at least two business operation requests, generate transaction records corresponding to the at least two business operation requests, and generate data update records corresponding to each transaction identifier in the transaction records based on the data update information carried by each of the at least two business operation requests.
[0117] The correction module 706 is used to correct the transaction identifier in the transaction record based on the operation results of the regular business operations corresponding to at least two business operation requests.
[0118] The update module 708 is used to generate a data merge record based on the data update record corresponding to the transaction identifier in the corrected transaction record, and update the data to be updated based on the data merge record.
[0119] In one embodiment, the generation module 704 is used to generate transaction identifiers corresponding to at least two business operation requests; obtain an initial transaction record; and write the transaction identifiers corresponding to at least two business operation requests into the initial transaction record to obtain transaction records corresponding to at least two business operation requests.
[0120] In one embodiment, the generation module 704 is configured to, for each of at least two business operation requests, extract the balance record identifier and modified data from the data update information carried by the business operation request; obtain an initial update data record and determine the transaction identifier in the transaction record corresponding to the business operation request; and write the balance record identifier, modified data, and the transaction identifier corresponding to the business operation request into the initial update data record to obtain the corresponding update data record.
[0121] In one embodiment, the correction module 706 is used to determine the request execution result corresponding to each of the at least two business operation requests based on the operation results of other business operations corresponding to each of the at least two business operation requests; and to correct the transaction identifier in the transaction record based on each request execution result.
[0122] In one embodiment, the correction module 706 is configured to, for each of at least two business operation requests, determine the operation execution result of each regular business operation corresponding to the targeted business operation request; when the determined operation execution results of each regular business operation are all successful operation results, determine the request execution result corresponding to the targeted business operation request as a successful request execution result; when among the regular business operations corresponding to the targeted business operation request, there is a regular business operation corresponding to a failed operation result, determine the request execution result corresponding to the targeted business operation request as a failed request execution result.
[0123] In one embodiment, the correction module 706 is used to filter out the target business operation request corresponding to the request execution failure result from at least two business operation requests; determine the target transaction identifier corresponding to each target business operation request; delete the target transaction identifier in the transaction record to obtain the corrected transaction record.
[0124] In one embodiment, the update module 708 is used to determine the modified data corresponding to the same data record identifier based on the data update record corresponding to the transaction identifier in the corrected transaction record; merge the modified data corresponding to the same balance record identifier to obtain the merged data corresponding to each balance record identifier; and generate a data merge record based on each balance record identifier and the merged data corresponding to each balance record identifier.
[0125] Each module in the aforementioned data update device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.
[0126] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data related to data updates. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a data update method.
[0127] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0128] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0129] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0130] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0131] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0132] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this 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), magnetic 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0133] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0134] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A data update method, characterized in that, The method includes: Receive at least two business operation requests, each business operation request corresponding to at least one business operation, the business operations including data update operations to update the data to be updated and regular business operations other than the data update operations; For the at least two business operation requests, the regular business operation is executed, and a transaction record corresponding to the at least two business operation requests is generated. Based on the data update information carried by each of the at least two business operation requests, a data update record corresponding to each transaction identifier in the transaction record is generated. Based on the operation results of the regular business operations corresponding to the at least two business operation requests, the transaction identifier in the transaction record is corrected. Based on the data update record corresponding to the transaction identifier in the corrected transaction record, a data merge record is generated, and the data to be updated is updated based on the data merge record; The data update record includes at least one balance record identifier and the modified data corresponding to each balance record identifier; The step of generating a data merge record based on the data update record corresponding to the transaction identifier in the corrected transaction record includes: Based on the data update record corresponding to the transaction identifier in the corrected transaction record, determine the modified data corresponding to the same balance record identifier; The modified data corresponding to the same balance record identifier are merged to obtain the merged data corresponding to each balance record identifier; A data merging record is generated based on each balance record identifier and the merging data corresponding to each balance record identifier.
2. The method according to claim 1, characterized in that, The generation of transaction records corresponding to the at least two business operation requests includes: Generate transaction identifiers corresponding to each of the at least two business operation requests; Obtain an initial transaction record, and write the transaction identifiers corresponding to each of the at least two business operation requests into the initial transaction record to obtain transaction records corresponding to the at least two business operation requests.
3. The method according to claim 1, characterized in that, The step of generating a data update record corresponding to each transaction identifier in the transaction record based on the data update information carried by each of the at least two business operation requests includes: For each of the at least two business operation requests, extract the balance record identifier and modified data from the data update information carried by the business operation request. Obtain the initial update data record and determine the transaction identifier in the transaction record corresponding to the targeted business operation request; The balance record identifier, the modified data, and the transaction identifier corresponding to the targeted business operation request are written into the initial update data record to obtain the corresponding update data record.
4. The method according to claim 1, characterized in that, The step of correcting the transaction identifier in the transaction record based on the operation results of the regular business operations corresponding to the at least two business operation requests includes: Based on the operation results of the regular business operations corresponding to the at least two business operation requests, determine the request execution results corresponding to the at least two business operation requests. Based on the execution results of each request, the transaction identifier in the transaction record is corrected.
5. The method according to claim 4, characterized in that, The step of determining the request execution result corresponding to each of the at least two business operation requests based on the operation results of the regular business operations corresponding to each of the at least two business operation requests includes: For each of the at least two business operation requests, determine the operation execution result of each regular business operation corresponding to the targeted business operation request; When the execution results of all regular business operations are determined to be successful, the execution result of the request corresponding to the business operation request is determined to be successful. If, among the regular business operations corresponding to the targeted business operation request, there is a regular business operation that corresponds to a failure result, then the request execution result corresponding to the targeted business operation request is determined to be a failure result.
6. The method according to claim 4, characterized in that, The step of correcting the transaction identifier in the transaction record based on the execution results of each request includes: Filter out the target business operation request corresponding to the request execution failure result from the at least two business operation requests; Determine the target transaction identifier corresponding to each of the target business operation requests; Delete the target transaction identifier from the transaction record to obtain the corrected transaction record.
7. A data update device, characterized in that, The device includes: The receiving module is used to receive at least two business operation requests, each business operation request corresponding to at least one business operation, the business operation including a data update operation to update the data to be updated and regular business operations other than the data update operation; The generation module is used to perform regular business operations for the at least two business operation requests, generate transaction records corresponding to the at least two business operation requests, and generate data update records corresponding to each transaction identifier in the transaction records according to the data update information carried by each of the at least two business operation requests; the data update records include at least one balance record identifier and modified data corresponding to each balance record identifier. The correction module is used to correct the transaction identifier in the transaction record based on the operation results of the regular business operations corresponding to the at least two business operation requests. The update module is used to update records according to the data corresponding to the transaction identifier in the corrected transaction record, determine the modified data corresponding to the same balance record identifier, merge the modified data corresponding to the same balance record identifier, and obtain the merged data corresponding to each balance record identifier; generate a data merge record according to each balance record identifier and the merged data corresponding to each balance record identifier, and update the data to be updated according to the data merge record.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data editing method and device based on knowledge graph, equipment and storage medium
CN116304102A
Database processing method and device, equipment, storage medium and program product
CN116932563A