Method, system and equipment for realizing autonomous transactions in database

By introducing dynamic application shared memory module (DSM) into the database, managing shared memory and processing autonomous transaction messages, the problems of unstable, inefficient and chaotic memory management in the database are solved, efficient, stable and flexible autonomous transaction management are achieved, and the system concurrency performance is improved.

CN119645687APending Publication Date: 2025-03-18BEIJING VASTDATA TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411908299.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

The existing database management system does not support autonomous transactions, resulting in limited flexibility and efficiency of transaction management. Especially in complex business logic and high concurrency environments, it is easy to cause transactions to lock resources for too long, the system concurrency performance is low, and the autonomous transaction implementation is unstable, which can easily cause program exceptions or database crashes.

Method used

By introducing the Dynamic Application Shared Memory Module (DSM), create shared memory in the database, assemble the function parameter package of the autonomous transaction function, and manage the shared memory of the main transaction thread and the autonomous transaction thread before starting the autonomous transaction thread. This method includes starting an autonomous transaction thread, obtaining function information in the function parameter package from shared memory, executing autonomous transaction functions, and processing autonomous transaction messages based on the execution results, and improving the error handling mechanism.

Benefits of technology

It realizes efficient, stable and flexible autonomous transaction management in the database, improves the concurrency performance of the system, and avoids the problems of autonomous transaction crashes, inefficiency and memory management chaos.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119645687A_ABST
    Figure CN119645687A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of database autonomous transactions, and provides a method, system and device for achieving autonomous transactions in a database, and the method comprises the steps that before an autonomous transaction thread is started, a shared memory is created by introducing a DSM module; a function parameter package of the autonomous transaction function is assembled, and the assembled function parameter package is placed in the created shared memory; starting an autonomous transaction thread, and obtaining function information in the function parameter packet from the shared memory; and executing the autonomous transaction function according to the obtained function information, and processing the autonomous transaction message according to an execution result. According to the method, the system and the equipment for realizing the autonomous transactions in the database, an error processing mechanism can be perfected by introducing a DSM shared memory management facility, and the problems that the autonomous transactions in the database are easy to crash, low in efficiency and disordered in memory management are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of database autonomous transactions, and in particular to a method, system and device for implementing autonomous transactions in a database. Background Art

[0002] In database management systems, transaction management and control are key to ensuring data consistency and integrity. The transaction processing mechanism allows users to perform a series of operations in the database, which are either all successful or all failed, thereby maintaining data integrity. The traditional transaction model requires that the commit or rollback of a transaction must take effect within the entire scope of the transaction, which means that all operations in a transaction are atomic, either all executed or none executed.

[0003] Oracle Database provides a special transaction type called "Autonomous Transactions", which is a feature natively supported by Oracle. In Oracle's PL / SQL (Procedural Language / SQL) procedural database programming language, developers can start a transaction isolated from the main transaction. This autonomous transaction can be committed (COMMIT) or rolled back (ROLLBACK) independently of the main transaction without affecting the execution and status of the main transaction. This mechanism provides greater flexibility for transaction management, allowing local control of transactions in functions or stored procedures, so that transactions in the current stored procedure can be committed independently without affecting external transactions. This is particularly important for complex business logic and data operations in high-concurrency environments, because it can reduce the time that transactions lock resources and improve the concurrency performance of the system.

[0004] However, not all database management systems support this autonomous transaction model. For example, MySQL, PostgreSQL (PG), and Microsoft SQL Server (SQLSERVER), which are widely used database systems, do not support autonomous transactions. This means that in these database systems, the commit or rollback of transactions must be performed uniformly within the scope of the entire transaction, limiting the flexibility and efficiency of transaction management. The OpenGauss database attempts to implement support for autonomous transactions, but due to problems with the implementation mechanism, this support is not perfect. Autonomous transactions in OpenGauss are prone to cause program exceptions and may even cause database crashes. This shows that although autonomous transactions provide significant advantages, their implementation requires precise and robust techniques to ensure the stability and reliability of the system.

