CN-122019227-A - Method, device, equipment and medium for processing database business
Abstract
The invention discloses a method, a device, equipment and a medium for processing a database service, which belong to the field of database service processing, and the method comprises the steps of acquiring the operation of a user for processing the service of data of a distributed database, and determining whether the service operation is a conflict event according to the conflict detection processing result of the service operation; if the business operation is determined to be a conflict event, determining a conflict level of the conflict event according to a business field and business constraint corresponding to the business operation; and dynamically matching a corresponding target processing strategy based on the conflict level, and executing the business operation based on the target processing strategy. The invention processes by matching different strategies through the grades of the service conflict, not only can fit and adapt to different actual service scenes, but also can avoid the condition of data loss caused by neglecting part of service operations, does not need to trigger the operations for a plurality of times, and can improve the service processing efficiency and the processing precision.
Inventors
- LIN XIZHEN
- FANG QIFENG
- YU JIAFA
- FENG SHIQUAN
- WANG BEIBEI
- XIE ZHOULONG
- CAI ZHENHAO
Assignees
- 广州市双照电子科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260114
Claims (10)
- 1. A method for processing a database service, the method comprising: acquiring business operation of a user, and determining whether the business operation is a conflict event according to the result of conflict detection processing of the business operation, wherein the conflict detection processing is processing for detecting a main key of an operation type of the business operation, resources used by the operation and semantics of the operation, and the business operation is processing of the business operation of the user on data of a distributed database; If the business operation is determined to be a conflict event, determining a conflict level of the conflict event according to a business field and business constraint corresponding to the business operation, wherein the business field is a field set processed by executing the business operation; And dynamically matching a corresponding target processing strategy based on the conflict level, and executing the business operation based on the target processing strategy.
- 2. The method for processing a service of a database according to claim 1, wherein the steps of acquiring a service operation of a user, and determining whether the service operation is a collision event according to a result of collision detection processing of the service operation, comprise: acquiring at least two business operations of a user, and classifying the business operations to obtain operation types; Performing conflict detection processing according to the operation types to obtain a conflict detection result, wherein the conflict detection processing comprises whether main keys of the operation types are consistent, whether the execution sequences of the operation types are executed in parallel, whether resource competition exists in the operation types and whether semantics of the operation types are compatible in a preset time window; If the conflict detection result is that the primary keys of the operation types are consistent, the execution sequence is parallel execution, resource competition exists and semantics are incompatible in a preset time window, determining that the business operation is a conflict event; and if the conflict detection result is that the primary keys of the operation types are inconsistent, the execution sequence is not parallel execution, no resource competition or semantic compatibility exists in the preset time window, determining that the business operation is not a conflict event.
- 3. The method for processing the service of the database according to claim 1, wherein determining the conflict level of the conflict event according to the service field and the service constraint corresponding to the service operation comprises: Acquiring a service field corresponding to each service operation, and determining field intersections of a plurality of service fields, wherein the service fields comprise changed fields after the service operation is executed and data fields required by the service operation; If the field intersection is empty, determining the conflict level of the conflict event as a first-level conflict; If the field intersection is non-null and the field of the field intersection has only a data field, determining that the conflict level of the conflict event is a secondary conflict; If the field intersection is non-null and the field of the field intersection comprises a change field, determining that the conflict level of the conflict event is three-level conflict; And if the service operation does not meet the preset service constraint, determining that the conflict level of the conflict event is a four-level conflict.
- 4. A method of processing a database according to claim 3, wherein said dynamically matching a corresponding target processing policy based on said conflict level and performing said business operation based on said target processing policy comprises: and if the conflict level is a primary conflict, taking a preset parallel processing mode as a target processing strategy, and executing the business operation in parallel based on the target processing strategy.
- 5. A method of processing a database according to claim 3, wherein said dynamically matching a corresponding target processing policy based on said conflict level and performing said business operation based on said target processing policy comprises: If the conflict level is the secondary conflict, a preset row-level intelligent merging mode is used as a target processing strategy, and service operation is executed based on the target processing strategy; The column-level intelligent merging strategy is an operation strategy for updating data according to the change field of the business operation at the same time.
- 6. A method of processing a database according to claim 3, wherein said dynamically matching a corresponding target processing policy based on said conflict level and performing said business operation based on said target processing policy comprises: If the conflict level is three-level conflict, matching from a preset strategy configuration frame according to the label of the service operation to obtain a target processing strategy, and executing the service operation based on the target processing strategy, wherein the preset strategy frame is a strategy frame generated by combining one or more conflict resolution strategies in a plug-and-pull mode; when the target processing strategy executes errors, executing service operation according to a preset time stamp priority strategy; the target processing strategy comprises a source priority strategy, a business logic callback strategy and a row-level intelligent merging strategy; the source priority strategy is a strategy for screening one target operation from a plurality of business operations and executing the target operation according to the priority of the starting point of the business operation; The business logic callback strategy is used for carrying out basic verification on the operation result of the business operation, and merging or backtracking the operation result according to the basic verification result; the column-level intelligent merging strategy is an operation strategy for updating data according to the change field of the service operation at the same time; the preset timestamp priority strategy is a strategy for screening one target operation from a plurality of business operations and executing the target operation according to a time node triggering the business operations.
- 7. A method of processing a database according to claim 3, wherein said dynamically matching a corresponding target processing policy based on said conflict level and performing said business operation based on said target processing policy comprises: And if the conflict level is a four-level conflict, using a service suspension mode as a target processing strategy, and generating an alarm notification after suspending executing the service operation based on the target processing strategy.
- 8. A business processing apparatus of a database, the apparatus comprising: The system comprises a determining module, a processing module and a processing module, wherein the determining module is used for acquiring business operations of a user and determining whether the business operations are conflict events according to the result of conflict detection processing of the business operations, wherein the conflict detection processing is processing for detecting a main key of an operation type of the business operations, resources used by the operations and semantics of the operations, and the business operations are operations of the user for carrying out business processing on data of a distributed database; the level module is used for determining the conflict level of the conflict event according to the service field and the service constraint corresponding to the service operation if the service operation is determined to be the conflict event, wherein the service field is a field set processed by executing the service operation; And the processing module is used for dynamically matching the corresponding target processing strategy based on the conflict level and executing the business operation based on the target processing strategy.
- 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements a method for processing services of a database according to any of claims 1-7 when executing the program.
- 10. A computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method of business processing of a database according to any one of claims 1-7.
Description
Method, device, equipment and medium for processing database business Technical Field The present invention relates to the field of database data recovery technologies, and in particular, to a method, an apparatus, a device, and a medium for processing a database service. Background Nodes of the distributed database are deployed on different machines, different partitions are processed by different sites (sites) in the nodes, and the sites (sites) of each Node have independent CPUs and memories, and the transactions are processed in a single-line Cheng Chuanhang lock-free mode so as to improve processing efficiency. However, during the use process, database conflicts are easily caused by improper access and locking mechanisms, resource competition and the like. While concurrent access is the most common primary reason. Conflicts are easily created when multiple users or applications are to access and modify the same data in the database at the same time due to business requirements. Frequent collisions not only increase system overhead and reduce performance, but also multiple nodes modify the same data at the same time, which results in inconsistent service processing results, damages data integrity, and affects service accuracy (such as inventory errors and transaction failures). In order to eliminate the conflict, the current common service processing method is to preset the latest write-in priority (LAST WRITE WINS, LWW) strategy, wherein the latest triggered service processing operation is used as the priority operation to execute the latest write-in service processing operation, and the prior write-in service processing operation is ignored to avoid the conflict between the previous and the next service processing operation. The method has the technical problems that a single processing strategy is difficult to adapt to different complex service scenes, and for concurrent service processing operation, partial operation is preferentially ignored in the latest service processing, so that data of partial operation is lost, the service which is ignored in the prior art is needed to be re-executed, and the processing efficiency is reduced. Disclosure of Invention The invention provides a method, a device, equipment and a medium for processing a database service, which can solve the technical problems that in the service processing process in the prior art, data is easy to be lost and the service processing efficiency is reduced by eliminating conflict through a single processing strategy. A first aspect of an embodiment of the present invention provides a method for processing a service of a database, where the method includes: acquiring business operation of a user, and determining whether the business operation is a conflict event according to the result of conflict detection processing of the business operation, wherein the conflict detection processing is processing for detecting a main key of an operation type of the business operation, resources used by the operation and semantics of the operation, and the business operation is processing of the business operation of the user on data of a distributed database; If the business operation is determined to be a conflict event, determining a conflict level of the conflict event according to a business field and business constraint corresponding to the business operation, wherein the business field is a field set processed by executing the business operation; And dynamically matching a corresponding target processing strategy based on the conflict level, and executing the business operation based on the target processing strategy. A second aspect of an embodiment of the present invention provides a service processing apparatus for a database, the apparatus including: The system comprises a determining module, a processing module and a processing module, wherein the determining module is used for acquiring business operations of a user and determining whether the business operations are conflict events according to the result of conflict detection processing of the business operations, wherein the conflict detection processing is processing for detecting a main key of an operation type of the business operations, resources used by the operations and semantics of the operations, and the business operations are operations of the user for carrying out business processing on data of a distributed database; the level module is used for determining the conflict level of the conflict event according to the service field and the service constraint corresponding to the service operation if the service operation is determined to be the conflict event, wherein the service field is a field set processed by executing the service operation; And the processing module is used for dynamically matching the corresponding target processing strategy based on the conflict level and executing the business operation based on the target processing strategy. Compared with the prior