Data detection method and device based on change behavior and computer equipment

By monitoring and intercepting database operation commands, data detection is realized using the MyBatis framework, which solves the problem of high cost of monitoring tools and improves data detection efficiency and information transmission accuracy.

CN120448423APending Publication Date: 2025-08-08SHANGHAI RUIDE HUIZHI TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510446601.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-10
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

In existing database-based project management, the cost of forwarding change data by configuring the listening tool is high, and the listening tool needs to be customized for different types of databases, which increases management costs.

Method used

By listening and intercepting the operation commands of the target database, obtain operation behavior, operation objects and change data, determine operation strategies based on the operation behavior, execute operation commands and query behaviors, and send query results and change data to the client. The MyBatis framework is used to implement data monitoring and query, reducing dependence on log parsing and listening tools.

Benefits of technology

No need to wait for the database to generate log files, which reduces the cost of configuring customized listening tools, improves data detection efficiency, and ensures the maximum amount of information transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448423A_ABST
    Figure CN120448423A_ABST
Patent Text Reader

Abstract

The embodiment of the invention belongs to the technical field of computers, and particularly relates to a data detection method and device based on change behaviors and computer equipment. The method comprises the steps that an operation command for a target database is monitored and intercepted; obtaining an operation behavior, an operation object and change data from the operation command; determining an operation strategy of the maximum query information amount according to the operation behavior, wherein the operation strategy is used for determining a sequence of executing the operation command and executing the query behavior aiming at the operation object; and executing the operation command and the query behavior according to the operation strategy, and sending a query result and the change data to a corresponding client. According to the embodiment of the invention, the problem of high cost of forwarding the changed data by configuring a monitoring tool in the existing project management based on the database is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of computer technology, and more particularly to a data detection method, apparatus, and computer equipment based on change behavior. Background Art

[0002] In database-based project management, after the service provider updates the database data, the monitoring tool (such as Maxwell, Canal, etc.) will read and parse the database Binlog log, and send the parsed data content before and after the database update to the message middleware, which will forward it to the corresponding client. However, in this way, it is necessary to build a system environment for independently deploying monitoring tools, which has high operation and maintenance costs in the management of small and medium-sized projects and is difficult to promote. In addition, existing monitoring tools are customized for databases. When multiple different types of databases are needed in project management, different monitoring tools need to be customized, which increases management costs. Summary of the Invention

[0003] The embodiments of this specification provide a data detection method, apparatus, and computer device based on change behavior, which are used to solve or at least partially solve the problem of high cost of forwarding change data by configuring monitoring tools in existing database-based project management.

[0004] In order to solve the above technical problems, a first aspect of an embodiment of this specification provides a data detection method based on change behavior, the method comprising:

[0005] Monitor and intercept operation commands targeting the target database;

[0006] Obtaining operation behavior, operation object and change data from the operation command;

[0007] Determining an operation strategy for maximizing the amount of query information based on the operation behavior, wherein the operation strategy is used to determine the order of executing the operation command and executing the query behavior for the operation object;

[0008] The operation command and the query behavior are executed according to the operation strategy, and the query result and the changed data are sent to the corresponding client.

[0009] Furthermore, when the operation behavior is data deletion, the operation strategy includes:

[0010] generating a query command based on the operation object;

[0011] Execute a query action on the operation object according to the query command;

[0012] After receiving the notification that the query behavior is successfully executed, the operation command is executed.

[0013] Furthermore, when the operation behavior is data insertion, the operation strategy includes:

[0014] Executing the operation command;

[0015] After receiving a notification that the operation command is successfully executed, generating a query command based on the operation object;

[0016] Execute a query action on the operation object according to the query command, and store the query result in a dynamic buffer area.

[0017] Furthermore, when the operation behavior is data update, the operation strategy includes:

[0018] generating a query command based on the operation object;

[0019] Execute a query action on the operation object according to the query command;

[0020] After receiving the notification that the query action is successfully executed, executing the operation command;

[0021] After receiving the notification that the operation command is successfully executed, the query behavior is executed on the operation object again according to the query command, and the query result of this time is stored in the dynamic cache area.

[0022] Furthermore, when the operation behavior is data deletion, the operation strategy also includes:

[0023] When the dynamic cache area contains a query result for the operation object, obtaining the latest query result for the operation object from the dynamic cache area;

[0024] Determine the latest query result as the current query result, and execute the operation command;

[0025] When the operation command is executed successfully, the query result of the operation object in the dynamic cache is deleted.

[0026] Furthermore, when the operation behavior is data update, the operation strategy also includes:

[0027] When the dynamic cache area contains a query result for the operation object, obtaining the latest query result for the operation object from the dynamic cache area;

[0028] Determine the latest query result as the first query result of this time, and execute the operation command;

[0029] After receiving the notification that the operation command is successfully executed, executing the query action on the operation object again according to the query command to obtain a second query result of this time;

