Transaction processing method and apparatus, electronic device, storage medium, and program product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 湖南亚信安慧科技有限公司
- Filing Date
- 2023-03-10
- Publication Date
- 2026-08-07
AI Technical Summary
[0004]本申请实施例旨在解决数据库事务长时间占用资源不自动提交的问题
[0027] The transaction processing method provided in this application determines the database isolation level and the database transaction initiation method. When the database isolation level and the database transaction initiation method meet a first preset condition, the operation type of at least one executed data manipulation language is determined. Based on the determined operation type and the executed data manipulation language, a target database transaction to be committed is generated and then committed. In this transaction processing method, when the preset condition is met, the type of the executed data manipulation language is judged, and a method for committing the executed data manipulation language is selected according to different types. This ensures that database transactions meeting the preset condition can be committed and resources released in a timely manner, avoiding prolonged occupation and waste of database resources.
Smart Images

Figure CN116225630B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of database technology, and more specifically, to a transaction processing method, apparatus, electronic device, storage medium, and computer program product. Background Technology
[0002] With the development of database technology, the commit method of database transactions and the data synchronization between replicas are becoming increasingly important for database efficiency. A database transaction is a mechanism, a sequence of operations containing a set of commands to manipulate the database. Some database operations can be automatically committed, meaning each statement is executed as a transaction without manual commit by the user. The statements are independent of each other, allowing for timely saving of user data operations.
[0003] The current solution to the problem of database transactions not committing for a long time is to abort the transaction after the idle transaction times out. However, the timeout period of a transaction is not easy to assess. If a transaction occupies resources on a replica for a long time without releasing them, it will affect the use and stability of the database system and lead to the waste of database resources. Summary of the Invention
[0004] This application aims to solve the problem of database transactions occupying resources for extended periods without automatic commit. The technical solution is as follows:
[0005] Firstly, this application provides a transaction processing method, including:
[0006] Determine the database isolation level and the database transaction initiation method;
[0007] If the database isolation level and the database transaction initiation method meet the first preset conditions, then determine the operation type of at least one data manipulation language that has been executed;
[0008] Based on the determined operation type and the executed data manipulation language, a target database transaction to be committed is generated and then the target database transaction is committed.
[0009] In an optional embodiment of the first aspect, the first preset condition includes:
[0010] The database isolation level is Read Committed, and the database transaction initiation method is Implicit Initiation and Non-Auto Commit.
[0011] In an alternative embodiment of the first aspect, generating the target database transaction to be committed based on the determined operation type and the executed data manipulation language includes:
[0012] If the operation type of at least one executed data manipulation language is a read-only query operation type, the executed data manipulation language is used as the target database transaction to be committed.
[0013] In an alternative embodiment of the first aspect, generating the target database transaction to be committed based on the determined operation type and the executed data manipulation language includes:
[0014] If at least one data manipulation language already executed includes a write operation type, then the execution of the data manipulation language to be executed continues until the second preset condition is met.
[0015] In an optional embodiment of the first aspect, the second preset condition includes:
[0016] The data manipulation language is not currently being executed, and the time interval between the current time and the last execution time of the data manipulation language is greater than or equal to the preset duration;
[0017] The method further includes:
[0018] Close the session channel, roll back the database transaction, and release the database resources; where rollback means restoring to the state before the transaction was executed.
[0019] Secondly, a transaction processing apparatus is provided, the apparatus comprising:
[0020] The first determination module is used to determine the database isolation level and the database transaction initiation method;
[0021] The second determining module is used to determine the operation type of at least one data manipulation language that has been executed if the database isolation level and the database transaction initiation method meet the first preset conditions.
[0022] The submission module is used to generate a target database transaction to be submitted based on the determined operation type and the executed data manipulation language, and to submit the target database transaction.
[0023] Thirdly, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory, characterized in that the processor executes the computer program to implement the steps of the method described in any of the first aspects of this application.
[0024] In a sixth aspect, a computer-readable storage medium is provided having a computer program stored thereon, characterized in that the computer program, when executed by a processor, implements the transaction processing method shown in any of the first aspects of this application.
[0025] In a seventh aspect, a computer program product is provided, comprising a computer program, characterized in that, when the computer program is executed by a processor, it implements the transaction processing method shown in any one of the first aspects of this application.
[0026] The beneficial effects of the technical solutions provided in this application are:
[0027] The transaction processing method provided in this application determines the database isolation level and the database transaction initiation method. When the database isolation level and the database transaction initiation method meet a first preset condition, the operation type of at least one executed data manipulation language is determined. Based on the determined operation type and the executed data manipulation language, a target database transaction to be committed is generated and then committed. In this transaction processing method, when the preset condition is met, the type of the executed data manipulation language is judged, and a method for committing the executed data manipulation language is selected according to different types. This ensures that database transactions meeting the preset condition can be committed and resources released in a timely manner, avoiding prolonged occupation and waste of database resources. Attached Figure Description
[0028] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below.
[0029] Figure 1 This is a schematic diagram illustrating an application scenario of a transaction processing method provided in an embodiment of this application;
[0030] Figure 2 A flowchart illustrating a transaction processing method provided in an embodiment of this application;
[0031] Figure 3 A flowchart illustrating an example of a transaction processing method provided in an embodiment of this application;
[0032] Figure 4 This is a schematic diagram of the structure of a transaction processing device provided in an embodiment of this application;
[0033] Figure 5 This is a schematic diagram of the structure of an electronic device to which a transaction processing method is applicable, as provided in an embodiment of this application. Detailed Implementation
[0034] The embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the embodiments described below with reference to the accompanying drawings are exemplary descriptions for explaining the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions of the embodiments of this application.
[0035] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the terms “comprising” and “including” as used in embodiments of this application mean that the corresponding feature can be implemented as the presented feature, information, data, step, operation, and component, but do not exclude implementation as other features, information, data, steps, operations, components, and / or combinations thereof supported by the art. It should be understood that when we say that an element is “connected” or “coupled” to another element, the element can be directly connected or coupled to the other element, or it can mean that the element and the other element are connected through an intermediate element. Furthermore, “connected” or “coupled” as used herein can include wireless connection or wireless coupling. The term “and / or” as used herein indicates at least one of the items defined by the term; for example, “A and / or B” can be implemented as “A,” or as “B,” or as “A and B.”
[0036] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0037] First, let's introduce and explain several terms used in this application:
[0038] Data Manipulation Language (DML): Performs simple operations on data in a database, such as insert, delete, update, and select.
[0039] There are four isolation levels for database transactions, from lowest to highest: Read uncommitted, Read committed, Repeatable read, and Serializable.
[0040] Read Committed: A transaction can only see changes made by committed transactions. Query results are not repeatable, allowing the same select query to return different results.
[0041] The data manipulation language for read-only query operations includes the SELECT statement (without FOR UPDATE).
[0042] The data manipulation languages for write operations include: INSERT, UPDATE, DELETE, and SELECTFOR UPDATE.
[0043] In existing technologies, there are roughly two solutions to the problem of database transactions not being committed for a long time. However, there are problems such as the difficulty in evaluating the timeout configuration value and the waste of database resources due to prolonged occupation.
[0044] To address at least one technical problem or area requiring improvement in related technologies, this application proposes a transaction processing method, apparatus, electronic device, storage medium, and computer program product. The transaction processing method provided by this application determines the database isolation level and the database transaction initiation method. When the database isolation level and the database transaction initiation method meet a first preset condition, it determines the operation type of at least one executed data manipulation language. Based on the determined operation type and the executed data manipulation language, it generates a target database transaction to be committed and commits the target database transaction. In the transaction processing method provided by this application, when the preset condition is met, the type of the executed data manipulation language is judged, and a method for committing the executed data manipulation language is selected according to different types. This ensures that database transactions meeting the preset condition can be committed promptly and resources are released, avoiding prolonged occupation and waste of database resources.
[0045] The technical solutions of this application and their effects are described below through several exemplary embodiments. It should be noted that the following embodiments can be referenced, borrowed from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.
[0046] Figure 1 This is a schematic diagram of an application scenario for the transaction processing method provided in this application embodiment. The application environment may include a terminal 101 with an application for processing database transactions installed.
[0047] Specifically, when performing database operations in terminal 101, the above-mentioned transaction processing method can be used for the execution and commit of database transactions. That is, first determine the database isolation level and the database transaction start method. If the first preset condition is met, determine the data manipulation language operation that has been executed. If the operation type meets the second preset condition, that is, the time interval between the current idle time and the last data manipulation language execution time is greater than the preset time, close the session channel, roll back this database transaction, and release the database resources.
[0048] In the above application scenario, in the application that operates on the database in terminal 101, the above transaction processing method is used to select the submission method according to the type of the executed database data manipulation language that meets the preset conditions; in other embodiments, database operations can also be performed on the server. The above application scenario is just an example and does not limit the application scenario of the transaction processing method of this application.
[0049] Those skilled in the art will understand that the terminal (also referred to as a user terminal or user device) can be a smartphone, tablet computer, laptop computer, desktop computer, intelligent voice interaction device (e.g., smart speaker), wearable electronic device (e.g., smartwatch), in-vehicle terminal, smart home appliance (e.g., smart TV), AR / VR device, aircraft, etc., but is not limited thereto. Embodiments of this invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving.
[0050] The server may include servers installed with the ability to handle database operations. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server or server cluster providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal may be a smartphone (such as an Android phone, iOS phone, etc.), tablet computer, laptop computer, digital broadcast receiver, MID (Mobile Internet Device), PDA (Personal Digital Assistant), desktop computer, smart home appliance, in-vehicle terminal (such as in-vehicle navigation terminal, in-vehicle computer, etc.), smart speaker, smartwatch, etc. The terminal and server can be directly or indirectly connected via wired or wireless communication, but are not limited thereto. This invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, and assisted driving. Specific applications can be determined based on actual application needs and are not limited here.
[0051] In some possible implementations, taking a database operation program in a terminal as the executing entity as an example, this application provides a transaction processing method, such as... Figure 2 As shown, it may include the following steps:
[0052] S201, determine the database isolation level and the database transaction initiation method.
[0053] The database isolation levels can include: Read Uncommitted, Read Committed, Repeatable Read, and Serialization. In this embodiment, the database isolation level includes Read Committed, which means that a transaction can only see the changes made by a committed transaction.
[0054] Specifically, the triggering conditions for determining the database isolation level and the database transaction initiation method can be: determining the above two conditions at a preset interval, or determining the above two conditions when a transaction commit operation is detected.
[0055] S202, if the database isolation level and the database transaction initiation method meet the first preset conditions, then determine the operation type of at least one data manipulation language that has been executed.
[0056] The first preset condition includes a database isolation level of read committed and a database transaction initiation mode of implicit initiation and non-auto-commit. Data Manipulation Language (DML) operation types include read-only query operations and write operations.
[0057] Specifically, when both the database isolation level is read committed and the database transaction start mode is implicit and non-autocommitted, the operation type of at least one data manipulation language that has been executed is determined.
[0058] In the specific implementation process, the number of executed data manipulation languages can be one or more. "Executed" means that the data manipulation languages have been executed but not committed when determining the operation type. For example, after determining the database isolation level and database transaction start mode, if the three data manipulation languages A, B, and C have been executed when determining the operation type, then the operation type of the three data manipulation languages A, B, and C is determined.
[0059] S203, based on the determined operation type and the executed data manipulation language, generate a target database transaction to be committed, and commit the target database transaction.
[0060] The target database transaction may include at least one data manipulation language; the submission process is based on database transactions, and a database transaction may include one or more data manipulation languages.
[0061] In practice, when all operation types are read-only query operations, the executed data manipulation languages are used to generate a target database transaction and commit it. If a write operation type is present in the operation type, the executed data manipulation languages are not committed. For example, if there are three executed data manipulation languages, A, B, and C, where B is a write operation type and A and B are both read-only query operations, then the three data manipulation languages A, B, and C cannot be used to generate a target database transaction and commit it.
[0062] In some possible implementations, the first preset condition in S202 above includes:
[0063] (1) The database isolation level is read committed, and the database transaction start mode is implicit start and non-auto commit.
[0064] Specifically, when the database transaction is started in a non-auto-commit mode, the transaction is started implicitly and requires the use of the database transaction processing methods described above. When the database transaction is started in an auto-commit mode, i.e., explicitly started, the database transaction processing methods described above are not used. For example, if a user explicitly starts a transaction using the BEGIN or START TRANSACION statement, the database transaction processing methods described above will not be used even if the read committed and non-auto-commit conditions are met.
[0065] Specifically, there are no requirements on the order in which the database isolation level and the database transaction initiation method are determined, but both preset conditions must be met simultaneously.
[0066] In the specific implementation process, when performing subsequent transaction commit operations under the condition that the first preset condition is met, if it is detected that at least one of the database isolation level and database transaction initiation mode has changed, the subsequent data manipulation language judgment and commit will not be performed.
[0067] In some possible implementations, step S203 above, which generates a target database transaction to be committed based on the determined operation type and the executed data manipulation language, includes:
[0068] (1) If the operation type of the at least one data manipulation language that has been executed is a read-only query operation type, the executed data manipulation language shall be used as the target database transaction to be submitted.
[0069] When all the data manipulation languages executed are read-only query operations, the target database transaction may include one or more data manipulation languages.
[0070] In the specific implementation process, if the first preset condition is met, during the first operation type determination, there may be multiple executed read-only query operation types of data manipulation languages. In this case, the multiple executed data manipulation languages will be generated into a target database transaction and committed. If a data manipulation language is executed after the first commit, and the operation type of this data manipulation language is a read-only query operation, then this data manipulation language can be generated into a target database transaction and committed. That is, a data manipulation language is a database transaction.
[0071] In some possible implementations, step S203 above, which generates a target database transaction to be committed based on the determined operation type and the executed data manipulation language, includes:
[0072] (1) If the at least one data manipulation language already executed includes a write operation type, then continue to execute the data manipulation language to be executed until the second preset condition is met.
[0073] Specifically, when there are multiple data manipulation languages that have been executed, the above method will be executed as long as one of them is a write operation type.
[0074] For example, if the first data manipulation language executed since the last transaction commit is a write operation, then the second and subsequent data manipulation languages executed will not be committed unless the second preset condition is met; or, if the first preset condition has not been met since the last transaction commit, and there are two data manipulation languages, A and B, that have been executed but not committed, then when determining the operation type, if A is a read-only query operation and B is a write operation, then the executed data manipulation languages and subsequent data manipulation languages will not be processed until the second preset condition is met.
[0075] In some possible implementations, the second preset condition may include:
[0076] The data manipulation language is not currently being executed, and the time interval between the current time and the last execution time of the data manipulation language is greater than or equal to the preset duration;
[0077] The above transaction processing methods also include:
[0078] (1) Close the session channel, roll back this database transaction, and release database resources;
[0079] Here, rollback refers to restoring to the state before the transaction was executed.
[0080] Specifically, the time of the last execution of the Data Manipulation Language (DML) is recorded, and the interval is determined based on the current system time and the execution time of the last DML. A pre-set database transaction timeout duration is established, i.e., the aforementioned preset duration. When the interval is greater than or equal to the preset duration, the user's session channel is closed, the current transaction is aborted, and database resources are released.
[0081] In practice, if the above interval is longer than the preset duration, the user's session channel will be closed, the transaction will be rolled back to the state before the transaction was executed, and the database resources will be released. When the user sends a database request after the session channel is closed, he will find that the session channel has been closed due to the database transaction timeout.
[0082] In the specific implementation process, the above-mentioned second preset condition may also include receiving a user's submission instruction; wherein, the user's submission instruction may be that the user executes a database transaction submission statement to submit the transaction, or the user submits the transaction by clicking the "Submit" button.
[0083] In the specific implementation process, when the user's commit instruction is received, the executed data manipulation language is used as the target database transaction according to the user's commit instruction. The transaction can be considered to have started after the last transaction was completed and ended when the user's commit instruction is received. The data manipulation language executed during this period can be considered to be in a transaction and can be committed together as a transaction.
[0084] In the above embodiments, by determining the database isolation level and the database transaction initiation method, when the database isolation level and the database transaction initiation method meet the first preset condition, the operation type of at least one executed data manipulation language is determined; based on the determined operation type and the executed data manipulation language, a target database transaction to be committed is generated and committed. In the transaction processing method provided by this application, when the preset condition is met, the type of the executed data manipulation language is judged, and a method for committing the executed data manipulation language is selected according to different types, so that database transactions that meet the preset condition can be committed and resources released in a timely manner, avoiding long-term occupation leading to database resource waste.
[0085] To better understand the transaction processing method described in the embodiments of this application, the following will provide a more detailed explanation with reference to examples.
[0086] In one example, the transaction processing method of this application, such as Figure 3 As shown, it may include:
[0087] Determine the current database isolation level and database transaction initiation mode. When both conditions are met—database isolation level is Read Committed and database transaction initiation mode is Implicit and Non-Auto Commit—the operation type of the Data Manipulation Language (DML) operations executed since the last commit is determined. If the operation type of the DML is all read-only query operations, the executed DML operations are treated as a database transaction and committed.
[0088] If any of the executed data manipulation languages contains a write operation, the currently executed data manipulation language will not be committed. A preset timeout period will be used to determine whether the interval between the current time and the last execution time of the data manipulation language exceeds the preset timeout period. If the time interval is greater than or equal to the preset timeout period, the user's session channel will be closed, the transaction will be rolled back, and the database resources will be released.
[0089] The aforementioned transaction processing method determines the database isolation level and the database transaction initiation method. When the database isolation level and the database transaction initiation method meet a first preset condition, it determines the operation type of at least one executed data manipulation language. Based on the determined operation type and the executed data manipulation language, it generates a target database transaction to be committed and commits the target database transaction. In the transaction processing method provided in this application, when the preset condition is met, the type of the executed data manipulation language is judged, and a method for committing the executed data manipulation language is selected according to different types. This ensures that database transactions meeting the preset condition can be committed and resources released in a timely manner, avoiding prolonged occupation and waste of database resources.
[0090] This application provides a transaction processing apparatus, such as... Figure 4 As shown, the device 40 may include: a first determining module 401, a second determining module 402, and a submitting module 403, wherein,
[0091] The first determination module 401 is used to determine the database isolation level and the database transaction initiation method;
[0092] The second determining module 402 is used to determine the operation type of at least one data manipulation language that has been executed if the database isolation level and the database transaction initiation method meet the first preset conditions.
[0093] The submission module 403 is used to generate a target database transaction to be submitted based on the determined operation type and the executed data manipulation language, and to submit the target database transaction.
[0094] The transaction processing apparatus and method provided in this application determine the database isolation level and the database transaction initiation method. When the database isolation level and the database transaction initiation method meet a first preset condition, the operation type of at least one executed data manipulation language is determined. Based on the determined operation type and the executed data manipulation language, a target database transaction to be committed is generated and committed. In the transaction processing method provided in this application, when the preset condition is met, the type of the executed data manipulation language is judged, and a method for committing the executed data manipulation language is selected according to different types. This ensures that database transactions meeting the preset condition can be committed and resources released in a timely manner, avoiding prolonged occupation and waste of database resources.
[0095] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps of a transaction processing method. Compared with related technologies, it can achieve the following: when there is no automatic commit and the database isolation level is read committed, it can quickly determine the commit method according to the data manipulation language type and commit the transaction in the data manipulation language, which can quickly release resources and avoid the waste caused by long-term occupation of database resources.
[0096] In one alternative embodiment, an electronic device is provided, such as Figure 5 As shown, Figure 5 The illustrated electronic device 5000 includes a processor 5001 and a memory 5003. The processor 5001 and the memory 5003 are connected, for example, via a bus 5002. Optionally, the electronic device 5000 may further include a transceiver 5004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 5004 is not limited to one type, and the structure of the electronic device 5000 does not constitute a limitation on the embodiments of this application.
[0097] Processor 5001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 5001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
[0098] Bus 5002 may include a path for transmitting information between the aforementioned components. Bus 5002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 5002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0099] The memory 5003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.
[0100] The memory 5003 is used to store computer programs that execute the embodiments of this application, and its execution is controlled by the processor 5001. The processor 5001 is used to execute the computer programs stored in the memory 5003 to implement the steps shown in the foregoing method embodiments.
[0101] Among them, electronic devices include, but are not limited to, terminals with database services.
[0102] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it can implement the steps and corresponding content of the aforementioned method embodiments.
[0103] This application also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.
[0104] The terms "first," "second," "third," "fourth," "1," "2," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in a sequence other than that shown in the figures or text.
[0105] It should be understood that although arrows indicate various operation steps in the flowcharts of this application's embodiments, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of this application's embodiments, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all steps in each flowchart, based on the actual implementation scenario, may include multiple sub-steps or multiple stages. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured according to requirements, and this application's embodiments do not limit this.
[0106] The above description is only an optional implementation method for some implementation scenarios of this application. It should be noted that for those skilled in the art, other similar implementation methods based on the technical concept of this application without departing from the technical concept of this application also fall within the protection scope of the embodiments of this application.
Claims
1. A transaction processing method, characterized in that, include: Determine the database isolation level and the database transaction initiation method; If the database isolation level and the database transaction initiation method meet the first preset conditions, then determine the operation type of at least one data manipulation language that has been executed but not yet committed; The first preset condition includes that the database isolation level is read committed and the database transaction start mode is implicit start and non-automatic commit; If the operation type of at least one executed but not yet committed data manipulation language is a read-only query operation type, the executed but not yet committed data manipulation language is taken as the target database transaction to be committed, and the target database transaction is committed. If at least one data manipulation language that has been executed but not yet committed includes a write operation type, then the pending data manipulation language continues to be executed until the second preset condition is met; the session channel is closed, the database transaction is rolled back, and the database resources are released; wherein, the second preset condition includes that no data manipulation language is currently being executed, and the interval between the current time and the execution time of the last data manipulation language is greater than or equal to a preset duration. Rollback refers to restoring the state to which the transaction was performed.
2. A transaction processing apparatus, characterized in that, include: The first determination module is used to determine the database isolation level and the database transaction initiation method; The second determining module is used to determine the operation type of at least one data manipulation language that has been executed but not yet committed if the database isolation level and the database transaction initiation method meet the first preset conditions. The first preset condition includes that the database isolation level is read committed and the database transaction start mode is implicit start and non-automatic commit; The submission module is configured to, if the operation types of at least one executed but not yet submitted data manipulation language are all read-only query operation types, treat the executed but not yet submitted data manipulation language as the target database transaction to be submitted, and submit the target database transaction. If at least one data manipulation language that has been executed but not yet committed includes a write operation type, then the pending data manipulation language continues to be executed until the second preset condition is met; the session channel is closed, the database transaction is rolled back, and the database resources are released; wherein, the second preset condition includes that no data manipulation language is currently being executed, and the interval between the current time and the execution time of the last data manipulation language is greater than or equal to a preset duration. Rollback refers to restoring the state to which the transaction was performed.
3. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method of claim 1.
4. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the transaction processing method of claim 1.
5. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method of claim 1.
Citation Information
Patent Citations
Database-based data processing method and device, and readable storage medium
CN112084161A
Distributed transaction processing method and device, medium and database system
CN114003644A