[0005] Therefore, how to achieve efficient, stable and flexible autonomous transaction management and optimization in the database and provide more efficient and flexible transaction processing capabilities to meet increasingly complex business needs and system performance requirements has become a technical problem that needs to be solved urgently. Summary of the invention

[0006] In view of this, in order to overcome the deficiencies of the prior art, the present application aims to provide a method, system and device for implementing autonomous transactions in a database.

[0007] According to a first aspect of the present application, a method for implementing autonomous transactions in a database is provided, the method comprising: Before starting the autonomous transaction thread, create shared memory by introducing the DSM module; Assemble the function parameter package of the autonomous transaction function, and place the assembled function parameter package in the created shared memory; Start the autonomous transaction thread and obtain the function information in the function parameter package from the shared memory; The autonomous transaction function is executed according to the obtained function information, and the autonomous transaction message is processed according to the execution result.

[0008] Optionally, in the method of implementing autonomous transactions in a database of the present application, before starting the autonomous transaction thread, shared memory is created by introducing a DSM module, including: before starting the autonomous transaction thread, creating and managing shared memory of the main transaction thread and the autonomous transaction thread by dynamically applying for a shared memory module.

[0009] Optionally, in the method for implementing autonomous transactions in a database of the present application, assembling a function parameter package of an autonomous transaction function includes: assembling function information of the autonomous transaction function into a function parameter package of the autonomous transaction function.

[0010] Optionally, in the method of implementing autonomous transactions in a database of the present application, the function information of the autonomous transaction function includes the input parameter type, number and parameter value information of the autonomous transaction function.

[0011] Optionally, in the method for implementing autonomous transactions in a database, the present application starts an autonomous transaction thread and obtains information in a function parameter package from a shared memory, including: starting an autonomous transaction thread, obtaining a function parameter package in the shared memory of a main transaction thread and an autonomous transaction thread, and obtaining input parameter type, number, and parameter value information in the function parameter package through deserialization recovery.

[0012] Optionally, in the method of implementing autonomous transactions in a database, the present application executes the autonomous transaction function according to the acquired function information, and processes the autonomous transaction message according to the execution result, including: executing the autonomous transaction function according to the restored input parameter type, number and parameter value information, and when the execution is normal, placing the execution result in a shared message queue and sending it to the main transaction thread.

[0013] Optionally, in the method for implementing autonomous transactions in a database, the present application executes the autonomous transaction function according to the acquired function information, and processes the autonomous transaction message according to the execution result, including: when an execution exception occurs, writing an error message to a shared message queue, waking up the main transaction thread, and processing the error message in the shared message queue through the awakened main transaction thread.

[0014] Optionally, in the method for implementing autonomous transactions in a database, the present application executes the autonomous transaction function according to the acquired function information, and processes the autonomous transaction message according to the execution result, and also includes: setting an error level threshold for error messages in a shared message queue, when the error level of the error message in the shared message queue reaches the set error level threshold, triggering the main transaction thread exception, and releasing the corresponding resources through the main transaction thread.

[0015] According to a second aspect of the present application, a system for implementing autonomous transactions in a database is provided, the system comprising an autonomous server, the autonomous server comprising: A shared memory creation module is used to create a shared memory by introducing a DSM module before starting an autonomous transaction thread; A function parameter package creation module is used to assemble the function parameter package of the autonomous transaction function and place the assembled function parameter package in the created shared memory; The function information acquisition module is used to start the autonomous transaction thread and obtain the function information in the function parameter package from the shared memory; The autonomous transaction processing module is used to execute the autonomous transaction function according to the acquired function information and process the autonomous transaction message according to the execution result.

[0016] According to a third aspect of the present application, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect of the present application when executing the program.