[0030] The second query result of this time is stored in the dynamic buffer area.

[0031] Furthermore, after the query result is stored in the dynamic buffer area, the following steps are also included:

[0032] When the query result is the same as the latest query result corresponding to the same operation object in the dynamic cache area, a notification of failure in executing the corresponding operation command is sent, and a change failure record of the operation object is added.

[0033] Furthermore, before sending the query result and the changed data to the corresponding client, the method further includes:

[0034] If the operation command carries an internal transaction identifier, storing the query result and the changed data in a cache area corresponding to the internal transaction identifier, where the internal transaction identifier indicates that the current operation command has an associated impact on other operation commands for the local database;

[0035] After the query results and change data for all operation commands with the same internal transaction identifier are stored, the query results and change data for all operation commands are obtained from the cache area corresponding to the internal transaction identifier and sent to the corresponding client.

[0036] Furthermore, the data detection method based on the change behavior also includes:

[0037] If the operation command carries an external transaction identifier and a third-party database address, the query result and the changed data are sent to the third-party database, wherein the external transaction identifier indicates that the current operation command has an associated impact on other operation commands targeting the external database;

[0038] After receiving the success notification from the third-party database, the query result and the changed data are sent to the corresponding client.

[0039] A second aspect of the embodiments of this specification provides a data detection device based on change behavior, the device comprising:

[0040] The monitoring module is used to monitor and intercept operation commands targeting the target database;

[0041] An acquisition module, configured to acquire the operation behavior, operation object, and change data from the operation command;

[0042] a determination module, configured to determine an operation strategy for maximizing the amount of query information based on the operation behavior, wherein the operation strategy is configured to determine a sequence for executing the operation command and executing the query behavior for the operation object;

[0043] An execution module is used to execute the operation command and the query behavior according to the operation strategy, and send the query result and the change data to the corresponding client.

[0044] A third aspect of the embodiments of this specification provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the computer program executes the instructions of the data detection method based on change behavior described in any of the aforementioned embodiments.

[0045] A fourth aspect of the embodiments of this specification provides a computer storage medium having a computer program stored thereon. When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the data detection method based on change behavior described in any of the aforementioned embodiments.

[0046] A fifth aspect of the embodiments of this specification provides a computer program product, which includes a computer program. When the computer program is run by a processor of a computer device, it executes the instructions of the data detection method based on change behavior described in any of the above embodiments.

[0047] The data detection method, device and computer equipment based on change behavior provided in the embodiments of this specification monitor and intercept operation commands for the target database, determine the operation strategy based on the operation behavior of the operation command, determine the order of querying the target database and executing the operation command according to the operation strategy, and send the query results and change data to the corresponding client. In the process of executing the operation command, the required data can be obtained from the operation command and the target database to complete data detection when the data change behavior occurs. There is no need to wait for the database to generate log files, which speeds up the data detection efficiency. At the same time, there is no need to parse the log, which reduces the cost of configuring customized monitoring tools.

[0048] In order to make the above and other purposes, features and advantages of the embodiments of this specification more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0050] Figure 1 A flow chart of a data detection method based on behavior change according to an embodiment of this specification is shown;

[0051] Figure 2 A flowchart of the first method when the operation behavior of the embodiment of this specification is data deletion is shown;

[0052] Figure 3 A flowchart of a method when the operation behavior of an embodiment of this specification is data insertion is shown;

[0053] Figure 4 A flowchart of a first method when the operation behavior of the embodiment of this specification is data update is shown;

[0054] Figure 5 A flow chart of the second method when the operation behavior of the embodiment of this specification is data deletion is shown;

[0055] Figure 6 A flow chart of the second method when the operation behavior of the embodiment of this specification is data update is shown;

[0056] Figure 7 A flowchart of a method in which an operation command carries an internal transaction identifier is shown in an embodiment of this specification;

[0057] Figure 8 A flowchart of a method in which an operation command carries an external transaction identifier is shown in an embodiment of this specification;

[0058] Figure 9 An example flow chart showing an operation command carrying an internal transaction identifier according to an embodiment of this specification is shown;

[0059] Figure 10 An example flow chart showing an operation command carrying an external transaction identifier according to an embodiment of this specification is shown;

[0060] Figure 11 A structural diagram of a data detection device based on behavior change according to an embodiment of this specification is shown;

[0061] Figure 12 The diagram shows the structure of the computer device according to the embodiment of the present specification.

[0062] Description of the accompanying symbols:

[0063] 1110, monitoring module;

[0064] 1120. Get module;

[0065] 1130. Determine module;

[0066] 1140, execution module;

[0067] 1202. Computer equipment;

[0068] 1204, processor;

[0069] 1206. Memory;

[0070] 1208, driving mechanism;

[0071] 1210, input / output module;

[0072] 1212. Input device;

