Database transaction processing method and apparatus, computer device, and storage medium

By detecting and applying the interface of the application in the Oracle database, the problem of data inconsistency between the calling system and the called system is solved, achieving efficient and accurate database transaction processing and ensuring data consistency.

CN114968499BActive Publication Date: 2025-11-28CHINA PING AN LIFE INSURANCE CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210682211.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-16
Publication Date
2025-11-28
Estimated Expiration
2042-06-16

AI Technical Summary

Technical Problem

In Oracle databases, data inconsistencies can arise when the calling system and the called system experience call logic errors due to microservices technology, which are used to maintain applications on different systems.

Method used

By acquiring the current transaction, it checks whether the first application and the second application meet the application conditions. If they meet the conditions, it performs application processing to obtain the transaction interface corresponding to the transaction logic information, the data operation interface corresponding to the first operation statement, and the program interface corresponding to the second application. The current transaction is implemented through these interfaces to ensure that rollback can be performed if any interface fails.

Benefits of technology

It improves the efficiency and accuracy of database transaction implementation, and ensures data consistency between the first application and the second application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114968499B_ABST
    Figure CN114968499B_ABST
Patent Text Reader

Abstract

The application discloses a database transaction processing method and device, computer equipment and a storage medium, and relates to the technical field of database transaction processing. The database transaction processing method comprises the following steps: acquiring a current transaction; the current transaction indicates that a first application program in a same database calls a second application program; the first application program comprises transaction logic information and at least one first operation statement; detecting whether the first application program and the second application program meet application conditions; when the first application program and the second application program meet the application conditions, performing application processing on the first application program and the second application program, obtaining a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement and a program interface corresponding to the second application program; and implementing the current transaction through the transaction interface, the data operation interface and the program interface. The application improves the efficiency and accuracy of database transaction implementation.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data processing, and in particular to a database transaction processing method and device, computer equipment and a storage medium. BACKGROUND

[0002] In many industry fields, the storage system adopts an Oracle database. Different systems can maintain their corresponding application programs separately in the same Oracle database. Therefore, the application program of a certain system can maintain the consistency of the calling logic when calling the application program of another system.

[0003] However, with the passage of time, many redundant codes are accumulated in the Oracle database. Therefore, the storage process of the application program needs to be applied to other language frameworks by using micro-service technology. If the calling logic is abnormal when the micro-service technology maintains the application programs of different systems, the calling system needs to be rolled back. However, the called system does not know the rollback process of the calling system, that is, the called system does not perform the rollback process. Therefore, the data inconsistency problem between the calling system and the called system occurs. SUMMARY

[0004] The embodiments of the present application provide a database transaction processing method and device, computer equipment and a storage medium to solve the problem of data inconsistency between the calling system and the called system.

[0005] A database transaction processing method comprises the following steps:

[0006] A current transaction is obtained. The current transaction indicates that a first application program in a same database calls a second application program. The first application program comprises transaction logic information and at least one first operation statement.

[0007] It is detected whether the first application program and the second application program meet an application condition.

[0008] When the first application program and the second application program meet the application condition, the first application program and the second application program are applied to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement and a program interface corresponding to the second application program.

[0009] The current transaction is implemented through the transaction interface, the data operation interface and the program interface.

[0010] A database transaction processing device comprises the following steps:

[0011] The transaction acquisition module is configured to acquire a current transaction; the current transaction indicates that a first application program in a same database calls a second application program; the first application program includes transaction logic information and at least one first operation statement;

[0012] The condition detection module is configured to detect whether the first application program and the second application program meet an application condition.

[0013] The application processing module is configured to, when the first application program and the second application program meet the application condition, perform application processing on the first application program and the second application program to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement, and a program interface corresponding to the second application program.

[0014] The transaction implementation module is configured to implement the current transaction through the transaction interface, the data operation interface, and the program interface.

[0015] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the database transaction processing method when executing the computer program.

[0016] A computer readable storage medium stores a computer program, and the computer program is executable by a processor to implement the database transaction processing method.

[0017] The database transaction processing method, device, computer device, and storage medium are described above. The database transaction processing method acquires a current transaction; the current transaction indicates that a first application program in a same database calls a second application program; the first application program includes transaction logic information and at least one first operation statement; whether the first application program and the second application program meet an application condition is detected; when the first application program and the second application program meet the application condition, application processing is performed on the first application program and the second application program to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement, and a program interface corresponding to the second application program; and the current transaction is implemented through the transaction interface, the data operation interface, and the program interface.

