Transaction processing method and device based on database connection, equipment and storage medium
By intercepting and listening to database connection requests, and automatically detecting and recording the transaction execution process, the problem of low transaction execution efficiency and high error rate in existing technologies is solved, achieving efficient and automatic transaction optimization and management, and reducing manual costs.
Patent Information
- Application Number
- CN202310173026.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2043-02-22
AI Technical Summary
In existing technologies, manually reading code to check for potential efficiency issues during transaction execution results in low transaction execution efficiency and a high error rate, making it impossible to quickly and accurately identify transaction records that can be optimized.
A database connection-based transaction processing method is provided. This method intercepts database connection requests, detects whether they originate from an open transaction, establishes a connection, listens to the transaction and records the script, identifies transaction records that can be optimized based on the script records, and sends reminder information to optimize the transaction when necessary.
It enables efficient monitoring of the transaction execution process, automatically discovers and promptly identifies transaction records that can be optimized, reduces the error rate, improves transaction execution efficiency, and reduces manual workload and costs.
Smart Images

Figure CN116414846B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database, in particular to a transaction processing method and device based on database connection, equipment and storage medium. BACKGROUND
[0002] With the diversification of Internet business, the function is also more and more complex, even if a relatively simple function is realized, the back end often needs to operate multiple tables and interact with third-party systems, and when performing atomic operation of multiple tables, transaction is born, and the processing of transaction is indispensable to a system. In the related art, whether there is a hidden danger affecting the transaction execution efficiency in the transaction execution process needs to be checked by manually reading the code, and the manual checking cannot quickly and accurately find the transaction record that can be optimized, resulting in a high error rate of the transaction execution process and low transaction execution efficiency. SUMMARY
[0003] The purpose of the present application is to provide a transaction processing method and device based on database connection, equipment and storage medium, to solve the problems existing in the related art that whether there is a hidden danger affecting the transaction execution efficiency in the transaction execution process needs to be checked by manually reading the code, and the manual checking cannot quickly and accurately find the transaction record that can be optimized, resulting in a high error rate of the transaction execution process and low transaction execution efficiency. In order to have a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. This part is not a general review, nor is it intended to determine the key / important elements or delineate the scope of protection of these embodiments. Its only purpose is to present some concepts in a simple form as a prelude to the detailed description that follows.
[0004] According to one aspect of an embodiment of the present application, a transaction processing method based on database connection is provided, comprising:
[0005] intercepting a database connection request;
[0006] detecting whether the intercepted database connection request is from an open transaction;
[0007] if yes, establishing the connection of the transaction and the database according to the database connection request;
[0008] listening to the transaction and establishing a script record of the transaction;
[0009] determining a transaction record that can be optimized according to the script record.
[0010] In some embodiments of the present application, the method further comprises:
[0011] According to the monitored execution process of the transaction, a connection state of the transaction with the database is controlled.
[0012] In some embodiments of the present application, the controlling of the connection state of the transaction with the database according to the monitored execution process of the transaction comprises:
[0013] if the transaction is monitored to be in the execution process, maintaining the connection of the transaction with the database;
[0014] if the execution process of the transaction is monitored to be ended, disconnecting the connection of the transaction with the database.
[0015] In some embodiments of the present application, the establishing of the connection of the transaction with the database according to the database connection request comprises:
[0016] releasing the database connection request so that the database connection request is sent to the database;
[0017] recording information of the to-be-started transaction and obtaining information of the transaction from the connection request;
[0018] recording the information of the transaction into a properties attribute of the database and writing the information of the transaction into a data table for transaction record in the database.
[0019] In some embodiments of the present application, the information of the transaction comprises a unique identifier, a statement type, a table name involved, a current time and a specific executed script.
[0020] In some embodiments of the present application, the determining of the transaction record that can be optimized according to the script record comprises:
[0021] inquiring, according to the script record, whether there is a strongly associated script in the transaction, and if there is, determining the strongly associated script as the transaction record that can be optimized.
[0022] In some embodiments of the present application, the method further comprises:
[0023] sending a prompt information to prompt to optimize the transaction record that can be optimized.
[0024] According to another aspect of the embodiments of the present application, a transaction processing apparatus based on database connection is provided, comprising:
[0025] an intercepting module configured to intercept a database connection request;
[0026] a detecting module configured to detect whether the intercepted database connection request is from a started transaction;
[0027] The connection establishing module is configured to, if yes, establish the connection of the transaction and the database according to the database connection request.
[0028] The monitoring module is configured to monitor the transaction and establish a script record of the transaction.
[0029] The determining module is configured to determine the transaction record that can be optimized according to the script record.
[0030] According to another aspect of the embodiments of the present application, an electronic device is provided, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the program to implement the database connection-based transaction processing method described in any of the above.
[0031] According to another aspect of the embodiments of the present application, a computer readable storage medium is provided, which stores a computer program executable by a processor to implement the database connection-based transaction processing method described in any of the above.
[0032] One of the aspects of the embodiments of the present application can provide the following beneficial effects.
[0033] The database connection-based transaction processing method provided by the embodiments of the present application can achieve the following beneficial effects.
[0034] Other features and advantages of the present application will be described in the following description and become apparent from the description, or can be learned from the description, or can be sufficiently determined from the description, or can be sufficiently determined only through implementation of the embodiments of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0035] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are only some embodiments described in the present application, and for those skilled in the art, other drawings can also be obtained from these drawings without any creative labor.
[0036] Figure 1 An application environment diagram of the transaction processing method based on database connection in an embodiment of the present application is shown.
[0037] Figure 2 A diagram showing the connection of multiple transactions and a database in the related art during execution is shown.
[0038] Figure 3 A flowchart of a transaction processing method based on database connection in an embodiment of the present application is shown.
[0039] Figure 4 A diagram showing the transaction execution process in a specific example of the present application is shown.
[0040] Figure 5 A flowchart of a transaction processing method based on database connection in an embodiment of the present application is shown.
[0041] Figure 6 A flowchart of intercepting a database request and generating a transaction script record in a specific example of the present application is shown.
[0042] Figure 7 A diagram showing the acquisition of an optimizable transaction record from a script record in a specific example of the present application is shown.
[0043] Figure 8 A structural block diagram of a transaction processing apparatus based on database connection in an embodiment of the present application is shown.
[0044] Figure 9 A structural block diagram of a transaction processing apparatus based on database connection in an embodiment of the present application is shown.
[0045] Figure 10 A structural block diagram of an electronic device in an embodiment of the present application is shown.
[0046] Figure 11 A diagram showing a computer readable storage medium in an embodiment of the present application is shown.
[0047] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0048] In order to make the purposes, technical solutions and advantages of the present application clearer, further description will be made to the present application with reference to the drawings and specific embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and not used to limit the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.
[0049] Those skilled in the art can understand that, unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meaning as commonly understood by those skilled in the art in the field of the present application. It should also be understood that terms such as those defined in a general dictionary should be understood to have meanings consistent with those in the context of the prior art, and should not be interpreted to have idealized or overly formal meanings unless specifically defined as such herein.
[0050] Reference Figure 1 As shown, the transaction processing method based on database connection provided by the present application can be applied in the application environment as shown in Figure 1 , wherein the user terminal communicates with the server end through the Internet, and the user terminal can send information to the server end and can also receive information sent by the server end. The server end can intercept the database connection request, detect whether the intercepted database connection request is from an open transaction, and if so, establish a connection between the transaction and the database according to the database connection request, listen to the transaction and establish a script record of the transaction, determine the transaction record that can be optimized according to the script record, and the server end can also send a prompt information to the user terminal to remind the optimization of the foregoing transaction record that can be optimized. The user terminal can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers and portable wearable devices. The server end can be implemented by an independent server or a server cluster composed of multiple servers. The present application will be described in detail through specific embodiments.
[0051] Transaction refers to a program execution unit that accesses and possibly updates various data items in a database. For example, in a java program, transaction represents the entire period from the beginning of the transaction to the end of the transaction, and all operations performed during the period are either all successful or all failed, and except for special cases, the same database connection is used for the entire transaction in the same process. The time of a database connection is limited, i.e. there is a timeout time, and the number of database connections is also limited. If the transaction is not used properly, during the program running process, some connection cannot be obtained and connection timeout error occurs.
[0052] The same database connection is held from the beginning to the end of the entire transaction operation process to ensure that the operation can be rolled back or committed together. The more steps or the more time-consuming steps in the transaction, the longer the duration of the transaction, that is, the duration of holding the database connection.
[0053] Figure 2 A schematic diagram of multiple transactions and a database connected with the database during execution in the related art is shown. Referring to Figure 2 As shown, transaction operation units A, B, C, and D are in the transaction execution process and keep connected with the database, and transaction operation units E, F, G, H, and Z are in the waiting process and wait to be connected with the database. Because the database connections are limited in a time period, if the previously used connections are not released in time, and the application program continuously accepts new requests during running, the new requests cannot get idle connections and report errors at this time, and often a few slow transactions will cause the entire system to collapse like an avalanche, which is an important reason for the long transaction operation time in the related art.
[0054] Transaction granularity control refers to moving out of the transaction operations that are not necessarily implemented in the transaction and are not strongly associated with the query operations, and some logical code calculations, and only keeping the core database change operations in the transaction.
[0055] In the related art, there are many monitoring and detection tools for slow SQL and slow interfaces in the industry, but in fact, many system slow is caused by resource waste due to poor transaction control, and there is a lack of tools for detecting in the dimension of transactions in the related art. In the related art, the detection granularity of slow SQL in the industry is too fine, and the granularity of slow interface is too large, for example, a slow interface takes 5 seconds, but the SQL involved is fast SQL, which causes the database connection pool connection to be exhausted and the monitoring alarm to be frequent, which is difficult to handle. Experienced developers can only check the problem by reading the code, and then find that some scripts execute because of waiting for connection for several seconds, but it cannot be determined which transaction connection holds for too long, which lays hidden dangers for future connection problems.
[0056] Therefore, in view of the defects of the development process and the deficiencies of the tools in the related art, the embodiments of the present application provide a transaction processing method based on a database connection, which can realize monitoring of the transaction execution process, can monitor how long each transaction executes, can locate the operation process of the transaction, and can immediately notify the developer to rectify.
[0057] Referring to Figure 3 As shown, an embodiment of the present application provides a transaction processing method based on a database connection, including steps S10 to S50:
[0058] S10, intercepting the database connection request.
[0059] Specifically, the database connection request can be intercepted by the database connection request interception plug-in.
[0060] In an embodiment, the process of intercepting the database connection request by the database connection request interception plug-in can include: starting a first socket in the interception plug-in, the first socket including a VFS method; obtaining a pointer of the VFS method from the socket file; modifying the pointer of the VFS method to a pointer of the VFS method in the socket; and intercepting the database connection request by the VFS method in the socket.
[0061] Specifically, the database connection request is intercepted by the VFS method in the socket, which is achieved by the IOCTL instruction.
[0062] A database can be regarded as an electronic file cabinet, i.e., a place for storing electronic files. Users can perform operations such as adding, querying, updating, and deleting data in the files. The database is a collection of data stored together in a certain way, shared by multiple users, with as little redundancy as possible, and independent of application programs. The connection to the database is to interact with the database during transaction execution, obtain data in the database, and write data generated during transaction execution into the database.
[0063] S20, detecting whether the intercepted database connection request comes from an open transaction.
[0064] Specifically, the data in the intercepted database connection request is detected. If there is a transaction identifier, it is determined that the database connection request comes from an open transaction.
[0065] Reference Figure 4As shown, in one specific example, the business request triggering the transaction start can include request verification, parameter conversion, logical processing, etc. After the transaction starts, a database connection is obtained, a consumption notification is queried (0.2s), order information is queried (0.1s), a consumption record is added (0.2s), user information is queried (0.1s), a user member card balance is updated (0.2s), a user credit level is queried (1.5s), a consumption record is queried (0.2s), calculation, update of billing information (0.4s), and the transaction ends. After the transaction ends, data conversion, other logic, and response assembly operations are performed, and the operation result is sent to the database. The entire transaction operation holds the same database connection from start to end to ensure that this operation can be rolled back or committed together. The more steps or the more time-consuming steps within the transaction, the longer the duration of the transaction, that is, the duration of holding the database connection.
[0066] S30, if yes, a transaction and a database are connected according to a database connection request.
[0067] In one embodiment, the transaction and the database are connected according to the database connection request, comprising:
[0068] The database connection request is released to send the database connection request to the database; information of a transaction to be started is recorded and the information of the transaction is obtained from the connection request; the information of the transaction is recorded in a properties attribute of the database, and the information of the transaction is written into a data table in the database for transaction record.
[0069] Specifically, the information of the transaction includes a unique identifier, a statement type, a table name involved, a current time, and a specific executed script.
[0070] S40, a script record of the transaction is established by listening to the transaction.
[0071] In one specific example, a transaction listening plug-in is called to intercept the database connection request; connection information in the database connection request is obtained, and it is judged whether there is a started transaction in the database connection request according to the connection information; if yes, the database connection request is released to establish a connection to the database; if no, a UUID corresponding to the database connection request is obtained; and a script storage operation is performed.
[0072] Exemplarily, the UUID corresponding to the database connection request can include: detecting whether there is a UUID in the database connection request; if yes, obtaining the UUID in the database connection request, and if there is no UUID in the connection, generating a UUID and storing it in the attribute of the database connection request.
[0073] UUID is the abbreviation of Universally Unique Identifier, which is a software construction standard and part of the distributed computing environment organized by the Open Software Foundation. The purpose is to let all elements in the distributed system have unique identification information without the need for central control to specify the identification information.
[0074] transaction table
[0075]
[0076] S50, according to the script record, determine the transaction record that can be optimized.
[0077] In an embodiment, according to the script record, determining the transaction record that can be optimized comprises: querying the script record according to the script record to determine whether there is a strong association in the transaction, and if there is, determining the strong association script as the transaction record that can be optimized.
[0078] For example, by querying the interface of the database transaction script list, it can be queried whether there is a strong association in each transaction. If there is, it is determined that these transactions are transactions that can be optimized.
[0079] Reference Figure 5 In an embodiment, the transaction processing method based on database connection further comprises:
[0080] S60, according to the execution process of the transaction monitored, control the connection state of the transaction and the database.
[0081] Exemplarily, according to the execution process of the transaction monitored, controlling the connection state of the transaction and the database comprises: if the transaction is in the execution process, maintaining the connection between the transaction and the database; if the execution process of the transaction is ended, disconnecting the connection between the transaction and the database.
[0082] In an embodiment, the transaction processing method based on database connection can further comprise: sending a reminder information to remind the optimization of the transaction record that can be optimized.
[0083] The reminder information can be sent to the terminal of the staff, such as personal computer or mobile phone, etc., to remind the staff to optimize the above-mentioned transaction record that can be optimized. The reminder information may, for example, be a reminder message sent to the staff's mobile phone.
[0084] In a specific example, the transaction processing method based on database connection, the overall flow steps can include:
[0085] The transaction monitoring plug-in is called to intercept database requests, and when an open transaction is found in the current database connection, script recording is performed. A unique identifier of the current script transaction is generated or obtained from the current connection. If the unique identifier is not obtained, it is recorded in the properties attribute of the current database connection. The unique transaction identifier, statement type, involved table name, current time, and specific executed script are written into the transaction record data table. For details, refer to Figure 6 The flowchart of intercepting database requests and generating transaction script records is shown in Figure 6 In the flowchart, the transaction identifier is uuid1, and the name of the intercepting plug-in is transation_warming.jar. In the script storage data table, the transaction identifier, script, script type, involved table, and execution time of multiple transactions are included. The script includes query consumption notification, query order information, add consumption record, query user information, update user member card balance, query user credit level, query consumption record, and calculation. The script type includes select, insert, and update. The involved table includes t_xiaofei, t_order, t_trade, t_user, t_user_card, t_user_record, and t_bill. The execution time represents the time point of executing the script in the database.
[0086] The transaction monitoring plug-in can provide an interface for querying a database transaction script list. Through the interface for querying the database transaction script list, it can be determined whether there is a select query script without strong association in each transaction. If there is, it is determined that these transactions are transactions that can be optimized. For details, refer to Figure 7 In the right table in the flowchart, the scripts marked by the selected boxes are pointed to by arrows. The scripts in the square boxes are select query scripts without strong association, and the scripts in the oval boxes are query scripts, but there is strong association with another script, and therefore, they are not found. In Figure 7 In the flowchart, the transaction identifier is uuid1, and the script type-involved table selected by the square box includes select-t_xiaofei, select-t_order, and select-t_user_record. The script type-involved table selected by the oval box includes insert-t_trade and select-t_trade.
[0087] The tool class of JDBC is used to determine whether there is a JDBC transaction in the connection.
[0088] For example: DataSourceUtils.isConnectionTransactional(connection, mappedStatement.getConfiguration().getEnvironment().getDataSource()).
[0089] In JDBC, transaction processing is done through Connection, a Connection object represents the connection established through JDBC driver and data source. Application using JDBC API may need to maintain multiple Connection objects, a Connection object may access multiple data sources, or may access a single data source.
[0090] The way to get Connection object includes: through DriverManger class provided in JDBC API, or through the implementation class of DataSource interface.
[0091] Three methods of Connection are related to transaction:
[0092] setAutoCommit(boolean): set whether it is an automatic commit transaction, if true (the default value is true) indicates automatic commit, that is, each executed SQL statement is a separate transaction, if set false, it is equivalent to starting a transaction; con.setAutoCommit(false) indicates starting a transaction.
[0093] commit(): commit the end transaction; con.commit() indicates committing the transaction.
[0094] rollback(): rollback the end transaction. con.rollback() indicates rolling back the transaction.
[0095] Judge whether there is a strong association: not exists (select 1 from table where "involved table" = #{tableName} and "script type"!='select')
[0096] Through the method of the embodiment of the application, the system can expose the possible problems that affect the efficiency before going online, improve the system efficiency, flexibly detect the transaction with problems, timely inform the developer to view the scripts of these transactions, confirm the problems and correct them in time, save the cost of manpower reading code, improve the maintainability of the code for the developer, and at least save more than 30% of the manpower cost.
[0097] The transaction processing method based on database connection provided by the embodiment of the application can intercept a database connection request, detect whether the intercepted database connection request is from an open transaction, establish a connection between the transaction and a database according to the database connection request if the database connection request is from the open transaction, listen to the transaction and establish a script record of the transaction, determine an optimizable transaction record according to the script record, thereby realizing efficient listening to a transaction execution process, automatically discovering and determining an optimizable transaction record, realizing timely discovery and determination of the optimizable transaction record, facilitating a staff to optimize the optimizable transaction record in time, reducing an error rate of the transaction execution process, improving transaction execution efficiency, and reducing manual workload and manual cost.
[0098] Reference Figure 8 Another embodiment of the application provides a transaction processing apparatus based on database connection, as shown in the accompanying drawings, the transaction processing apparatus based on database connection comprises:
[0099] An intercepting module is configured to intercept a database connection request.
[0100] A detecting module is configured to detect whether the intercepted database connection request is from an open transaction.
[0101] A connection establishing module is configured to establish a connection between the transaction and a database according to the database connection request if the database connection request is from the open transaction.
[0102] A listening module is configured to listen to the transaction and establish a script record of the transaction.
[0103] A determining module is configured to determine an optimizable transaction record according to the script record.
[0104] Reference Figure 9 In an embodiment, the transaction processing apparatus based on database connection can further comprise:
[0105] A control module is configured to control a connection state between the transaction and the database according to an execution process of the listened-to transaction.
[0106] In an embodiment, the control module is further specifically configured to maintain the connection between the transaction and the database if the listened-to transaction is in the execution process, and disconnect the connection between the transaction and the database if the execution process of the listened-to transaction is ended.
[0107] In an embodiment, the connection establishing module establishes the connection between the transaction and the database according to the database connection request, including: releasing the database connection request, so that the database connection request is sent to the database; recording information of the transaction to be started and obtaining the information of the transaction from the connection request; recording the information of the transaction in a properties attribute of the database, and writing the information of the transaction into a data table used for transaction record in the database.
[0108] Exemplarily, the information of the transaction includes a unique identifier, a statement type, a table name involved, a current time and a specific executed script.
[0109] In an embodiment, the determining module determines the recordable transaction according to the script record, including: querying whether there is a strongly associated script in the transaction according to the script record, and determining the strongly associated script as the recordable transaction if there is.
[0110] In an embodiment, the transaction processing apparatus based on database connection further includes:
[0111] The sending module is configured to send the reminding information to remind the optimization of the recordable transaction.
[0112] The transaction processing apparatus based on database connection provided by the embodiments of the present application can intercept the database connection request, detect whether the intercepted database connection request is from a started transaction, establish the connection between the transaction and the database according to the database connection request if the intercepted database connection request is from a started transaction, listen to the transaction and establish a script record of the transaction, and determine the recordable transaction according to the script record, so that the execution process of the transaction can be efficiently listened to, the recordable transaction can be automatically found and determined, the recordable transaction can be found and determined in time, the staff can optimize the recordable transaction in time, the error rate of the execution process of the transaction is reduced, the execution efficiency of the transaction is improved, the artificial workload is reduced, and the artificial cost is reduced.
[0113] Another embodiment of the present application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executes the program to implement the transaction processing method based on database connection of any of the above embodiments.
[0114] Reference Figure 10 As shown in the figure, the electronic device 10 can include a processor 100, a memory 101, a bus 102 and a communication interface 103, the processor 100, the communication interface 103 and the memory 101 are connected through the bus 102; the memory 101 stores a computer program executable on the processor 100, and the processor 100 executes the computer program to implement the method provided by any of the above embodiments.
[0115] The memory 101 can include a high-speed random access memory (RAM), and can also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which can be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. can be used.
[0116] The bus 102 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 101 is used to store programs, and the processor 100 executes the programs after receiving execution instructions. The method disclosed in any of the embodiments of the present application can be applied to the processor 100 or implemented by the processor 100.
[0117] The processor 100 can be an integrated circuit chip with signal processing capability. In the implementation process, each step of the above method can be completed by integrated logic circuits or instructions in the form of software in the processor 100. The processor 100 described above can be a general-purpose processor, which can include a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a ready-to-program gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. Each method, step and logic block disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware coding processor for execution, or a combination of hardware and software modules in the coding processor for execution. The software module can be located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, or other mature storage media in the art. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and combines the hardware to complete the steps of the above method.
[0118] The electronic device provided by the embodiments of the present application and the method provided by the embodiments of the present application have the same beneficial effects as the method they adopt, run or implement.
[0119] Another embodiment of the present application provides a computer readable storage medium, having stored thereon a computer program, which is executed by a processor to implement the database connection based transaction processing method of any of the above embodiments.
[0120] Reference Figure 11 As shown in FIG. 20, the computer readable storage medium is an optical disc 20, having stored thereon a computer program (i.e. program product), which, when executed by a processor, performs the method provided by any of the above embodiments.
[0121] It should be noted that examples of the computer readable storage medium can also include, but are not limited to, a phase change memory (PRAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), other types of random access memory (RAM), a read only memory (ROM), an electrically erasable programmable read only memory (EEPROM), a flash memory, or other optical, magnetic storage medium, which are not listed here.
[0122] The computer readable storage medium provided by the above embodiments of the present application has the same beneficial effects as the method adopted, run or implemented by the application program stored therein, based on the same inventive concept.
[0123] It should be noted that:
[0124] The term "module" is not intended to be limited to a particular physical form. Depending on the specific application, a module can be implemented as hardware, firmware, software and / or a combination thereof. In addition, different modules can share common components or even be implemented by the same components. There can or can not be a clear boundary between different modules.
[0125] The algorithms and displays presented herein are not inherently related to any particular computer, virtual apparatus, or other device. Various general purpose devices can be used with these examples based on the description herein. The construction required to construct such a device as described above is apparent to those skilled in the art from the description above. In addition, the present application is not directed to any particular programming language. It will be appreciated that a variety of programming languages can be used to implement the present application described herein, and that the descriptions above are provided for the best mode of the present application.
[0126] It should be understood that although the steps in the flowcharts of the drawings are shown in a sequential order following the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated otherwise herein, the execution of the steps is not necessarily limited to the order indicated by the arrows. Moreover, at least some of the steps in the flowcharts of the drawings can comprise a plurality of sub-steps or stages, which are not necessarily executed at the same time, but can be executed at different times, and which are not necessarily executed sequentially, but can be executed in rotation or alternation with at least some of the other steps or sub-steps or stages of other steps.
[0127] The above embodiments only express the implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the patent scope of the present application. It should be pointed out that for those skilled in the art, a number of modifications and improvements can be made without departing from the concept of the present application, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A transaction processing method based on database connections, characterized in that, include: Intercept database connection requests; Detect whether the intercepted database connection requests originate from an open transaction; If so, then establish a connection between the transaction and the database according to the database connection request; Monitor the transaction and create a script record for the transaction; Based on the script records, identify transaction records that can be optimized; The step of establishing a connection between the transaction and the database based on the database connection request includes: Release the database connection request so that the database connection request is sent to the database; Record the transaction information and obtain the transaction information from the connection request; The transaction information is recorded in the properties attribute of the database and written into the data table used for transaction recording in the database.
2. The method according to claim 1, characterized in that, The method further includes: Based on the monitored execution progress of the transaction, control the connection status between the transaction and the database.
3. The method according to claim 2, characterized in that, The step of controlling the connection status between the transaction and the database based on the monitored execution process of the transaction includes: If the transaction is detected to be in execution, then maintain the connection between the transaction and the database; If the execution process of the transaction is detected to have ended, the connection between the transaction and the database is disconnected.
4. The method according to claim 1, characterized in that, The transaction information includes a unique identifier, statement type, table name involved, current time, and the specific script being executed.
5. The method according to claim 1, characterized in that, The step of determining optimizable transaction records based on the script records includes: The system queries the script records to determine if there are strongly related scripts in the transaction. If so, the strongly related scripts are identified as transaction records that can be optimized.
6. The method according to claim 1, characterized in that, The method further includes: Send a reminder message to prompt you to optimize the optimizable transaction records.
7. A transaction processing apparatus based on database connection, characterized in that, include: The interception module is used to intercept database connection requests; The detection module is used to detect whether the intercepted database connection requests come from an open transaction; A connection establishment module is used to establish a connection between the transaction and the database based on the database connection request if the request is true. The monitoring module is used to monitor the transaction and establish a script record for the transaction; The determination module is used to determine optimizable transaction records based on the script records; The connection establishment module is further used for: Release the database connection request so that the database connection request is sent to the database; Record the transaction information and obtain the transaction information from the connection request; The transaction information is recorded in the properties attribute of the database and written into the data table used for transaction recording in the database.
8. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the program to implement the database connection-based transaction processing method as described in any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, The program is executed by the processor to implement the database connection-based transaction processing method as described in any one of claims 1-6.
Citation Information
Patent Citations
Systems and methods for appflow for datastream
CN104904160A
Database monitoring method and device
CN107632919A