[0073] 1214. Output device;

[0074] 1216. Presentation equipment;

[0075] 1218. Graphical User Interface;

[0076] 1220, network interface;

[0077] 1222, communication link;

[0078] 1224. Communication bus. DETAILED DESCRIPTION

[0079] The following will clearly and completely describe the technical solutions in the embodiments of this specification in conjunction with the drawings in the embodiments of this specification. Obviously, the embodiments described are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the embodiments of this specification.

[0080] It should be noted that the terms "first," "second," and the like in this specification, the claims, and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a particular order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate, so that the embodiments of this specification described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, apparatus, product, or device comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to such processes, methods, products, or devices.

[0081] This specification provides method operation steps as described in the embodiments or flowcharts, but more or fewer operation steps may be included based on routine or non-creative work. The order of steps listed in the embodiments is only one way of executing the steps among many orderings and does not represent the only execution order. When a system or device product is actually executed, the method can be executed in the order shown in the embodiments or the drawings or in parallel.

[0082] It should be noted that the acquisition, storage, use, and processing of data in the technical solutions of the embodiments of this specification comply with the relevant provisions of national laws and regulations.

[0083] It should be noted that in the embodiments of this specification, certain software, components, models and other existing solutions in the industry may be mentioned. They should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solutions of the embodiments of this specification, but it does not mean that the applicant has or will necessarily use the solution.

[0084] Database project management often requires deploying monitoring tools and message-based middleware to communicate database data changes to interested parties (clients). When database data changes, the database generates a Binlog log. The monitoring tool monitors and parses the Binlog contents, forwarding the target database's pre- and post-change data to the corresponding client via the message-based middleware. However, commonly used monitoring tools, such as Maxwell and Canal, require independent deployment environments, resulting in high operational and maintenance costs for small and medium-sized projects, making them difficult to scale. Furthermore, Maxwell, Canal, and other tools are customized for specific databases. When managing multiple databases in a project, different monitoring tools need to be customized, increasing management costs. Table 1 below provides an introduction to Maxwell and Canal.

[0085] Table 1

[0086]

[0087] Therefore, although Maxwell and Canal are relatively powerful, their high application costs make them unsuitable for managing small and medium-sized projects. Furthermore, Maxwell and Canal only support MySQL databases, making them limited in scope. Therefore, the embodiments of this specification use the MyBatis framework to replace traditional monitoring tools, and implement data monitoring, querying, and sending based on the plug-in functionality provided by the MyBatis framework. The MyBatis framework does not require independent deployment and is independent of the database type, making it easy to use and highly effective in managing small and medium-sized projects.

[0088] In one embodiment of the present specification, a data detection method based on change behavior is provided to solve the problem of high cost of forwarding change data by configuring a monitoring tool in existing database-based project management.

[0089] Specifically, such as Figure 1 As shown in the figure, the data detection method based on change behavior includes:

[0090] Step 110: monitor and intercept operation commands for the target database;

[0091] Step 120: Obtain the operation behavior, operation object, and change data from the operation command;

[0092] Step 130: determining an operation strategy for maximizing the amount of query information based on the operation behavior, wherein the operation strategy is used to determine the order of executing the operation command and executing the query behavior for the operation object;

[0093] Step 140: Execute the operation command and the query behavior according to the operation policy, and send the query result and the changed data to the corresponding client.

[0094] This embodiment monitors and intercepts operation commands for the target database, determines an operation strategy based on the operation behavior of the operation command, determines the order of querying the target database and executing the operation command according to the operation strategy, and sends the query results and changed data to the corresponding client. In the process of executing the operation command, the required data can be obtained from the operation command and the target database to complete data detection when the data change behavior occurs. There is no need to wait for the database to generate log files, which speeds up the data detection efficiency. At the same time, there is no need to parse the log, which reduces the cost of configuring customized monitoring tools.

[0095] In some embodiments of this specification, the operation command can be an SQL operation statement for a MySQL database. The operation command includes operation behavior, operation object and change data. The operation behavior includes data insertion, data deletion, data update, data query, etc. The operation object is one or several data tables in the database, and the change data is the specific data to be changed in the operation object.

[0096] When an operation command targeting the target database is monitored, the operation command will be intercepted first, and the operation behavior, operation object and change data of the operation command will be analyzed. After obtaining the operation behavior, the operation strategy can be determined. The operation strategy is used to determine when to execute the query behavior on the target data and when to execute the aforementioned intercepted operation command. The operation strategy embodies the principle of maximizing the amount of query information, and combined with the change data, it can provide the client with a complete and clear information about the data content, change status and change location of the current operation object.

[0097] In one embodiment of this specification, Figure 2 As shown, when the operation behavior is data deletion, the operation strategy includes:

[0098] Step 210: Generate a query command based on the operation object;

[0099] Step 220: executing a query action on the operation object according to the query command;