[0018] The application applicationizes the first to-be-processed statement in the first application program and the second to-be-processed statement in the second application program into the form of an interface (for example, the first to-be-processed statement is applicationized into a data operation interface, and the second to-be-processed statement is applicationized into a program interface), so as to facilitate the call between the first application program and the second application program, thereby improving the efficiency and accuracy of the database transaction implementation. The current transaction is implemented through the interface call, and when an exception occurs in any interface, rollback processing can be performed on all interfaces, so that the data consistency between the first application program and the second application program is maintained. BRIEF DESCRIPTION OF DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0020] Figure 1 is an application environment schematic diagram of a database transaction processing method in an embodiment of the present application;

[0021] Figure 2 is a flowchart of a database transaction processing method in an embodiment of the present application;

[0022] Figure 3 is a flowchart of step S30 in a database transaction processing method in an embodiment of the present application;

[0023] Figure 4 is a principle block diagram of a database transaction processing device in an embodiment of the present application;

[0024] Figure 5 is a principle block diagram of an application processing module in a database transaction processing device in an embodiment of the present application;

[0025] Figure 6 is a schematic diagram of a computer device in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The technical solutions in the embodiments of the present application will be described clearly and completely in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are some embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the protection scope of the present application.

[0027] The database transaction processing method provided by the embodiments of the present application can be applied to Figure 1The application environment shown. Specifically, the database transaction processing method is applied in a database transaction processing system, which includes a client and a server as shown in Figure 1 The application environment shown. Specifically, the database transaction processing method is applied in a database transaction processing system, which includes a client and a server as shown in

[0028] In an embodiment, as shown in Figure 2 A database transaction processing method is provided, which is applied in a server as shown in Figure 1 The steps are as follows:

[0029] S10: Obtain a current transaction; the current transaction indicates that a first application program in a same database calls a second application program; the first application program includes transaction logic information and at least one first operation statement.

[0030] It can be understood that the process that the application program of a certain system in the same database (the database can be an Oracle database) calls the application program of another system to obtain data in the application program of the other system can be regarded as a current transaction. There can be one or more data operation statements in the first application program and the second application program (the data operation statement in the first application program is defined as a first operation statement; the data operation statement in the second application program is defined as a second operation statement). Exemplarily, the data operation statement can be an update, insert, delete, or select type of statement. Since the current transaction is regarded as the process that the first application program calls the second application program, the transaction logic information can also be included in the first application program. The transaction logic information can include transaction basic information and transaction execution information of the current transaction. The transaction basic information can include basic information of the first application program and the second application program participating in the current transaction. The transaction execution information is used to represent the execution relationship between the first application program and the second application program, such as the statement execution order of the data operation statements in the first application program and the second application program.

[0031] Further, in the embodiment, the current transaction is defined as the calling process between two different application programs in the same database. It should be noted that the current transaction defined in the embodiment is only an example. That is, the current transaction can also be the calling process between multiple different application programs.

[0032] S20: Detect whether the first application program and the second application program meet the application condition.

[0033] It can be understood that in the background art, it is mentioned that many redundant codes will be accumulated in the Oracle database over time. The storage process of the application program needs to be applicationized by using other language frameworks through the micro-service technology. Therefore, before the first application program and the second application program are applicationized, it is determined whether the first application program and the second application program meet the application condition. If the first application program and the second application program meet the application condition, the first application program and the second application program are applicationized. If the first application program and the second application program meet the application condition, the first application program and the second application program are not applicationized. The application condition means that the first application program and the second application program include at least one type of data operation statement of update, insert, or delete, and the data operation statement of the first application program is executed after the data operation statement of the second application program.

[0034] S30: when the first application and the second application meet the application condition, performing application processing on the first application and the second application to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement, and a program interface corresponding to the second application.

[0035] It can be understood that the application processing is to modularize the data operation statement or the transaction verification logic in the first application and the second application by using the micro-service technology, so that the data operation statement or the transaction verification logic in the first application and the second application can be called separately.

[0036] Specifically, after detecting whether the first application and the second application meet the application condition, if the first application and the second application meet the application condition, the first application and the second application are processed by using the micro-service technology. The data operation statement in the first application and the second application can be applied to a separate interface, so that the calling process between the first application and the second application can be realized in the form of interface calling.

[0037] S40: realizing the current transaction through the transaction interface, the data operation interface, and the program interface.