[0017] The present invention provides a method and system for implementing autonomous transactions in a database, which solves the problems of easy crash, low efficiency and chaotic memory management of autonomous transactions in a database by introducing a DSM shared memory management facility and improving the error handling mechanism. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 This is an example diagram of the architecture of a system for implementing autonomous transactions in a database according to an embodiment of the present application; Figure 2 This is an example diagram of the architecture of an autonomous server of a system for implementing autonomous transactions in a database according to an embodiment of the present application; Figure 3 A flowchart of a method for implementing autonomous transactions in a database according to an embodiment of the present application; Figure 4 An example diagram of an execution of a method for implementing autonomous transactions in a database according to an embodiment of the present application; Figure 5 A schematic diagram of the structure of the device provided in this application. DETAILED DESCRIPTION

[0020] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0021] It should be noted that the following embodiments and features in the embodiments may be combined with each other in the absence of conflict; and, based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making any creative work are within the scope of protection of the present disclosure.

[0022] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.

[0023] Figure 1 FIG. 1 is an example diagram of the architecture of a system for implementing autonomous transactions in a database according to an embodiment of the present application. Figure 1 As shown, the system may include an autonomous server 101, a communication network 102 and / or one or more autonomous clients 103. Figure 1 The example shown is a plurality of autonomous clients 103.

[0024] The autonomous server 101 can be any appropriate server for storing information, data, programs and / or any other suitable type of content. In some embodiments, the autonomous server 101 can perform appropriate functions. For example, in some embodiments, the autonomous server 101 can be used to implement autonomous transactions in a database. As an optional example, in some embodiments, the autonomous server 101 can be used to: create a shared memory by introducing a DSM module before starting an autonomous transaction thread; assemble a function parameter package of an autonomous transaction function, and place the assembled function parameter package in the created shared memory; start an autonomous transaction thread, and obtain function information in the function parameter package from the shared memory; execute the autonomous transaction function according to the obtained function information, and process the autonomous transaction message according to the execution result.

[0025] Figure 2 FIG. 1 is an example diagram of an architecture of an autonomous server of a system for implementing autonomous transactions in a database according to an embodiment of the present application, such as Figure 2 As shown, in this embodiment, the autonomous server includes: A shared memory creation module is used to create a shared memory by introducing a DSM module before starting an autonomous transaction thread; A function parameter package creation module is used to assemble the function parameter package of the autonomous transaction function and place the assembled function parameter package in the created shared memory; The function information acquisition module is used to start the autonomous transaction thread and obtain the function information in the function parameter package from the shared memory; The autonomous transaction processing module is used to execute the autonomous transaction function according to the acquired function information and process the autonomous transaction message according to the execution result.

[0026] As another example, in some embodiments, the autonomous server 101 may send a method for implementing an autonomous transaction in a database to the autonomous client 103 for user use based on a request from the autonomous client 103 .

[0027] As an optional example, in some embodiments, the autonomous client 103 is used to provide a visual autonomous interface, which is used to receive a user's selection input operation to implement autonomous transactions in a database, and to, in response to the selection input operation, obtain from the autonomous server 101 an autonomous interface corresponding to the option selected by the selection input operation and display the autonomous interface, wherein the autonomous interface at least displays information on implementing autonomous transactions in the database and operation options for the information on implementing autonomous transactions in the database.

[0028] In some embodiments, the communication network 102 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 102 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The autonomous client 103 can be connected to the communication network 102 via one or more communication links (e.g., communication link 104), and the communication network 102 can be linked to the autonomous server 101 via one or more communication links (e.g., communication link 105). The communication link can be any communication link suitable for transmitting data between the autonomous client 103 and the autonomous server 101, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.

[0029] Autonomous client 103 may include any one or more clients that present an interface related to implementing autonomous transactions in a database in an appropriate form for use and operation by a user. In some embodiments, autonomous client 103 may include any suitable type of device. For example, in some embodiments, autonomous client 103 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, and / or any other suitable type of client device.