[0100] Step 230: After receiving the notification that the query behavior is successfully executed, execute the operation command.

[0101] In this embodiment, when the operation behavior is data deletion, a query command is first generated based on the operation object, and the query behavior is executed on the operation object according to the query command. After the query is successful, the operation command is executed again. The complete data of the operation object before deletion and the data to be deleted by the operation object can be provided to the client, so that the client can check the data content, change status and change location of the current operation object.

[0102] Specifically, for example, a data deletion command example: delete from user where id = *; the operation command obtains the ID of the operation object, and based on the operation object's ID, the target database can be queried, such as the query command example: select * from user where uid = *; after the query is successful, the previously intercepted operation command is executed to delete the corresponding data of the operation object. After the query results and changed data are sent to the corresponding client, the client can determine the data content of the latest operation object, the deleted data, and the corresponding location of the deleted data based on the complete data before deletion and the deleted data. This eliminates the need to receive all the data before and after the change, ensuring the maximum amount of information while reducing information transmission costs.

[0103] In another embodiment of this specification, Figure 3 As shown, when the operation behavior is data insertion, the operation strategy includes:

[0104] Step 310, executing the operation command;

[0105] Step 320: After receiving the notification that the operation command is successfully executed, generate a query command based on the operation object;

[0106] Step 330: Execute a query action on the operation object according to the query command, and store the query result in a dynamic buffer area.

[0107] In this embodiment, when the operation behavior is data insertion, the operation command is executed first. After success, the query behavior is performed on the operation object according to the query command. The complete data after the operation object is inserted and the data that has been inserted by the operation object can be provided to the client, so that the client can check the data content, change status and change location of the current operation object. At the same time, the query results are stored in the dynamic cache area for subsequent use.

[0108] Specifically, for example, an operation command example where the operation behavior is data insertion is: insert into user value(*,*,*); the operation command can be used to obtain the id of the operation object, and the target database can be queried based on the id of the operation object. After the query is successful, the query results and changed data obtained are sent to the corresponding client. The client can then determine the data content of the latest operation object, the inserted data, and the corresponding location of the inserted data based on the complete data after insertion and the data already inserted. This eliminates the need to receive all the data before and after the change, ensuring the maximum amount of information while reducing information transmission costs. At the same time, since the query results for operations involving data insertion can reflect the latest data of the operation object, storing the query results in the dynamic cache area can provide another query path for subsequent queries against the operation object.

[0109] The dynamic cache ensures high space utilization by clearing data of operation objects that have not been accessed for a specified time, eliminating the need to reserve storage space for all operation objects. At the same time, the dynamic cache can dynamically expand storage space when space is insufficient to accommodate deviations from the initial planning.

[0110] In another embodiment of this specification, Figure 4 As shown, when the operation behavior is data update, the operation strategy includes:

[0111] Step 410: Generate a query command based on the operation object;

[0112] Step 420: executing a query action on the operation object according to the query command;

[0113] Step 430: After receiving the notification that the query action is successfully executed, execute the operation command;

[0114] Step 440: After receiving the notification that the operation command is successfully executed, the query behavior is executed on the operation object again according to the query command, and the query result of this time is stored in the dynamic cache area.

[0115] In this embodiment, when the operation behavior is data update, a query command is first generated based on the operation object, and the query behavior is executed on the operation object according to the query command. After the query is successful, the operation command is executed again. After the operation command is successfully executed, the query behavior is executed on the operation object according to the query command. The complete data before the operation object is updated, the complete data after the update, and the updated data of the operation object can be provided to the client for the client to check the data content, change status and change location of the current operation object. At the same time, the query results are stored in the dynamic cache area for subsequent use.

[0116] Specifically, for example, an example of an operation command whose operation behavior is data update is: update user set password = * where uid = *; the id of the operation object is obtained through the operation command, and the target database can be queried based on the id of the operation object to obtain the first query result of the operation object. After success, the operation command is executed, and the target database is queried again based on the id of the operation object to obtain the second query result of the operation object. After the query results and changed data obtained from the two queries are sent to the corresponding client, the client can determine the data content of the latest operation object, the updated data, and the corresponding location of the updated data based on the data before and after the update and the updated data. At the same time, since the second query result of the operation behavior is data update can reflect the latest data of the operation object, storing the query result in the dynamic cache area can provide another query path for subsequent queries against the operation object.

[0117] In another embodiment of this specification, Figure 5 As shown, when the operation behavior is data deletion, the operation strategy also includes:

[0118] Step 510: When the dynamic cache area contains a query result for the operation object, obtain the latest query result for the operation object from the dynamic cache area;

[0119] Step 520: determine the latest query result as the current query result, and execute the operation command;

[0120] Step 530: When the operation command is successfully executed, the query result of the operation object in the dynamic cache is deleted.