[0038] It can be understood that after the first application and the second application are processed by using the micro-service technology, the interface calling between the transaction interface, the data operation interface, and the program interface can be realized in the form of interface calling, so that the current transaction can be realized. However, it should be noted that after the current transaction is realized, the current transaction is not submitted, that is, the current transaction is not terminated. During the process of realizing the current transaction in the form of interface calling, it is necessary to detect whether the transaction interface, the data operation interface, and the program interface are abnormal in real time. Only when the transaction interface, the data operation interface, and the program interface are not abnormal, the current transaction is submitted after the current transaction is realized.

[0039] In the embodiment, the first to-be-processed statement in the first application and the second to-be-processed statement in the second application are separately applied to an interface (for example, the first to-be-processed statement is applied to a data operation interface, and the second to-be-processed statement is applied to a program interface), so as to facilitate the calling between the first application and the second application, thereby improving the efficiency and accuracy of the database transaction implementation.

[0040] In an embodiment, step S20, that is, the detection of whether the first application and the second application meet the application condition, comprises:

[0041] (1) obtaining all second operation statements in the second application program, and detecting whether the first operation statements and the second operation statements are only query statements.

[0042] It can be understood that the second operation statement is a data operation statement in the second application program. The second operation statement can be an update, insert, delete, or select type of statement. The query statement is a select statement.

[0043] Specifically, after obtaining the second operation statement in the second application program, field detection can be performed on all first operation statements in the first application program and all second operation statements in the second application program, so as to determine the types of the first operation statements and the second operation statements. Then, it can be determined whether the first operation statements and the second operation statements are only query statements (select type of data operation statement). That is, it is determined whether the first operation statements in the first application program include any one of the three types of update, insert, or delete type of data operation statement, and whether the second operation statements in the second application program include any one of the three types of update, insert, or delete type of data operation statement. For example, it is assumed that the first application program includes an insert type of data operation statement and a select type of data operation statement. The second application program includes an update type of data operation statement and a select type of data operation statement. Then, it is determined that the first application program and the second application program both have other types of data operation statements that are not query statements.

[0044] (2) obtaining transaction execution information of the current transaction when any one of the first operation statements and any one of the second operation statements is not a query statement.

[0045] It can be understood that the transaction execution information is used to represent the execution relationship between the first application program and the second application program, such as the statement execution order of the data operation statements in the first application program and the second application program.

[0046] Specifically, after detecting whether the first operation statements and the second operation statements are only query statements, if it is detected that there is a first operation statement that is not a query statement and a second operation statement that is not a query statement, the transaction execution information of the current transaction can be obtained. If it is detected that all first operation statements and / or all second operation statements are query statements, it is determined that the first application program and the second application program do not meet the application condition.

[0047] (3) parsing the transaction execution information to determine a statement execution order of the first transaction statement and the second transaction statement; the first transaction statement refers to a first operation statement participating in the current transaction; the second transaction statement refers to a second operation statement participating in the current transaction.

[0048] It can be understood that the above description indicates that the transaction execution information represents the execution relationship between the first application program and the second application program. Therefore, after obtaining the transaction execution information of the current transaction, the transaction execution information can be parsed to determine the calling relationship between the first application program and the second application program. That is, the statement execution order of the first transaction statement in the first application program and the second transaction statement in the second application program is determined. It should be noted that because the first application program and the second application program are in a calling relationship, the first transaction statement and the second transaction statement cannot be executed at the same time.

[0049] (4) when the statement execution order indicates that the first transaction statement is executed after the second transaction statement, it is determined that the first application program and the second application program meet the application condition.

[0050] Specifically, after parsing the transaction execution information to determine the statement execution order of the first transaction statement and the second transaction statement, if the statement execution order indicates that the first transaction statement is executed after the second transaction statement, it is determined that the first application program and the second application program meet the application condition. If the statement execution order indicates that the first transaction statement is executed before the second transaction statement, it is determined that the first application program and the second application program do not meet the application condition.

[0051] Further, before the first application program and the second application program are applied, if the first transaction statement is executed after the second transaction statement, when the first application program has an exception, the first application program performs rollback processing. And the second application program can know the rollback processing process of the first application program. But after the first application program and the second application program are applied, if the first transaction statement is executed after the second transaction statement, when the first application program has an exception, the first application program performs rollback processing. At this time, the second application program does not know the rollback processing process of the first application program. Thus, the data between the first application program and the second application program is inconsistent. Therefore, in the embodiment, it is limited that only when the statement execution order indicates that the first transaction statement is executed after the second transaction statement, it is determined that the first application program and the second application program meet the application condition.

[0052] In an embodiment, as Figure 3As shown, in step S30, that is, the application processing of the first application and the second application is performed to obtain the transaction interface corresponding to the transaction logic information, the data operation interface corresponding to the first operation statement, and the program interface corresponding to the second application, which includes:

[0053] S301: Obtain transaction execution information of the current transaction, and determine a first transaction statement and a second transaction statement according to the transaction execution information; the first transaction statement refers to the first operation statement participating in the current transaction; the second transaction statement refers to the second operation statement participating in the current transaction.

[0054] It can be understood that the transaction execution information is used to represent the execution relationship between the first application and the second application, such as the statement execution order of the data operation statements in the first application and the second application. That is, the transaction execution information contains the first operation statement in the first application participating in the current transaction. For example, it is assumed that after the second application feeds back data in its system to the first application in the current transaction, the first application needs to write the feedback data into an entity table. At this time, the first application has a first transaction statement of data writing logic (insert type).

[0055] Specifically, there can be multiple first operation statements in the first application, but not all of the first operation statements participate in the current transaction. Therefore, the transaction execution information of the current transaction can be obtained and parsed. Thus, the fields of all data operation statements participating in the current transaction are identified, and the identified fields are matched with the fields of all first operation statements in the first application. The first operation statement with the fields of all data operation statements participating in the current transaction is recorded as the first transaction statement, so as to complete the screening of the first operation statement in the first application. Similarly, after identifying the fields of all data operation statements participating in the current transaction, the identified fields are matched with the fields of all second operation statements in the second application. The second operation statement with the fields of all data operation statements participating in the current transaction is recorded as the second transaction statement, so as to complete the screening of the second operation statement in the second application.

[0056] S302: Record the first transaction statement that is not a query statement as a first to-be-processed statement, and record the second transaction statement that is not a query statement as a second to-be-processed statement.

[0057] Specifically, after determining the first transaction statement according to the transaction execution information, since the query statement (data operation statement of select type) does not modify or replace the data in the first application or the second application. Therefore, the query statement does not need to be applied. Further, the first transaction statement and the second transaction statement are field parsed, and the first transaction statement which is not a query statement is regarded as a first to-be-processed statement. The second transaction statement which is not a query statement is regarded as a second to-be-processed statement. That is, the first transaction statement which does not include a "select" field is regarded as the first to-be-processed statement, that is, the first to-be-processed statement is a data operation statement of any one of update, insert or delete. Similarly, the second transaction statement which does not include the "select" field is regarded as the second to-be-processed statement, that is, the second to-be-processed statement is a data operation statement of any one of update, insert or delete.

[0058] S303: applying the transaction logic information in the first application and the first to-be-processed statement respectively to obtain a transaction interface corresponding to the transaction logic information and a data operation interface corresponding to the first to-be-processed statement.

[0059] It can be understood that, in order to facilitate the calling between the applications, and when the first application or the second application abnormally occurs and needs to be rolled back, the first application and the second application can be rolled back. Further, the data consistency between the first application and the second application is maintained. After recording the first transaction statement which is not a query statement as the first to-be-processed statement, the transaction logic information in the first application and the first to-be-processed statement are applied respectively to obtain a transaction interface corresponding to the transaction logic information and a data operation interface corresponding to the first to-be-processed statement. That is, the transaction logic information and the first to-be-processed statement are separately modularized, so that the first to-be-processed statement can be executed separately when the data operation interface is called.

[0060] Further, the number of data operation interfaces can be determined according to the number of first to-be-processed statements. For example, when there is only one first to-be-processed statement in the first application, the data operation interface is only one. When there are multiple first to-be-processed statements in the first application, each first to-be-processed statement is applied to obtain a data operation interface, that is, one first to-be-processed statement corresponds to one data operation interface.

[0061] S304: applying the second to-be-processed statement in the second application to obtain a program interface corresponding to the second operation statement.

[0062] It can be understood that, since the current transaction is the first application program calling the second application program, transaction execution information corresponding to the current transaction can not be stored in the second application program. Therefore, only the second pending statement in the second application program needs to be applied, and then a program interface corresponding to the second operation statement is obtained. Further, the number of program interfaces can be only one, or a corresponding program interface can be applied for each second operation statement.

[0063] In the embodiment, by separately applying the first pending statement in the first application program and the second pending statement in the second application program into the form of interfaces (such as applying the first pending statement into a data operation interface and applying the second pending statement into a program interface), the calling between the first application program and the second application program is facilitated. When an exception occurs in any one interface, rollback processing can be performed on all interfaces, so that the consistency of data between the first application program and the second application program is maintained.

[0064] In an embodiment, in step S40, that is, the current transaction is implemented through the transaction interface, the data operation interface, and the program interface, includes:

[0065] (1) The program interface is called through the transaction interface, so that target data is obtained from the second application program through the program interface.

[0066] It can be understood that the target data is data that the first application program needs to obtain from the second application program. The target data can have different substantive meanings in different scenarios. For example, in an information pushing scenario, the first application program needs to obtain user portrait data of a target user in the second application program, and the target data is the user portrait data in this case.

[0067] Specifically, after the first application program and the second application program are applied to obtain a transaction interface corresponding to transaction logic information, a data operation interface corresponding to a first operation statement, and a program interface corresponding to a second application program, the program interface can be called through the transaction interface, and then the target data can be obtained from the second application program through the program interface. Further, when the program interface obtains the target data from the second application program, the program interface queries the target data from a temporary table in the second application program. After the program interface performs a corresponding logical query and obtains the target data, the temporary table is deleted. Here, the program interface executes a delete type data operation statement.

[0068] (2) The data operation interface is called through the program interface, so that the target data is input from the program interface to the data operation interface.

[0069] Specifically, after the program interface is invoked through the transaction interface to obtain the target data from the second application program through the program interface, the data operation interface is invoked through the program interface. Thus, the target data is input from the program interface to the data operation interface.

[0070] (3) after the target data is stored to the first application program through the data operation interface, it is determined that the current transaction is implemented.

[0071] Specifically, after the data operation interface is invoked through the program interface to input the target data from the program interface to the data operation interface, the target data is stored to the first application program through the data operation interface, and it is determined that the current transaction is implemented. Further, when the data operation interface stores the target data to the first application program, the data operation interface actually executes an insert type data operation statement. That is, the data operation interface receives the target data and writes the target data into the entity table of the first application program, and the current transaction is completed.

[0072] In an embodiment, the implementation of the current transaction through the transaction interface, the data operation interface and the program interface further comprises:

[0073] During the implementation of the current transaction, it is detected whether the transaction interface, the data operation interface and the program interface are abnormal.

[0074] It can be understood that during the implementation of the current transaction through the interface invocation, the interface can be abnormal (for example, the network state of the data operation interface becomes offline state during the implementation of the insert logic, and it is determined that the data operation interface is abnormal). If the interface is abnormal, the data transmission can be stopped, and thus the data inconsistency between the first application program and the second application program can be caused. Therefore, during the implementation of the current transaction, it is necessary to detect whether the transaction interface, the data operation interface and the program interface are abnormal. For example, the network state of the transaction interface, the data operation interface and the program interface is detected. Further, the abnormality of the transaction interface, the data operation interface and the program interface can be detected in real time, or the abnormality of the transaction interface, the data operation interface and the program interface can be detected at a fixed time.

[0075] If the transaction interface, the data operation interface or the program interface is abnormal, the initial program version of the first application program and the second application program is obtained; the initial program version is the version after the application processing of the first application program and the second application program.

[0076] It can be understood that in the process of implementing the current transaction, the data in the second application program can be synchronized in the first application program. In the embodiment, the change of the data in the first application program or the second application program is regarded as the change of the program version of the first application program and the second application program. The initial program version refers to the version after the application processing of the first application program and the second application program. That is, the first application program corresponding to the initial program version has not stored the data of the second application program.

[0077] The interface rollback processing is performed on the transaction interface, the data operation interface and the program interface, so that the first application program and the second application program are rolled back to the initial program version.

[0078] Specifically, after the application processing of the first application program and the second application program, the initial program version of the first application program and the second application program can be defined. After the implementation of the current transaction, the implementation program version can be defined. When the transaction interface, the data operation interface and the program interface are detected to be abnormal, the rollback processing is performed on the transaction interface, the data operation interface and the program interface, so that the first application program and the second application program are rolled back from the implementation program version to the initial program version. In the implementation program version, the target data in the second application program has been written in the entity table of the first application program. After the implementation program version is rolled back to the initial program version, the target data in the second application program is not written in the entity table of the first application program.

[0079] The abnormal interface is adjusted, and the current transaction is implemented through the normal interface and the adjusted abnormal interface. The abnormal interface refers to the transaction interface, the data operation interface or the program interface that is abnormal. The normal interface refers to the transaction interface, the data operation interface or the program interface that is not abnormal.

[0080] It can be understood that the abnormal interface refers to the transaction interface, the data operation interface or the program interface that is abnormal. The normal interface refers to the transaction interface, the data operation interface or the program interface that is not abnormal. For example, if the transaction interface is abnormal, and the data operation interface and the program interface are not abnormal, the transaction interface is regarded as the abnormal interface, and the data operation interface and the program interface are regarded as the normal interface.