[0030] Although the autonomous server 101 is illustrated as one device, in some embodiments, any suitable number of devices may be used to perform the functions performed by the autonomous server 101. For example, in some embodiments, multiple devices may be used to implement the functions performed by the autonomous server 101. Alternatively, the functions of the autonomous server 101 may be implemented using a cloud service.

[0031] Based on the above system, an embodiment of the present application provides a method for implementing autonomous transactions in a database, which is described below through the following embodiments.

[0032] Figure 3 The following is a flowchart of a method for implementing autonomous transactions in a database according to an embodiment of the present application. Figure 4 FIG. 1 is an example diagram of an execution of a method for implementing an autonomous transaction in a database according to an embodiment of the present application. The method for implementing an autonomous transaction in a database in this embodiment can be executed on an autonomous server, such as Figure 3 and Figure 4 As shown, the method for implementing autonomous transactions in a database includes the following steps: Step S201: before starting the autonomous transaction thread, create a shared memory by introducing a DSM module.

[0033] This embodiment introduces a DSM module (dynamic shared memory module) before starting the autonomous transaction thread to create and manage the shared memory of the main transaction thread and the autonomous transaction thread. In the dynamic shared memory module, the object automatically manages its memory, and the last thread to exit releases the memory, avoiding the problem of database crash caused by the main transaction thread exiting first.

[0034] As an optional example, before starting the autonomous transaction thread, this embodiment creates and manages the shared memory of the main transaction thread and the autonomous transaction thread by dynamically applying for a shared memory module.

[0035] Step S202: Assemble the function parameter package of the autonomous transaction function, and place the assembled function parameter package in the created shared memory.

[0036] As an optional example, this embodiment assembles the function information of the autonomous transaction function into a function parameter package of the autonomous transaction function. The function information of the autonomous transaction function includes the input parameter type, number and parameter value information of the autonomous transaction function.

[0037] Step S203: Start the autonomous transaction thread and obtain the function information in the function parameter package from the shared memory.

[0038] As an optional example, in this embodiment, an autonomous transaction thread is started, a function parameter package is obtained in the shared memory of the main transaction thread and the autonomous transaction thread, and the input parameter type, number and parameter value information in the function parameter package are obtained through deserialization recovery.

[0039] Step S204: Execute the autonomous transaction function according to the acquired function information, and process the autonomous transaction message according to the execution result.

[0040] As an optional example, this embodiment executes the autonomous transaction function according to the restored input parameter type, number, and parameter value information. When the execution is normal, the execution result is placed in the shared message queue and sent to the main transaction thread. When the execution is abnormal, an error message is written to the shared message queue to wake up the main transaction thread, and the error message in the shared message queue is processed by the awakened main transaction thread. This embodiment avoids the deficiency of returning the abnormal execution result directly to the main transaction thread by improving the error handling mechanism of the autonomous transaction.

[0041] It should be noted that in this embodiment, an error level threshold is set for the error message in the shared message queue. When the error level of the error message in the shared message queue reaches the set error level threshold, the main transaction thread is triggered to be abnormal, and the corresponding resources are released by the main transaction thread. For example, when the error level of the error message in the shared message queue is ERROR, the main transaction thread is triggered to be abnormal, and the main transaction thread releases the related resources in the shared memory.

[0042] For example, in the existing autonomous transaction implementation mechanism in the OpenGauss database, the main thread needs to strictly wait for the autonomous transaction thread. Once the main thread exits prematurely, the database will crash. Moreover, the shared memory management of the main thread and the autonomous transaction thread is relatively chaotic, resulting in memory waste and the problem of returning incorrect results. According to the method and system for implementing autonomous transactions in a database in this embodiment, by introducing the DSM shared memory management facility and improving the error handling mechanism, the problems of easy crash, low efficiency and chaotic memory management of autonomous transactions in the OpenGauss database are solved. It should be noted that the method and system for implementing autonomous transactions in a database in this embodiment are also applicable to other types of databases, such as other types of relational databases, or other databases that store data, such as numerical databases, character databases, Boolean databases, etc.

