Method, device, computer equipment and storage medium for handling transaction rollback exception
Patent Information
- Application Number
- CN202010098092.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-02-18
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2040-02-18
AI Technical Summary
[0005]本申请实施例的目的在于提出一种事务回滚异常的处理方法,旨在解决现有的事务异常处理方法普遍耗费极大的人力资源,处理效率低的问题
[0027] The present invention provides a method for handling transaction rollback exceptions, which includes receiving an exception signal sent by a monitoring device; responding to the exception signal, reading a thread backup system, obtaining exclusive thread data in the thread backup system, wherein the exclusive thread data carries at least a thread start time; reading a database, obtaining continuously active transaction data in the database, wherein the transaction data carries at least a transaction start time; judging whether the thread start time is consistent with the transaction start time; if the thread start time is consistent with the transaction start time, judging whether the transaction data meets a connection exception condition; if the transaction data meets the connection exception condition, performing at least the following steps: replacing the original connection driver of the database with a target connection driver; if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection exception condition, outputting the continuously active transaction data. By knowing whether the source of the exception signal is caused by a connection exception, if it is caused by a connection exception, the problem of transaction rollback failure occurring during the upgrade process can be effectively solved, and manual processing of exception data is no longer required, saving manpower and time for repeated exception processing, and ensuring the stability of the business system.
Smart Images