[0081] Specifically, after the interface rollback processing is performed on the transaction interface, the data operation interface and the program interface, so that the first application program and the second application program are rolled back to the initial program version, the abnormal interface is adjusted. For example, when the network state of the abnormal interface is in the offline state, the network state of the abnormal interface is restored to the online state. Thus, the current transaction is implemented through the normal interface and the adjusted abnormal interface. The process of implementing the current transaction through the interface is the same as the above process, which will not be described here.

[0082] In an embodiment, after detecting whether the transaction interface, the data operation interface and the program interface have exceptions, the method further comprises:

[0083] If none of the transaction interface, the data operation interface and the program interface has an exception, a transaction commit strategy is acquired.

[0084] It can be understood that the transaction commit strategy is used to commit the current transaction. After the current transaction is committed, the current transaction is considered to be terminated.

[0085] Specifically, after detecting whether the transaction interface, the data operation interface and the program interface have exceptions, if none of the transaction interface, the data operation interface and the program interface has an exception, it is considered that the data between the first application program and the second application program is consistent, and then the transaction commit strategy can be acquired. For the Oracle database, the transaction commit strategy includes a manual explicit commit strategy, an implicit commit strategy and an automatic commit strategy. The manual explicit commit strategy is to commit the current transaction by executing a COMMIT command. The implicit commit strategy means that after receiving an operation instruction of the user to close the database, the current transaction is considered to be committed. The automatic commit strategy means that after detecting that none of the transaction interface, the data operation interface and the program interface has an exception, the current transaction is automatically committed.

[0086] After executing the transaction commit strategy on the current transaction, it is determined that the current transaction is completed.

[0087] Specifically, after acquiring the transaction commit strategy, the transaction commit strategy is executed on the current transaction to commit the current transaction to the database. Then, after the current transaction is committed, the current transaction is considered to be in a terminated state.

[0088] It should be understood that the size of the serial number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.

[0089] In an embodiment, a database transaction processing apparatus is provided, which corresponds to the database transaction processing method in the above embodiment. As shown in the figure, the database transaction processing apparatus comprises a transaction acquisition module 10, a condition detection module 20, an application processing module 30 and a transaction implementation module 40. The functions of each functional module are described in detail as follows: Figure 4

[0090] ​The transaction acquisition module 10 is configured to acquire a current transaction; the current transaction indicates that a first application program in a same database calls a second application program; the first application program comprises transaction logic information and at least one first operation statement;

[0091] The condition detection module 20 is configured to detect whether the first application program and the second application program meet an application condition.

[0092] The application processing module 30 is configured to, when the first application program and the second application program meet the application condition, perform application processing on the first application program and the second application program, to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement, and a program interface corresponding to the second application program.

[0093] The transaction implementation module 40 is configured to implement the current transaction through the transaction interface, the data operation interface, and the program interface.

[0094] Preferably, the condition detection module 20 comprises:

[0095] The first statement detection unit is configured to acquire all second operation statements in the second application program, and detect whether the first operation statement and the second operation statement are only query statements.

[0096] The information acquisition unit is configured to, when any one of the first operation statement and any one of the second operation statement is not a query statement, acquire transaction execution information of the current transaction.

[0097] The information analysis unit is configured to analyze the transaction execution information, and determine a statement execution order of a first transaction statement and a second transaction statement; the first transaction statement refers to a first operation statement participating in the current transaction; the second transaction statement refers to a second operation statement participating in the current transaction.

[0098] The first condition detection unit is configured to, when the statement execution order indicates that the first transaction statement is executed after the second transaction statement, determine that the first application program and the second application program meet the application condition.

[0099] Preferably, the condition detection module 20 further comprises:

[0100] The second statement detection unit is configured to, when the first operation statement and / or the second operation statement is only the query statement, determine that the first application program and the second application program do not meet the application condition.

[0101] Preferably, the condition detection module 20 further comprises:

[0102] The second condition detection unit is configured to determine that the first application and the second application do not meet the application condition when the statement execution order indicates that the first transaction statement is executed before the second transaction statement.

[0103] Preferably, as shown in Figure 5 The application processing module 30 includes:

[0104] The transaction statement screening unit 301 is configured to acquire transaction execution information of the current transaction, and determine a first transaction statement and a second transaction statement according to the transaction execution information; the first transaction statement refers to the first operation statement participating in the current transaction; the second transaction statement refers to the second operation statement participating in the current transaction.