[0121] In this embodiment, when the operation behavior is data deletion, the dynamic cache area is used to directly obtain the latest data of the operation object, reducing the query cost of the target database. At the same time, when the operation command is successfully executed, the query results of the corresponding operation object stored in the dynamic cache area are deleted, which can increase the available space of the dynamic cache area while ensuring the validity of the dynamic cache area data.

[0122] Specifically, when the operation behavior is data deletion, the operation strategy is to first query the target database based on the ID of the operation object to obtain the data of the operation object before data deletion, and then execute the operation command to delete the data corresponding to the operation object. At this time, because the query result corresponding to the data deletion is not the latest data of the operation object, the query result is not stored in the dynamic cache area. However, the data of the operation object has changed. If no policy restrictions are imposed, subsequent attempts to obtain the data of the operation object from the dynamic cache area will inevitably result in errors. Therefore, the embodiments of this specification first provide two solutions:

[0123] 1. Add policy restrictions. For example, after a delete operation, the dynamic cache is locked and unlocked only when data is stored in the dynamic cache again (i.e., when a data insert or update operation occurs). This ensures that the latest data from the dynamic cache is not retrieved for the wrong operation object.

[0124] 2. After executing the data deletion operation, perform another query on the target database and store the latest query results in the dynamic cache. By adding one more query, the data in the dynamic cache is always up to date, thus avoiding the acquisition of incorrect data.

[0125] However, the first solution requires additional policy configuration to lock and unlock different operation objects in the dynamic cache separately, increasing query costs. The second solution results in an additional query behavior: a query after data deletion plus a query of the dynamic cache during subsequent operations. This conflicts with the solution of the present invention, which only queries once upon deletion.

[0126] Therefore, the present invention provides a third solution:

[0127] 3. After executing a data deletion operation, delete the query results for the corresponding operation object in the dynamic cache. This approach simplifies the strategy and ensures that the latest data for the operation object is not retrieved from the dynamic cache. Furthermore, when subsequent operations require queries, only a single query is required (i.e., querying the target database directly). Furthermore, deletion can occasionally clear available space in the dynamic cache, preventing the dynamic cache from expanding due to insufficient space.

[0128] In another embodiment of this specification, Figure 6 As shown, when the operation behavior is data update, the operation strategy also includes:

[0129] Step 610: When the dynamic cache area contains a query result for the operation object, obtain the latest query result for the operation object from the dynamic cache area;

[0130] Step 620: determine the latest query result as the first query result of this time, and execute the operation command;

[0131] Step 630: After receiving the notification that the operation command is successfully executed, the query action is executed again on the operation object according to the query command to obtain a second query result of this time;

[0132] Step 640: store the second query result in the dynamic cache.

[0133] In this embodiment, when the operation behavior is data update, the dynamic cache area is used to directly obtain the latest data of the operation object as the first query result of the operation object. At the same time, when the operation command is executed successfully, the target database is queried again to obtain the second query result of the operation object, thereby reducing one query on the database. At the same time, the second query result of the operation object is stored in the dynamic cache area again for subsequent use.

[0134] When the operation behavior is data update, two query results need to be obtained. The first is the query result before the operation object data is updated, and the second is the query result after the operation object data is updated. The query result before the operation object data is updated corresponds to the latest data of the current operation object. Therefore, it can be obtained directly from the dynamic cache area. The query result after the update needs to execute the operation command and query the target database again to obtain it.

[0135] In some embodiments of this specification, when the operation behavior is data insertion or data update, after storing the query result in the dynamic cache area, the following steps are further included:

[0136] When the query result is the same as the latest query result corresponding to the same operation object in the dynamic cache, a notification of failure in executing the corresponding operation command is sent, and a change failure record of the operation object is added.

[0137] After executing an operation command, it may complete incorrectly. For example, if the operation is intended to insert data, the data may not be successfully inserted into the operation object, or if the operation is intended to update data, the data of the operation object may not be successfully updated. By comparing the query results of the database with the query results of the dynamic cache, it is possible to quickly and easily determine whether such an anomaly has occurred. In the event of an anomaly, a notification of the corresponding operation command execution failure will be sent, thus reducing the transmission costs caused by data errors.

[0138] In addition, when the data change of the corresponding operation object fails, a failure record will be made for subsequent analysis of the operation object. Only the failure record of the dynamic cache area needs to be received, and there is no need to aggregate error records that may come from different operating systems, reducing management costs.

[0139] In another embodiment of this specification, Figure 7 As shown, before sending the query result and the change data to the corresponding client, the process further includes:

[0140] Step 710: If the operation command carries an internal transaction identifier, the query result and the changed data are stored in a cache corresponding to the internal transaction identifier, where the internal transaction identifier indicates that the current operation command has an associated impact on other operation commands for the local database.