[0043] like Figure 5 As shown, the present application also provides a device, including a processor 310, a communication interface 320, a memory 330 for storing a processor executable computer program, and a communication bus 340. The processor 310, the communication interface 320, and the memory 330 communicate with each other through the communication bus 340. The processor 310 implements the above-mentioned method for implementing autonomous transactions in a database by running an executable computer program.

[0044] Among them, the computer program in the memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0045] The system embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected based on actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0046] Through the description of the above implementation modes, those skilled in the art can clearly understand that each implementation mode can be implemented by means of software plus a necessary general hardware platform, or of course by hardware. Based on such an understanding, the above technical solution can essentially or in other words be embodied in the form of a software product that contributes to the prior art. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0047] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for implementing autonomous transactions in a database, characterized in that: The method comprises: Before starting the autonomous transaction thread, create shared memory by introducing the DSM module; Assemble the function parameter package of the autonomous transaction function, and place the assembled function parameter package in the created shared memory; Start the autonomous transaction thread and obtain the function information in the function parameter package from the shared memory; The autonomous transaction function is executed according to the obtained function information, and the autonomous transaction message is processed according to the execution result.

2. The method for implementing autonomous transactions in a database according to claim 1, characterized in that: Before starting the autonomous transaction thread, a shared memory is created by introducing a DSM module, including: before starting the autonomous transaction thread, a shared memory module is dynamically applied for to create and manage the shared memory of the main transaction thread and the autonomous transaction thread.

3. The method for implementing autonomous transactions in a database according to claim 1, characterized in that: Assembling a function parameter package of an autonomous transaction function, including: assembling function information of the autonomous transaction function into a function parameter package of the autonomous transaction function.

4. The method for implementing autonomous transactions in a database according to claim 3, characterized in that: The function information of the autonomous transaction function includes the input parameter type, number and parameter value information of the autonomous transaction function.

5. The method for implementing autonomous transactions in a database according to claim 1, characterized in that: Starting an autonomous transaction thread, and obtaining information in a function parameter package from a shared memory, including: starting an autonomous transaction thread, obtaining a function parameter package in a shared memory of a main transaction thread and an autonomous transaction thread, and obtaining input parameter type, number, and parameter value information in the function parameter package through deserialization recovery.

6. The method for implementing autonomous transactions in a database according to claim 1, characterized in that: Execute the autonomous transaction function according to the obtained function information, and process the autonomous transaction message according to the execution result, including: execute the autonomous transaction function according to the restored input parameter type, number and parameter value information, and when the execution is normal, place the execution result in the shared message queue and send it to the main transaction thread.

7. The method for implementing autonomous transactions in a database according to claim 1, characterized in that: The autonomous transaction function is executed according to the obtained function information, and the autonomous transaction message is processed according to the execution result, including: when the execution is abnormal, an error message is written to the shared message queue, the main transaction thread is awakened, and the error message in the shared message queue is processed by the awakened main transaction thread.

8. The method for implementing autonomous transactions in a database according to claim 7, characterized in that: The autonomous transaction function is executed according to the obtained function information, and the autonomous transaction message is processed according to the execution result. It also includes: setting an error level threshold for error messages in the shared message queue. When the error level of the error message in the shared message queue reaches the set error level threshold, the main transaction thread exception is triggered, and the corresponding resources are released through the main transaction thread.

9. A system for implementing autonomous transactions in a database, characterized in that: The system includes an autonomous server, and the autonomous server includes: A shared memory creation module is used to create a shared memory by introducing a DSM module before starting an autonomous transaction thread; A function parameter package creation module is used to assemble the function parameter package of the autonomous transaction function and place the assembled function parameter package in the created shared memory; The function information acquisition module is used to start the autonomous transaction thread and obtain the function information in the function parameter package from the shared memory; The autonomous transaction processing module is used to execute the autonomous transaction function according to the acquired function information and process the autonomous transaction message according to the execution result.

10. A computer device, characterized in that: The computer device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 8 when executing the program.