[0105] The query statement screening unit 302 is configured to record the first transaction statement that is not a query statement as a first to-be-processed statement, and record the second transaction statement that is not a query statement as a second to-be-processed statement.

[0106] The first application processing unit 303 is configured to perform application processing on transaction logic information in the first application and the first to-be-processed statement respectively, to obtain a transaction interface corresponding to the transaction logic information and a data operation interface corresponding to the first to-be-processed statement.

[0107] The second application processing unit 304 is configured to perform application processing on the second to-be-processed statement in the second application, to obtain a program interface corresponding to the second operation statement.

[0108] Preferably, the transaction implementation module 40 includes:

[0109] The first interface calling unit is configured to call the program interface through the transaction interface, to acquire target data from the second application through the program interface.

[0110] The second interface calling unit is configured to call the data operation interface through the program interface, to input the target data from the program interface to the data operation interface.

[0111] The data storage unit is configured to store the target data to the first application through the data operation interface, and determine the current transaction implementation.

[0112] Preferably, the transaction implementation module 40 further includes:

[0113] The exception detection unit is configured to detect whether an exception occurs in the transaction interface, the data operation interface and the program interface during implementation of the current transaction.

[0114] The version obtaining unit is configured to obtain initial program versions of the first application and the second application if the transaction interface, the data operation interface or the program interface is abnormal; the initial program versions are versions after the first application and the second application are applied.

[0115] The rollback processing unit is configured to perform interface rollback processing on the transaction interface, the data operation interface and the program interface, so as to roll back the first application and the second application to the initial program versions.

[0116] The transaction implementing unit is configured to adjust the abnormal interface, and implement the current transaction through the normal interface and the adjusted abnormal interface; the abnormal interface refers to the transaction interface, the data operation interface or the program interface that is abnormal; the normal interface refers to the transaction interface, the data operation interface or the program interface that is not abnormal.

[0117] Preferably, the transaction implementing module 40 further comprises:

[0118] The commit policy obtaining unit is configured to obtain a transaction commit policy if the transaction interface, the data operation interface or the program interface is not abnormal.

[0119] The transaction committing unit is configured to determine that the current transaction is completed after the transaction commit policy is executed on the current transaction.

[0120] The specific limitations of the database transaction processing apparatus can refer to the limitations of the database transaction processing method in the foregoing, which will not be repeated here. Each module in the above database transaction processing apparatus can be realized by software, hardware and a combination thereof in whole or in part. The above modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each module.

[0121] In one embodiment, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in FIG. 4. Figure 6The computer device includes a processor, a memory, a network interface and a database connected through a system bus. The processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The database of the computer device is configured to store data used by the database transaction processing in the above embodiments. The network interface of the computer device is configured to communicate with external terminals through a network connection. The computer program is configured to be executed by the processor to implement the database transaction processing method.

[0122] In one embodiment, a computer device is provided, which includes a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor is configured to execute the computer program to implement the database transaction processing method in the above embodiments.

[0123] In one embodiment, a computer readable storage medium is provided, which stores a computer program, and the computer program is configured to be executed by a processor to implement the database transaction processing method in the above embodiments.

[0124] A person of ordinary skill in the art can understand that all or part of the processes in the above embodiments can be completed by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above embodiments. Any reference to memory, storage, database or other medium in the embodiments provided by the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM) and memory bus dynamic RAM (RDRAM).

[0125] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the above-mentioned division of each functional unit and module is exemplified, and in actual application, the above-mentioned functions can be completed by different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above.

[0126] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalents; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.

Claims

1. A method of database transaction processing, characterized by, The application comprises the following steps: acquiring a current transaction; the current transaction indicates that a first application program calls a second application program in the same database; transaction logic information and at least one first operation statement are included in the first application program; detecting whether the first application program and the second application program meet application conditions; when the first application program and the second application program meet the application conditions, the first application program and the second application program are subjected to application processing, so as to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement and a program interface corresponding to the second application program; the current transaction is implemented through the transaction interface, the data operation interface and the program interface; the detection of whether the first application program and the second application program meet the application conditions comprises the following steps: all second operation statements in the second application program are acquired, and it is detected whether the first operation statement and the second operation statement are only query statements; when any one of the first operation statement and any one of the second operation statement is not a query statement, transaction execution information of the current transaction is acquired; the transaction execution information is analyzed to determine a statement execution order of a first transaction statement and a second transaction statement; the first transaction statement refers to a first operation statement participating in the current transaction; the second transaction statement refers to a second operation statement participating in the current transaction; when the statement execution order represents that the first transaction statement is executed after the second transaction statement, it is determined that the first application program and the second application program meet the application conditions.