[0141] Step 720: After the query results and change data for all operation commands with the same internal transaction identifier are stored, the query results and change data for all operation commands are obtained from the cache area corresponding to the internal transaction identifier and sent to the corresponding client.

[0142] This embodiment takes into account the situation of operation commands with associated impacts. When an operation command carries an internal transaction identifier, the query result and change data corresponding to the operation command are first stored in the cache area corresponding to the internal transaction identifier. The query result and change data are not sent to the corresponding client until all operation commands associated with the operation command (i.e., corresponding to the same internal transaction identifier) have obtained the query results and change data, thereby ensuring the accuracy of data transmission.

[0143] Specifically, the internal transaction identifier is used to indicate that all corresponding operation commands are performed on the local system, and the complete operation strategy can be executed by the local system. The internal transaction identifier is unique for each task; for example, in the transfer scenario, A initiates a transfer to B, and data of A and B need to be updated separately (that is, A's account balance needs to be reduced, and B's account balance needs to be increased). Figure 9 For example, at this time, an operation command A needs to be formed for A, and an operation command B needs to be formed for B. A common internal transaction identifier a can be added to the operation commands A and B to indicate the task identifier of the transfer from A to B.

[0144] When operation command A is monitored, operation command A is intercepted and parsed (parsing can use the mapper method in the Mybatis framework). It is found that operation command A has an internal transaction identifier a, and the operation behavior of operation command A is data update, the operation object is operation object 1, and the change data is y (i.e. the balance after the change). At this time, the operation behavior is data update, and it is necessary to first obtain the id of operation object 1 through the operation command, and query the target database according to the id of operation object 1 to obtain the first query result of operation object 1. After the query is successful, operation command A is executed, and the target database is queried again according to the id of operation object 1 to obtain the second query result of operation object 1. Since operation command A has an internal transaction identifier a, it is necessary to store the two query results and change data of operation object 1 in the cache area corresponding to the internal transaction identifier a, and wait until all operation commands corresponding to the internal transaction identifier a have query results and change data before sending them to the corresponding client.

[0145] Afterwards, operation command B is intercepted and parsed, revealing that operation command B has internal transaction identifier a, that the operation behavior of operation command B is a data update, that the operation object is operation object 2, and that the change data is k (i.e., the changed balance). Since the operation behavior is a data update, the operation command first obtains the ID of operation object 2 through the operation command. A query is then performed on the target database based on the ID of operation object 2, obtaining the first query result for operation object 2. After the query is successful, operation command B is executed and the target database is queried again based on the ID of operation object 2, obtaining the second query result for operation object 2. Since operation command B has internal transaction identifier a, the two query results and change data for operation object 2 need to be stored in the cache corresponding to internal transaction identifier a. At this point, all operation commands corresponding to internal transaction identifier a in the cache have query results and change data. The query results and change data for all operation commands can be sent to the corresponding client. Finally, the query results in the cache corresponding to internal transaction identifier a are stored in the dynamic cache, and the data in the cache corresponding to internal transaction identifier a is cleared.

[0146] In another embodiment of this specification, Figure 8 As shown, before sending the query result and the change data to the corresponding client, the process further includes:

[0147] Step 810: If the operation command carries an external transaction identifier and a third-party database address, the query result and the changed data are sent to the third-party database. The external transaction identifier indicates that the current operation command has an associated impact on other operation commands targeting the external database.

[0148] Step 820: After receiving the success notification from the third-party database, the query result and the changed data are sent to the corresponding client.

[0149] This embodiment takes into account the situation where the operation command carries an external transaction identifier. The query results and change data corresponding to the operation command need to be stored in a third-party database first. The query results and change data are not sent to the corresponding client until a success notification is received from the third-party database, thereby ensuring the accuracy of data transmission.

[0150] Specifically, the external transaction identifier is used to indicate that the corresponding different operation commands are not all executed on the local system. The external transaction identifier is also unique for each task. For example, in a scenario involving remote management of orders and inventory, C manages orders on system X and D manages inventory on system Y. When a consumer purchases a product, C needs to generate a new order and D needs to update the inventory (i.e., reduce the inventory). Figure 10 For example, at this time, an operation command C needs to be formed for C, and an operation command D needs to be formed for D. A common external transaction identifier b can be added to the operation commands C and D to indicate the task identifier of C and D jointly processing the product information.

[0151] When operation command C is monitored, operation command C is intercepted and parsed to obtain the result that operation command C has external transaction identifier b, and the operation behavior of operation command C is data insertion (i.e., generating a new order), the operation object is operation object 3, and the changed data is m (i.e., the inserted new order m). At this time, the operation behavior is data insertion, and operation command C needs to be executed first, and then the target database is queried according to the id of operation object 3 to obtain the query result of operation object 3. Since operation command C has external transaction identifier b, the local system alone cannot complete the supervision of external transaction identifier b. The query result and change data of operation object 3 need to be sent to a third-party database for storage. After receiving the notification of the success of external transaction identifier b from the third-party database, the query result and change data of operation object 3 are sent to the corresponding client.