Figure CN111400085B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, computer equipment, and storage medium for processing transaction rollback exceptions. Background Art
[0002] Oracle Database is one of the most widely used relational databases. With official vulnerability fixes and the addition of functional modules, Oracle Database versions have evolved from the previously popular 10g / 11g to the current 12c. Many enterprises and organizations require regular database upgrades to ensure database security. However, with the update to 12c, incompatibility with the WebLogic (JAVAEE-based middleware) JDBC (Java DataBase Connectivity) driver has been discovered, resulting in transaction rollback issues.
[0003] There is a method for handling transaction anomalies, which is to manually find abnormal data and conduct step-by-step investigation, testing and verification based on the abnormal data to achieve the effect of eliminating the anomaly.
[0004] However, traditional transaction exception handling methods are generally inefficient. Manually searching for abnormal data requires a huge amount of human resources and has low processing efficiency. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to propose a method for handling transaction rollback exceptions, aiming to solve the problem that existing transaction exception handling methods generally consume a lot of human resources and have low processing efficiency.
[0006] In order to solve the above technical problems, the embodiment of the present application provides a method for handling transaction rollback exceptions, which adopts the following technical solutions:
[0007] Receive abnormal signals sent by monitoring devices;
[0008] In response to the abnormal signal, reading the thread backup system, and obtaining exclusive thread data in the thread backup system, wherein the exclusive thread data at least carries a thread start time;
[0009] Reading a database, obtaining continuously active transaction data from the database, wherein the transaction data at least carries a transaction start time;
[0010] Determine whether the thread start time is consistent with the transaction start time;
[0011] If the thread start time is consistent with the transaction start time, determining whether the transaction data meets the connection abnormality condition;
[0012] If the transaction data satisfies the connection abnormality condition, at least the following steps are performed: replacing the original connection driver of the database with the target connection driver;
[0013] If the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection abnormality condition, the continuously active transaction data is output.
[0014] In order to solve the above technical problems, the embodiment of the present application provides a device for handling transaction rollback exceptions, which adopts the following technical solutions:
[0015] A signal receiving module, used for receiving abnormal signals sent by the monitoring device;
[0016] a signal response module, configured to respond to the abnormal signal, read the thread backup system, and obtain exclusive thread data from the thread backup system, wherein the exclusive thread data at least carries a thread start time;
[0017] A data reading module is used to read a database and obtain continuously active transaction data from the database, wherein the transaction data at least carries a transaction start time;
[0018] A time judgment module, used to judge whether the thread start time is consistent with the transaction start time;
[0019] an abnormality judgment module, configured to judge whether the transaction data satisfies a connection abnormality condition if the thread start time is consistent with the transaction start time;
[0020] A driver update module is configured to, if the transaction data satisfies a connection abnormality condition, at least perform the following steps: replacing an original connection driver of the database with a target connection driver;
[0021] A data output module is configured to output the continuously active transaction data if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection abnormality condition.
[0022] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0023] The system comprises a memory and a processor, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by the processor, the steps of the method for handling transaction rollback exceptions as described above are implemented.
[0024] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0025] The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for handling transaction rollback exceptions as described above.
[0026] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0027] The present invention provides a method for handling transaction rollback exceptions, which includes receiving an exception signal sent by a monitoring device; responding to the exception signal, reading a thread backup system, obtaining exclusive thread data in the thread backup system, wherein the exclusive thread data carries at least a thread start time; reading a database, obtaining continuously active transaction data in the database, wherein the transaction data carries at least a transaction start time; judging whether the thread start time is consistent with the transaction start time; if the thread start time is consistent with the transaction start time, judging whether the transaction data meets a connection exception condition; if the transaction data meets the connection exception condition, performing at least the following steps: replacing the original connection driver of the database with a target connection driver; if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection exception condition, outputting the continuously active transaction data. By knowing whether the source of the exception signal is caused by a connection exception, if it is caused by a connection exception, the problem of transaction rollback failure occurring during the upgrade process can be effectively solved, and manual processing of exception data is no longer required, saving manpower and time for repeated exception processing, and ensuring the stability of the business system. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In order to more clearly illustrate the solutions in this application, a brief introduction will be given below to the drawings required for use in the description of the embodiments of this application. Obviously, the drawings described below are some embodiments of this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0029] Figure 1 This is a flowchart of a method for handling transaction rollback exceptions provided in the first embodiment of the present invention;
[0030] Figure 2 yes Figure 1 Implementation flow chart of step S105;
[0031] Figure 3 yes Figure 1 Implementation flow chart of step S106;
[0032] Figure 4 1 is a schematic diagram of the structure of the target connection drive testing method provided in the first embodiment of the present invention;
[0033] Figure 5 yes Figure 4 Implementation flow chart of step S403;
[0034] Figure 6 2 is a schematic diagram of the structure of a device for processing transaction rollback exceptions provided in a second embodiment of the present invention;
[0035] Figure 7 2 is a schematic diagram of the structure of an abnormality judgment module provided in the second embodiment of the present invention;
[0036] Figure 8 2 is a schematic diagram of the structure of a driver update module provided in the second embodiment of the present invention;
[0037] Figure 9 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0038] Unless otherwise defined, all technical and scientific terms used herein have the same meanings as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of the application are for the purpose of describing specific embodiments only and are not intended to limit this application. The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of this application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0039] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute an independent or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0040] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0041] The method for handling transaction rollback exceptions provided by the embodiment of the present invention can effectively solve the problem of transaction rollback failure during the upgrade process by determining whether the source of the exception signal is caused by a connection exception. If so, it can be solved by updating the connection driver in the database. Manual processing of exception data is no longer required, which saves manpower and time for repeated exception processing and ensures the stability of the business system.
[0042] Example 1
[0043] Figure 1 A flowchart of a method for handling transaction rollback exceptions provided in the first embodiment of the present invention is shown. For ease of description, only the parts related to the present invention are shown.
[0044] In step S101, an abnormality signal sent by a monitoring device is received.
[0045] In an embodiment of the present invention, the monitoring device is a real-time detection tool suitable for an Oracle database, which is used to collect statistical information of the operating system. As an example, the monitoring device can be a WebLogic management console, which can obtain various performance indicators in real time. Through the console, the performance and operating status of WebLogic, published applications, resources, etc. can be monitored; the monitoring device can also be a CHM (Cluster Health Monitor), which collects statistical information of the operating system through the OS API, such as memory, SWAP space usage, process, IO usage, network and other related data. It should be understood that the examples of the monitoring device here are only for convenience of understanding and are not used to limit the present invention.
[0046] In an embodiment of the present invention, an abnormal signal refers to the application's exclusive thread data reaching a specified monitoring threshold. The monitoring threshold can be 10, 15 or 20, etc., and is not specifically limited. The abnormal signal can also be notified to the staff through warnings such as telephone and email, so that they can check the application in time to find abnormal instances.
[0047] In step S102, in response to the abnormal signal, the thread backup system is read, and exclusive thread data is obtained from the thread backup system, where the exclusive thread data at least carries the thread start time.
[0048] In an embodiment of the present invention, the thread backup system is used to record the contents of the thread portion of a storage device at a specific time in another storage device, and back up all threads that meet the time characteristics so as to be used to locate the source of abnormal data.
[0049] In the embodiment of the present invention, exclusive thread data refers to data that generates hogging threads. When a thread attempts to roll back a transaction, the resources it needs to acquire are locked, resulting in the thread attempting to roll back the transaction failing to roll back and being suspended, which in turn leads to the generation of more hogging threads.
[0050] In the embodiment of the present invention, the thread start time is used to record the time node of rolling back the thread started by a transaction.
[0051] In step S103 , a database is read to obtain continuously active transaction data from the database, where the transaction data at least carries a transaction start time.
[0052] In the embodiment of the present invention, the database refers to an Oracle database.
[0053] In the embodiment of the present invention, continuously active transaction data refers to transactions that are continuously in the "ACTIVE" state in the above Oracle database.
[0054] In the embodiment of the present invention, the transaction start time is used to record the time node when the transaction is started.
[0055] In step S104 , it is determined whether the thread start time is consistent with the transaction start time.
[0056] In the embodiment of the present invention, whether the thread start time is consistent with the transaction start time is determined, thereby determining whether the thread is used to roll back the transaction.
[0057] In step S105 , if the thread start time is consistent with the transaction start time, it is determined whether the transaction data meets the connection abnormality condition.
[0058] In an embodiment of the present invention, a connection abnormality condition refers to the above-mentioned continuously active transaction data not performing any database operations and not being closed normally. As an example, for example, Retry rollback request for tx (Retry Tx rollback request): 'Xid=BEA1-2C9101B1098244D0337F(212363144), Status=Unknown, numRepliesOwedMe=0 (number of replies originating from me), numRepliesOwedOthers=0 (number of replies originating from others). It should be understood that the examples of satisfying the connection abnormality condition here are only for convenience of understanding and are not used to limit the present invention.
[0059] In step S106 , if the transaction data satisfies the connection abnormality condition, at least the following steps are performed: replacing the original connection driver of the database with the target connection driver.
[0060] In the embodiment of the present invention, the original connection driver refers to the connection driver currently being used in the above Oracle database. Specifically, the original connection driver is ojdbc6.jar (version 11.2.0.3.0).
[0061] In the embodiment of the present invention, the target connection driver refers to a connection driver applicable to the Oracle database version 12.1.0.2.0.
[0062] In step S107 , if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection abnormality condition, the continuously active transaction data is output.
[0063] In an embodiment of the present invention, when the source of the abnormal signal is not caused by a connection abnormality and the rollback abnormality cannot be resolved by updating the connection driver, the system will output the continuously active transaction data in the database to the staff for manual investigation.
[0064] In an embodiment of the present invention, a method for handling transaction rollback exceptions is provided, comprising: receiving an exception signal sent by a monitoring device; responding to the exception signal, reading a thread backup system, obtaining exclusive thread data in the thread backup system, the exclusive thread data carrying at least a thread start time; reading a database, obtaining continuously active transaction data in the database, the transaction data carrying at least a transaction start time; determining whether the thread start time is consistent with the transaction start time; if the thread start time is consistent with the transaction start time, determining whether the transaction data meets a connection exception condition; if the transaction data meets the connection exception condition, performing at least the following steps: replacing the original connection driver of the database with a target connection driver; if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection exception condition, outputting the continuously active transaction data. By determining whether the source of the exception signal is caused by a connection exception, if it is caused by a connection exception, the problem of transaction rollback failure occurring during the upgrade process can be effectively solved, eliminating the need to manually process exception data, saving manpower and time for repeated exception processing, and ensuring the stability of the business system.
[0065] Continue to refer Figure 2 , showing Figure 1 For the sake of convenience, only the part related to the present invention is shown in the implementation flow chart of step S105.
[0066] As some optional implementations of the first embodiment, the above step S105 specifically includes: step S201, step S202, step S203 and step S204.
[0067] In step S201 , inactive session control data corresponding to the continuously active transaction data is obtained from a session control table of the database.
[0068] In the embodiment of the present invention, the session control table refers to a recording process of the interaction of the user's entire session activities and the tracking of the computer system during the human-computer interaction process.
[0069] In an embodiment of the present invention, after continuously active transaction data is obtained, the session control table can be associated with the special exchange address of the continuously active transaction data to find the inactive session control data associated with the continuously active transaction data.
[0070] In step S202, it is determined whether there is a database operation record for the inactive session control data.
[0071] In the embodiment of the present invention, the data operation record refers to the operation record of human-computer interaction during the human-computer interaction process.
[0072] In step S203, if the inactive session control data has a database operation record, the transaction data does not meet the connection abnormality condition.
[0073] In an embodiment of the present invention, when there are database operation records in the inactive session control data, it means that the connection driver operates normally during the human-computer interaction process, and the reason for the transaction rollback exception is not caused by a connection driver problem, but other reasons exist.
[0074] In step S204, if there is no database operation record for the inactive session control data, the transaction data meets the connection abnormality condition.
[0075] In an embodiment of the present invention, when there is no database operation record in the inactive session control data, it means that during the human-computer interaction process, the connection driver is not started, and the human-computer interaction cannot achieve normal data connection, which means that the reason for the transaction rollback exception is caused by a connection driver problem.
[0076] Continue to refer Figure 3 , showing Figure 1 For the sake of convenience, only the part related to the present invention is shown in the implementation flow chart of step S106.
[0077] As some optional implementations of the first embodiment of the present invention, the above-mentioned step S106 specifically includes: step S301, step S302 and step S303.
[0078] In step S301, if the transaction data meets the connection abnormality condition, it is determined whether all the data in the database is an I2C database.
[0079] In the embodiment of the present invention, the 12C database refers to an Oracle 12C database, that is, an Oracle database with an application version of 12.1.0.2.0.
[0080] In step S302 , if all the data in the database is an 12C database, the original connection driver of the database is replaced with the target connection driver.
[0081] In step S303, if the data in the database is not entirely an 12C database, a database incompatibility signal is output.
[0082] In an embodiment of the present invention, since the target connection driver is only applicable to Oracle database version 12.1.0.2.0, if the current database environment has Oracle 10g database and 12c database in use at the same time, incompatibility will occur. Therefore, by determining whether all databases are 12c databases, it is ensured that no incompatibility will occur when updating the connection driver, thereby effectively improving the stability of the system.
[0083] Continue to refer Figure 4 , shows an implementation flow chart of the target connection driven testing method. For ease of explanation, only the part related to the present invention is shown.
[0084] As some optional implementations of the first embodiment, after step S106, the electronic device may further perform the following steps: step S401, step S402, step S403, and step S404.
[0085] In step S401, the target connection driver is run in a test environment, where data in the test environment is the same as data in the database.
[0086] In this embodiment of the present invention, the test environment refers to a description of the software and hardware environment on which the test is run, as well as any other software that interacts with the software under test, including drivers and stubs. The connection driver is the target connection driver described above, while other computer hardware, software, network devices, historical data, etc. are the same as the database data currently used by the system.
[0087] In step S402, it is determined whether the operating result of the test environment contains the abnormal signal.
[0088] In step S403, if the running result of the test environment does not contain the abnormal signal, an abnormality resolution success signal is output.
[0089] In step S404, if the operating result of the test environment contains the abnormal signal, an abnormality resolution failure signal is output.
[0090] In an embodiment of the present invention, by changing the connection driver variables here to perform a run test in a test environment that is the same as the database data used by the system, it is determined whether an abnormal signal still appears after the connection driver is updated, thereby determining whether the transaction rollback abnormality problem can be solved, thereby improving the stability and practicality of the system.
[0091] Continue to refer Figure 5 , showing Figure 4 For the sake of convenience, only the part related to the present invention is shown in the implementation flow chart of step S403.
[0092] As some optional implementations of the first embodiment, the above step S403 specifically includes: step S501, step S502 and step S503.
[0093] In step S501, it is determined whether there are other abnormal signals in the operating results of the test environment.
[0094] In this embodiment of the present invention, "other exception signals" refer to exception signals for transactions other than the aforementioned continuously active transactions. These other transactions are businesses other than the currently active transaction, such as insurance and security services. Thus, "other transactions" refer to transactions used to execute other businesses.
[0095] In step S502, if there are other abnormal signals in the running result of the test environment, the abnormality resolution failure signal is output.
[0096] In step S503, if there are no other abnormal signals in the running result of the test environment, the abnormality resolution success signal is output.
[0097] In an embodiment of the present invention, in order to avoid incompatibility caused by rollback exceptions in other transactions after updating the connection driver, it is determined whether there are other abnormal signals in the running results of the test environment. This ensures that updating the connection driver can solve the transaction rollback exception problem without affecting the normal operation of other transactions, thereby ensuring the stability of the system.
[0098] In summary, the present invention provides a method for handling transaction rollback exceptions, which includes receiving an exception signal sent by a monitoring device; responding to the exception signal, reading a thread backup system, and obtaining exclusive thread data in the thread backup system, wherein the exclusive thread data carries at least a thread start time; reading a database, and obtaining continuously active transaction data in the database, wherein the transaction data carries at least a transaction start time; judging whether the thread start time is consistent with the transaction start time; if the thread start time is consistent with the transaction start time, judging whether the transaction data meets the connection exception condition; if the transaction data meets the connection exception condition, at least performing the following steps: replacing the original connection driver of the database with the target connection driver; if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection exception condition, outputting the continuously active transaction data. By knowing whether the source of the exception signal is caused by a connection exception, if it is caused by a connection exception, it can be solved by updating the connection driver in the database, which can effectively solve the problem of transaction rollback failure during the upgrade process. Manual processing of exception data is no longer required, saving manpower and time for repeated exception processing, and ensuring the stability of the business system. At the same time, since the above-mentioned target connection driver is only applicable to the Oracle database version 12.1.0.2.0, if the current database environment has Oracle 10g database and 12c database in use at the same time, incompatibility will occur. Therefore, by judging whether all databases are 12C databases, it is ensured that no incompatibility will occur when updating the connection driver, effectively improving the stability of the system; by changing the connection driver variables here and running the test in the same test environment as the database data used by the system, it is judged whether abnormal signals still appear after the connection driver is updated, so as to determine whether the transaction rollback abnormality problem can be solved, thereby improving the stability and practicality of the system; in order to avoid the incompatibility caused by rollback abnormalities in other transactions after updating the connection driver, it is judged whether there are other abnormal signals in the running results of the test environment, ensuring that updating the connection driver can solve the transaction rollback abnormality problem while not affecting the normal operation of other transactions, thereby ensuring the stability of the system.
[0099] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed, the program can include the processes in the above-described method embodiments. The aforementioned storage medium can be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0100] It should be understood that although the steps in the flowcharts of the accompanying drawings are shown in sequence as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the flowcharts of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
[0101] Example 2
[0102] Further references Figure 6 , as mentioned above Figure 1 The present application provides a device for processing transaction rollback exceptions. Figure 1 Corresponding to the method embodiment shown, the yellow paper can be specifically applied to various electronic devices.
[0103] like Figure 6 As shown, the transaction rollback exception processing device 100 provided in the second embodiment of the present invention includes: a signal receiving module 101, a signal response module 102, a data reading module 103, a time judgment module 104, an exception judgment module 105, a driver update module 106 and a data output module.
[0104] The signal receiving module 101 is used to receive abnormal signals sent by the monitoring device;
[0105] A signal response module 102 is configured to respond to the abnormal signal, read the thread backup system, and obtain exclusive thread data from the thread backup system, where the exclusive thread data at least carries a thread start time;
[0106] A data reading module 103 is configured to read a database and obtain continuously active transaction data from the database, wherein the transaction data at least carries a transaction start time;
[0107] A time determination module 104 is configured to determine whether the thread start time is consistent with the transaction start time;
[0108] The abnormality judgment module 105 is configured to judge whether the transaction data satisfies a connection abnormality condition if the thread start time is consistent with the transaction start time;
[0109] The driver update module 106 is configured to, if the transaction data satisfies the connection abnormality condition, at least perform the following steps: replace the original connection driver of the database with the target connection driver;
[0110] The data output module 107 is configured to output the continuously active transaction data if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection abnormality condition.
[0111] In an embodiment of the present invention, the monitoring device is a real-time detection tool suitable for an Oracle database, which is used to collect statistical information of the operating system. As an example, the monitoring device can be a WebLogic management console, which can obtain various performance indicators in real time. Through the console, the performance and operating status of WebLogic, published applications, resources, etc. can be monitored; the monitoring device can also be a CHM (Cluster Health Monitor), which collects statistical information of the operating system through the OS API, such as memory, SWAP space usage, process, IO usage, network and other related data. It should be understood that the examples of the monitoring device here are only for convenience of understanding and are not used to limit the present invention.
[0112] In an embodiment of the present invention, an abnormal signal refers to the application's exclusive thread data reaching a specified monitoring threshold. The monitoring threshold can be 10, 15 or 20, etc., and is not specifically limited. The abnormal signal can also be notified to the staff through warnings such as telephone and email, so that they can check the application in time to find abnormal instances.
[0113] In an embodiment of the present invention, the thread backup system is used to record the contents of the thread portion of a storage device at a specific time in another storage device, and back up all threads that meet the time characteristics so as to be used to locate the source of abnormal data.
[0114] In the embodiment of the present invention, exclusive thread data refers to data that generates hogging threads. When a thread attempts to roll back a transaction, the resources it needs to acquire are locked, resulting in the thread attempting to roll back the transaction failing to roll back and being suspended, which in turn leads to the generation of more hogging threads.
[0115] In the embodiment of the present invention, the thread start time is used to record the time node of rolling back the thread started by a transaction.
[0116] In the embodiment of the present invention, the database refers to an Oracle database.
[0117] In the embodiment of the present invention, continuously active transaction data refers to transactions that are continuously in the "ACTIVE" state in the above Oracle database.
[0118] In the embodiment of the present invention, the transaction start time is used to record the time node when the transaction is started.
[0119] In the embodiment of the present invention, whether the thread start time is consistent with the transaction start time is determined, thereby determining whether the thread is used to roll back the transaction.
[0120] In an embodiment of the present invention, a connection abnormality condition refers to the above-mentioned continuously active transaction data not performing any database operations and not being closed normally. As an example, for example, Retry rollback request for tx (Retry Tx rollback request): 'Xid=BEA1-2C9101B1098244D0337F(212363144), Status=Unknown, numRepliesOwedMe=0 (number of replies originating from me), numRepliesOwedOthers=0 (number of replies originating from others). It should be understood that the examples of satisfying the connection abnormality condition here are only for convenience of understanding and are not used to limit the present invention.
[0121] In the embodiment of the present invention, the original connection driver refers to the connection driver currently being used in the above Oracle database. Specifically, the original connection driver is ojdbc6.jar (version 11.2.0.3.0).
[0122] In the embodiment of the present invention, the target connection driver refers to a connection driver applicable to the Oracle database version 12.1.0.2.0.
[0123] In an embodiment of the present invention, when the source of the abnormal signal is not caused by a connection abnormality and the rollback abnormality cannot be resolved by updating the connection driver, the system will output the continuously active transaction data in the database to the staff for manual investigation.
[0124] In an embodiment of the present invention, a device for handling transaction rollback exceptions is provided, comprising: a signal receiving module for receiving an exception signal sent by a monitoring device; a signal response module for responding to the exception signal, reading a thread backup system, and obtaining exclusive thread data from the thread backup system, wherein the exclusive thread data carries at least a thread start time; a data reading module for reading a database, and obtaining continuously active transaction data from the database, wherein the transaction data carries at least a transaction start time; a time determination module for determining whether the thread start time is consistent with the transaction start time; an exception determination module for determining whether the transaction data meets a connection exception condition if the thread start time is consistent with the transaction start time; a driver update module for performing at least the following steps if the transaction data meets the connection exception condition: replacing an original connection driver of the database with a target connection driver; and a data output module for outputting the continuously active transaction data if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection exception condition. By knowing whether the source of the abnormal signal is caused by a connection abnormality, if it is caused by a connection abnormality, it can be solved by updating the connection driver in the database, which can effectively solve the problem of transaction rollback failure during the upgrade process. Manual processing of abnormal data is no longer required, saving manpower and time for repeated exception processing, and ensuring the stability of the business system.
[0125] In some optional implementations of the second embodiment of the present invention, such as Figure 7 As shown, the above-mentioned abnormality judgment module 105 includes: a data reading submodule 1051, a record judgment submodule 1052, a first result submodule 1053 and a second result submodule 1054. Among them:
[0126] The data reading submodule 1051 is configured to obtain, from the session control table of the database, inactive session control data corresponding to the continuously active transaction data;
[0127] A record determination submodule 1052 is configured to determine whether there is a database operation record for the inactive session control data;
[0128] A first result submodule 1053 is configured to determine that the transaction data does not meet the connection abnormality condition if a database operation record exists for the inactive session control data;
[0129] The second result submodule 1054 is configured to determine that if no database operation record exists for the inactive session control data, the transaction data satisfies the connection abnormality condition.
[0130] In the embodiment of the present invention, the session control table refers to a recording process of the interaction of the user's entire session activities and the tracking of the computer system during the human-computer interaction process.
[0131] In an embodiment of the present invention, after continuously active transaction data is obtained, the session control table can be associated with the special exchange address of the continuously active transaction data to find the inactive session control data associated with the continuously active transaction data.
[0132] In the embodiment of the present invention, the data operation record refers to the operation record of human-computer interaction during the human-computer interaction process.
[0133] In an embodiment of the present invention, when there are database operation records in the inactive session control data, it means that the connection driver operates normally during the human-computer interaction process, and the reason for the transaction rollback exception is not caused by a connection driver problem, but other reasons exist.
[0134] In an embodiment of the present invention, when there is no database operation record in the inactive session control data, it means that during the human-computer interaction process, the connection driver is not started, and the human-computer interaction cannot achieve normal data connection, which means that the reason for the transaction rollback exception is caused by a connection driver problem.
[0135] In some optional implementations of the second embodiment of the present invention, such as Figure 8 As shown, the driver update module 106 includes: a database determination submodule 1061, a driver update submodule 1062 and a data output submodule 1063.
[0136] The database judgment submodule 1061 is configured to judge whether all the data in the database is an I2C database if the transaction data satisfies the abnormal connection condition;
[0137] The driver update submodule 1062 is configured to replace the original connection driver of the database with the target connection driver if all the data in the database is an I2C database;
[0138] The data output submodule 1063 is configured to output a database incompatibility signal if the data in the database is not entirely an I2C database.
[0139] In the embodiment of the present invention, the 12C database refers to an Oracle 12C database, that is, an Oracle database with an application version of 12.1.0.2.0.
[0140] In an embodiment of the present invention, since the target connection driver is only applicable to Oracle database version 12.1.0.2.0, if the current database environment has Oracle 10g database and 12c database in use at the same time, incompatibility will occur. Therefore, by determining whether all databases are 12c databases, it is ensured that no incompatibility will occur when updating the connection driver, thereby effectively improving the stability of the system.
[0141] In some optional implementations of the second embodiment of the present invention, the transaction rollback exception processing device further includes: a driver test submodule, a first test judgment submodule, a first test success submodule, and a first test failure submodule.
[0142] A driver test submodule, configured to run the target connection driver in a test environment, wherein the data in the test environment is the same as the data in the database;
[0143] A first test judgment submodule is used to judge whether the running result of the test environment contains the abnormal signal;
[0144] A first test success submodule, configured to output an exception resolution success signal if the operation result of the test environment does not contain the exception signal;
[0145] The first test failure submodule is configured to output an exception resolution failure signal if the abnormal signal exists in the running result of the test environment.
[0146] In some optional implementations of the second embodiment of the present invention, the test success submodule includes: a second test judgment submodule, a second test failure submodule, and a second test success submodule.
[0147] The second test judgment submodule is used to judge whether there are other abnormal signals in the running results of the test environment;
[0148] A second test failure submodule is configured to output the abnormality resolution failure signal if other abnormal signals are present in the operating result of the test environment;
[0149] The second test success submodule is configured to output the exception resolution success signal if no other exception signals exist in the running result of the test environment.
[0150] In summary, an embodiment of the present invention provides a device for processing transaction rollback exceptions, comprising: a signal receiving module for receiving an exception signal sent by a monitoring device; a signal response module for responding to the exception signal, reading a thread backup system, and obtaining exclusive thread data from the thread backup system, wherein the exclusive thread data carries at least a thread start time; a data reading module for reading a database and obtaining continuously active transaction data from the database, wherein the transaction data carries at least a transaction start time; a time determination module for determining whether the thread start time is consistent with the transaction start time; an exception determination module for determining whether the transaction data meets a connection exception condition if the thread start time is consistent with the transaction start time; a driver update module for performing at least the following steps if the transaction data meets the connection exception condition: replacing an original connection driver of the database with a target connection driver; and a data output module for outputting the continuously active transaction data if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection exception condition. By knowing whether the source of the abnormal signal is caused by a connection abnormality, if it is caused by a connection abnormality, it can be solved by updating the connection driver in the database, which can effectively solve the problem of transaction rollback failure during the upgrade process. Manual processing of abnormal data is no longer required, saving manpower and time for repeated exception processing, and ensuring the stability of the business system. At the same time, since the above-mentioned target connection driver is only applicable to the Oracle database version 12.1.0.2.0, if the current database environment has Oracle 10g database and 12c database in use at the same time, incompatibility will occur. Therefore, by judging whether all databases are 12C databases, it is ensured that no incompatibility will occur when updating the connection driver, effectively improving the stability of the system; by changing the connection driver variables here and running the test in the same test environment as the database data used by the system, it is judged whether abnormal signals still appear after the connection driver is updated, so as to determine whether the transaction rollback abnormality problem can be solved, thereby improving the stability and practicality of the system; in order to avoid the incompatibility caused by rollback abnormalities in other transactions after updating the connection driver, it is judged whether there are other abnormal signals in the running results of the test environment, ensuring that updating the connection driver can solve the transaction rollback abnormality problem while not affecting the normal operation of other transactions, thereby ensuring the stability of the system.
[0151] To solve the above technical problems, the present application also provides a computer device. Figure 9 , Figure 9 This is a basic structural block diagram of the computer device in this embodiment.
[0152] The computer device 9 includes a memory 91, a processor 92, and a network interface 93 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 9 with components 91-93, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.
[0153] The computer device may be a desktop computer, notebook computer, PDA, cloud server, etc. The computer device may interact with the user via a keyboard, mouse, remote control, touchpad, or voice control device.
[0154] The memory 91 includes at least one type of readable storage medium, including flash memory, a hard disk, a multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic storage, a magnetic disk, an optical disk, etc. In some embodiments, the memory 91 may be an internal storage unit of the computer device 9, such as the hard disk or internal memory of the computer device 9. In other embodiments, the memory 91 may also be an external storage device of the computer device 9, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash memory card, etc. Of course, the memory 91 may also include both the internal storage unit of the computer device 9 and its external storage devices. In this embodiment, the memory 91 is generally used to store the operating system and various application software installed on the computer device 9, such as the program code for the method for handling transaction rollback exceptions. In addition, the memory 91 can also be used to temporarily store various types of data that have been output or are to be output.
[0155] In some embodiments, the processor 92 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip. The processor 92 is generally used to control the overall operation of the computer device 9. In this embodiment, the processor 92 is used to execute program code stored in the memory 91 or process data, such as executing the program code of the transaction rollback exception handling method.
[0156] The network interface 93 may include a wireless network interface or a wired network interface. The network interface 93 is generally used to establish a communication connection between the computer device 9 and other electronic devices.
[0157] The present application also provides another embodiment, namely, providing a computer-readable storage medium, which stores a transaction rollback exception handling program, and the transaction rollback exception handling program can be executed by at least one processor to enable the at least one processor to perform the steps of the transaction rollback exception handling method as described above.
[0158] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of this application, or the part that contributes to the existing technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of this application.
[0159] Obviously, the embodiments described above are only some of the embodiments of the present application, rather than all of the embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application has been described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions described in the aforementioned specific embodiments, or to make equivalent replacements for some of the technical features therein. Any equivalent structure made using the contents of the present application specification and the accompanying drawings, directly or indirectly used in other related technical fields, is also within the scope of patent protection of the present application.
Claims
1. A method for handling transaction rollback exceptions, characterized in that: The method comprises the following steps: Receive abnormal signals sent by monitoring devices; In response to the abnormal signal, reading the thread backup system, and obtaining exclusive thread data in the thread backup system, wherein the exclusive thread data at least carries a thread start time; Reading a database, obtaining continuously active transaction data from the database, wherein the transaction data at least carries a transaction start time; Determine whether the thread start time is consistent with the transaction start time; If the thread start time is consistent with the transaction start time, determining whether the transaction data meets a connection abnormality condition, wherein the connection abnormality condition refers to the continuously active transaction data not performing any database operations and not being closed normally; If the transaction data satisfies the connection abnormality condition, at least the following steps are performed: replacing the original connection driver of the database with the target connection driver; If the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection abnormality condition, the continuously active transaction data is output.
2. The method for handling transaction rollback exception according to claim 1, characterized in that: The step of determining whether the transaction data meets the connection abnormality condition specifically includes the following steps: Acquire inactive session control data corresponding to the continuously active transaction data from a session control table of the database; Determining whether there is a database operation record for the inactive session control data; If the inactive session control data has a database operation record, the transaction data does not meet the connection abnormality condition; If there is no database operation record for the inactive session control data, the transaction data meets the connection abnormality condition.
3. The method for handling transaction rollback exception according to claim 1, wherein: If the transaction data satisfies the connection abnormality condition, at least the following steps are performed: a step of replacing the original connection driver of the database with the target connection driver, specifically including the following steps: If the transaction data satisfies the abnormal connection condition, determining whether all the databases are 12C databases, wherein the 12C databases are Oracle 12C databases; If all the databases are 12C databases, the original connection driver of the database is replaced with the target connection driver; If the database is not entirely an 12C database, a database incompatibility signal is output.
4. The method for handling transaction rollback exception according to claim 1, wherein: If the transaction data satisfies the connection abnormality condition, at least the following steps are performed: after the step of replacing the original connection driver of the database with the target connection driver, the following steps are also included: Running the target connection driver in a test environment, where data in the test environment is the same as data in the database; Determining whether the operating result of the test environment contains the abnormal signal; If the test environment's running result does not contain the abnormal signal, outputting an abnormality resolution success signal; If the abnormal signal exists in the running result of the test environment, an abnormality resolution failure signal is output.
5. The method for handling transaction rollback exception according to claim 4, characterized in that: If the abnormal signal does not exist in the running result of the test environment, the step of outputting an abnormality resolution success signal specifically includes the following steps: Determine whether there are other abnormal signals in the operating results of the test environment; If there are other abnormal signals in the running result of the test environment, output the abnormality resolution failure signal; If there are no other abnormal signals in the running result of the test environment, the abnormality resolution success signal is output.
6. A device for processing transaction rollback exceptions, characterized in that: The device comprises: A signal receiving module, used for receiving abnormal signals sent by the monitoring device; a signal response module, configured to respond to the abnormal signal, read the thread backup system, and obtain exclusive thread data from the thread backup system, wherein the exclusive thread data at least carries a thread start time; A data reading module is used to read a database and obtain continuously active transaction data from the database, wherein the transaction data at least carries a transaction start time; A time judgment module, used to judge whether the thread start time is consistent with the transaction start time; an abnormality determination module, configured to determine whether the transaction data satisfies a connection abnormality condition if the thread start time is consistent with the transaction start time, wherein the connection abnormality condition refers to the continuously active transaction data not performing any database operations and not being closed normally; A driver update module is configured to, if the transaction data satisfies a connection abnormality condition, at least perform the following steps: replacing an original connection driver of the database with a target connection driver; A data output module is configured to output the continuously active transaction data if the thread start time is inconsistent with the transaction start time or the transaction data does not meet the connection abnormality condition.
7. The transaction rollback exception processing device according to claim 6, characterized in that: The driver update module includes: A database judgment submodule, configured to judge whether all the databases are 12C databases if the transaction data satisfies the connection abnormality condition, wherein the 12C database is an Oracle 12C database; A driver update submodule, configured to replace the original connection driver of the database with the target connection driver if all the databases are 12C databases; The data output submodule is used to output a database incompatibility signal if the database is not entirely an 12C database.
8. The transaction rollback exception processing device according to claim 6, characterized in that: The abnormality judgment module includes: A data reading submodule, configured to obtain inactive session control data corresponding to the continuously active transaction data from a session control table of the database; A record determination submodule, configured to determine whether a database operation record exists for the inactive session control data; A first result submodule, configured to determine that if there is a database operation record for the inactive session control data, the transaction data does not meet the connection abnormality condition; The second result submodule is configured to determine that if there is no database operation record for the inactive session control data, the transaction data meets the connection abnormality condition.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method for handling transaction rollback exceptions according to any one of claims 1 to 5 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for handling transaction rollback exceptions according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method for diagnosing large transactions and hotspot transactions of Oracle database
CN106201826A
Transaction tracking within a microprocessor
US9514006B1