2. The database transaction processing method of claim 1, wherein, after the detection of whether the first operation statement and the second operation statement are only query statements, the following steps are further included: when the first operation statement and / or the second operation statement are only the query statements, it is determined that the first application program and the second application program do not meet the application conditions. after the determination of the statement execution order of the first transaction statement and the second transaction statement, the following steps are further included: when the statement execution order represents that the first transaction statement is executed before the second transaction statement, it is determined that the first application program and the second application program do not meet the application conditions.

3. The database transaction processing method of claim 1, wherein, the second application program includes at least one second operation statement; the application processing of the first application program and the second application program to obtain the transaction interface corresponding to the transaction logic information, the data operation interface corresponding to the first operation statement and the program interface corresponding to the second application program comprises the following steps: transaction execution information of the current transaction is acquired, and a first transaction statement and a second transaction statement are determined according to the transaction execution information; the first transaction statement refers to the first operation statement participating in the current transaction; the second transaction statement refers to a second operation statement participating in the current transaction; the first transaction statement which is not a query statement is recorded as a first to-be-processed statement, and the second transaction statement which is not a query statement is recorded as a second to-be-processed statement; The transaction logic information in the first application and the first to-be-processed statement are respectively subjected to application processing, to obtain a transaction interface corresponding to the transaction logic information and a data operation interface corresponding to the first to-be-processed statement; The second to-be-processed statement in the second application is subjected to application processing, to obtain a program interface corresponding to the second operation statement.

4. The database transaction processing method of claim 1, wherein, The current transaction is implemented through the transaction interface, the data operation interface and the program interface, including: The program interface is called through the transaction interface, to acquire target data from the second application through the program interface; The data operation interface is called through the program interface, to input the target data from the program interface to the data operation interface; After the target data is stored to the first application through the data operation interface, it is determined that the current transaction is implemented.

5. The database transaction processing method of claim 1, wherein, The current transaction is implemented through the transaction interface, the data operation interface and the program interface, further including: During implementation of the current transaction, it is detected whether the transaction interface, the data operation interface and the program interface are abnormal; If the transaction interface, the data operation interface or the program interface is abnormal, an initial program version of the first application and the second application is acquired; the initial program version is a version after the first application and the second application are subjected to application processing; The transaction interface, the data operation interface and the program interface are subjected to interface rollback processing, to roll back the first application and the second application to the initial program version; The abnormal interface is adjusted, and the current transaction is implemented through the normal interface and the adjusted abnormal interface; the abnormal interface refers to the transaction interface, the data operation interface or the program interface that is abnormal; the normal interface refers to the transaction interface, the data operation interface or the program interface that is not abnormal.

6. The database transaction processing method of claim 5, wherein, After it is detected whether the transaction interface, the data operation interface and the program interface are abnormal, further including: If the transaction interface, the data operation interface or the program interface is not abnormal, a transaction commit strategy is acquired; After the transaction commit strategy is executed on the current transaction, it is determined that the current transaction is completed.

7. A database transaction processing apparatus characterized by comprising: Including: A transaction acquisition module is configured to acquire a current transaction; the current transaction indicates that a first application in a same database calls a second application; The first application includes transaction logic information and at least one first operation statement; A condition detection module is configured to detect whether the first application and the second application meet an application condition; An application processing module is configured to, when the first application and the second application meet the application condition, subject the first application and the second application to application processing, to obtain a transaction interface corresponding to the transaction logic information, a data operation interface corresponding to the first operation statement and a program interface corresponding to the second application. a transaction implementation module, configured to implement the current transaction through the transaction interface, the data operation interface and the program interface; The detection of whether the first application and the second application meet the application condition comprises: acquiring all second operation statements in the second application, and detecting whether the first operation statement and the second operation statement are only query statements; when any one of the first operation statement and any one of the second operation statement are not query statements, acquiring transaction execution information of the current transaction; parsing the transaction execution information to determine a statement execution order of first transaction statements and second transaction statements; the first transaction statement refers to the first operation statement participating in the current transaction; the second transaction statement refers to the second operation statement participating in the current transaction; when the statement execution order represents that the first transaction statement is executed after the second transaction statement, it is determined that the first application and the second application meet the application condition.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the database transaction processing method in any one of claims 1 to 6.

9. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 8. The computer program is executed by the processor to implement the database transaction processing method in any one of claims 1 to 6.

Citation Information

Patent Citations

  • API arrangement method, storage medium, electronic equipment and system

    CN109634571A