[0152] Afterwards, the client monitors operation command D, intercepts it, and parses it, finding that operation command D has an external transaction identifier b, that the operation behavior of operation command D is a data update, that the operation object is operation object 4, and that the changed data is n (i.e., the changed inventory quantity). At this point, since the operation behavior is a data update, it is necessary to first obtain the id of operation object 4 through the operation command, then query the target database based on the id of operation object 4 to obtain the first query result for operation object 4. After the query is successful, it executes operation command D and queries the target database again based on the id of operation object 4 to obtain the second query result for operation object 4. Since operation command D has an external transaction identifier b, it is necessary to also send the two query results and the changed data for operation object 4 to the third-party database for storage. After receiving notification from the third-party database about the success of external transaction identifier b, it is necessary to send the query results and changed data for operation object 4 to the corresponding client.

[0153] To reduce the complexity of third-party database configuration, the database only monitors whether all operations corresponding to the same external transaction identifier have completed data storage. If so, it sends a success notification without requiring client involvement. Furthermore, the database stores all changes related to each external transaction, enabling on-demand querying by different servers.

[0154] Based on the same inventive concept, the embodiments of this specification also provide a data detection device based on modified behavior, as described in the following embodiments. Since the principles of the data detection device based on modified behavior and the data detection method based on modified behavior are similar, the implementation of the data detection device based on modified behavior can refer to the data detection method based on modified behavior, and the repeated parts will not be repeated.

[0155] Specifically, such as Figure 11 As shown, the data detection device based on the change behavior includes:

[0156] A monitoring module 1110 is configured to monitor and intercept operation commands directed to a target database;

[0157] An acquisition module 1120 is configured to acquire an operation behavior, an operation object, and change data from the operation command;

[0158] A determination module 1130 is configured to determine an operation strategy for maximizing the amount of query information based on the operation behavior, wherein the operation strategy is configured to determine a sequence for executing the operation command and executing the query behavior for the operation object;

[0159] The execution module 1140 is configured to execute the operation command and the query behavior according to the operation policy, and send the query result and the change data to the corresponding client.

[0160] The data detection method, device and computer equipment based on change behavior provided in the embodiments of this specification monitor and intercept operation commands for the target database, determine the operation strategy based on the operation behavior of the operation command, determine the order of querying the target database and executing the operation command according to the operation strategy, and send the query results and change data to the corresponding client. In the process of executing the operation command, the required data can be obtained from the operation command and the target database to complete data detection when the data change behavior occurs. There is no need to wait for the database to generate log files, which speeds up the data detection efficiency. At the same time, there is no need to parse the log, which reduces the cost of configuring customized monitoring tools.

[0161] In one embodiment of this specification, a computer device is further provided for implementing the method described in any of the above embodiments, such as Figure 12 The diagram shows a schematic diagram of the structure of a computer device according to an embodiment of the present specification. Computer device 1202 may include one or more processors 1204, such as one or more central processing units (CPUs), each of which may implement one or more hardware threads. Computer device 1202 may also include any memory 1206 for storing any type of information, such as code, settings, data, etc. For example, and without limitation, memory 1206 may include any one or more combinations of the following: any type of RAM, any type of ROM, a flash memory device, a hard disk, an optical disk, etc. More generally, any memory may use any technology to store information. Furthermore, any memory may provide volatile or non-volatile retention of information. Furthermore, any memory may represent a fixed or removable component of computer device 1202. In one embodiment, when processor 1204 executes associated instructions stored in any memory or combination of memories, computer device 1202 may perform any operation of the associated instructions. Computer device 1202 also includes one or more drive mechanisms 1208, such as a hard disk drive mechanism, an optical disk drive mechanism, etc., for interacting with any memory.

[0162] The computer device 1202 may also include an input / output module 1210 (I / O) for receiving various inputs (via input devices 1212) and for providing various outputs (via output devices 1214). A specific output mechanism may include a presentation device 1216 and an associated graphical user interface (GUI) 1218. In other embodiments, the input / output module 1210 (I / O), input devices 1210, and output devices 1214 may not be included, and the computer device 1202 may simply be a computer device in a network. The computer device 1202 may also include one or more network interfaces 1220 for exchanging data with other devices via one or more communication links 1222. One or more communication buses 1224 couple the components described above together.

[0163] The communication link 1222 may be implemented in any manner, for example, via a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 1222 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc., governed by any protocol or combination of protocols.

[0164] Corresponding to Figures 1 to 10 The method in this specification also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are executed.

[0165] The embodiment of this specification also provides a computer-readable instruction, wherein when the processor executes the instruction, the program therein causes the processor to execute the following Figures 1 to 10 The method shown.

[0166] It should be understood that in the various embodiments of this specification, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this specification.

[0167] It should also be understood that in the embodiments of this specification, the term "and / or" is merely a description of the relationship between associated objects, indicating that three possible relationships exist. For example, "A and / or B" can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone. Furthermore, the character " / " in this specification generally indicates that the associated objects are in an "or" relationship.

[0168] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the embodiments of this specification can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of this specification.

[0169] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0170] In the several embodiments provided in this specification, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or can be an electrical, mechanical or other form of connection.

[0171] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of this specification.

[0172] In addition, the functional units in the various embodiments of this specification may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0173] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of this specification is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of this specification. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0174] Specific embodiments are used in this specification to illustrate the principles and implementation methods of this specification. The description of the above embodiments is only used to help understand the methods and core ideas of the embodiments of the specification. At the same time, for those skilled in the art, based on the ideas of the embodiments of this specification, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the embodiments of this specification.

Claims

1. A data detection method based on change behavior, characterized in that: The method comprises: Monitor and intercept operation commands targeting the target database; Obtaining operation behavior, operation object and change data from the operation command; Determining an operation strategy for maximizing the amount of query information based on the operation behavior, wherein the operation strategy is used to determine the order of executing the operation command and executing the query behavior for the operation object; The operation command and the query behavior are executed according to the operation strategy, and the query result and the changed data are sent to the corresponding client.

2. The method according to claim 1, wherein When the operation behavior is data deletion, the operation strategy includes: generating a query command based on the operation object; Execute a query action on the operation object according to the query command; After receiving the notification that the query behavior is successfully executed, the operation command is executed.

3. The method according to claim 1, wherein When the operation behavior is data insertion, the operation strategy includes: Executing the operation command; After receiving a notification that the operation command is successfully executed, generating a query command based on the operation object; Execute a query action on the operation object according to the query command, and store the query result in a dynamic buffer area.

4. The method according to claim 1, wherein When the operation behavior is data update, the operation strategy includes: generating a query command based on the operation object; Execute a query action on the operation object according to the query command; After receiving the notification that the query action is successfully executed, executing the operation command; After receiving the notification that the operation command is successfully executed, the query behavior is executed on the operation object again according to the query command, and the query result of this time is stored in the dynamic cache area.

5. The method according to claim 3 or 4, wherein: When the operation behavior is data deletion, the operation strategy also includes: When the dynamic cache area contains a query result for the operation object, obtaining the latest query result for the operation object from the dynamic cache area; Determine the latest query result as the current query result, and execute the operation command; When the operation command is executed successfully, the query result of the operation object in the dynamic cache is deleted.

6. The method according to claim 3 or 4, wherein: When the operation behavior is data update, the operation strategy further includes: When the dynamic cache area contains a query result for the operation object, obtaining the latest query result for the operation object from the dynamic cache area; Determine the latest query result as the first query result of this time, and execute the operation command; After receiving the notification that the operation command is successfully executed, executing the query action on the operation object again according to the query command to obtain a second query result of this time; The second query result of this time is stored in the dynamic buffer area.

7. The method according to claim 3 or 4, wherein: After storing the query results in the dynamic buffer, it also includes: When the query result is the same as the latest query result corresponding to the same operation object in the dynamic cache area, a notification of failure in executing the corresponding operation command is sent, and a change failure record of the operation object is added.

8. The method according to claim 1, wherein Before sending the query result and the changed data to the corresponding client, the method further includes: If the operation command carries an internal transaction identifier, storing the query result and the changed data in a cache area corresponding to the internal transaction identifier, where the internal transaction identifier indicates that the current operation command has an associated impact on other operation commands for the local database; After the query results and change data for all operation commands with the same internal transaction identifier are stored, the query results and change data for all operation commands are obtained from the cache area corresponding to the internal transaction identifier and sent to the corresponding client.

9. The method according to claim 1, wherein The method further comprises: If the operation command carries an external transaction identifier and a third-party database address, the query result and the changed data are sent to the third-party database, wherein the external transaction identifier indicates that the current operation command has an associated impact on other operation commands targeting the external database; After receiving the success notification from the third-party database, the query result and the changed data are sent to the corresponding client.

10. A data detection device based on change behavior, characterized in that: The device comprises: The monitoring module is used to monitor and intercept operation commands targeting the target database; An acquisition module, configured to acquire the operation behavior, operation object, and change data from the operation command; a determination module, configured to determine an operation strategy for maximizing the amount of query information based on the operation behavior, wherein the operation strategy is configured to determine a sequence for executing the operation command and executing the query behavior for the operation object; An execution module is used to execute the operation command and the query behavior according to the operation strategy, and send the query result and the change data to the corresponding client.

11. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 9 is implemented.

12. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor of a computer device, the method according to any one of claims 1 to 9 is implemented.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor of a computer device, the method according to any one of claims 1 to 9 is implemented.