A transaction commit item cleaning method and device, electronic equipment and storage medium
Patent Information
- Application Number
- CN202211713105.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2042-12-27
AI Technical Summary
[0020] The technical solution of this invention selects the target commit item to be cleaned from multiple transaction commit items in the list to be cleaned based on the second identifier of the tablespace performing the tablespace operation, and cleans the target commit item. This eliminates the need to clean all tablespaces involved in all transaction commits in the database system at the same time, thereby improving the system performance of the database system when cleaning tablespaces involved in transaction commits.
Smart Images

Figure CN115904639B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of database technology, and in particular to a transaction commit cleanup method, apparatus, electronic device and storage medium. Background Technology
[0002] In a database system, a tablespace consists of one or more data files. All objects in the database are logically stored in a tablespace, but physically stored in the data files belonging to that tablespace.
[0003] In current database systems, deleting database objects such as tables, indexes, or large fields, or deleting or modifying data rows, does not immediately release the storage space occupied by the objects upon transaction commit. The actual release of this storage space is handled by the cleanup system's cleanup thread at specific times. When the database system operates on tablespaces under certain scenarios, it triggers the cleanup thread to perform tablespace cleanup, releasing the storage space occupied by the tablespaces. This cleanup action cleans up all tablespaces involved in all transaction commits within the database system, which has a certain impact on system performance. Therefore, improving the system performance of database systems when cleaning up tablespaces involved in transaction commits is a pressing technical problem that needs to be solved. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and storage medium for cleaning up transaction commit items, which improves the system performance of database systems when cleaning up tablespaces involved in transaction commits.
[0005] In a first aspect, embodiments of the present invention provide a transaction commit cleanup method, including:
[0006] A list to be cleaned up is determined, which includes multiple transaction commits. Each transaction commit includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction.
[0007] Determine the second identifier of the tablespace from which the tablespace operation is performed;
[0008] Based on the second identifier, select the target commit item to be cleaned from multiple transaction commit items in the list to be cleaned;
[0009] Clean up the target commit.
[0010] Secondly, embodiments of the present invention provide a transaction commit cleanup apparatus, comprising:
[0011] The module for determining the list to be cleaned is used to determine the list to be cleaned. The list to be cleaned includes multiple transaction commit items. Each transaction commit item includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction.
[0012] The second identifier determination module is used to determine the second identifier of the tablespace where the tablespace operation is performed;
[0013] The target commit selection module is used to select the target commit to be cleaned from multiple transaction commits in the list to be cleaned based on the second identifier.
[0014] The target commit cleanup module is used to clean up the target commits.
[0015] Thirdly, embodiments of the present invention provide an electronic device, including:
[0016] At least one processor; and
[0017] A memory communicatively connected to the at least one processor; wherein,
[0018] The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the transaction commit cleanup method as described in the first aspect.
[0019] Fourthly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the transaction commit cleanup method as described in the first aspect.
[0020] The technical solution of this invention selects the target commit item to be cleaned from multiple transaction commit items in the list to be cleaned based on the second identifier of the tablespace performing the tablespace operation, and cleans the target commit item. This eliminates the need to clean all tablespaces involved in all transaction commits in the database system at the same time, thereby improving the system performance of the database system when cleaning tablespaces involved in transaction commits.
[0021] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a transaction commit item cleanup method provided in Embodiment 1 of the present invention;
[0024] Figure 2 This is a flowchart of a transaction commit item cleanup method provided in Embodiment 2 of the present invention;
[0025] Figure 3 This is a schematic diagram of a transaction commit cleanup device according to Embodiment 4 of the present invention;
[0026] Figure 4 A schematic diagram of an electronic device that can be used to implement embodiments of the present invention is shown. Detailed Implementation
[0027] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first," "second," etc., used in this invention 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 the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0029] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this disclosure in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0030] Example 1
[0031] Figure 1 This is a flowchart of a transaction commit cleanup method according to Embodiment 1 of the present invention. This embodiment is applicable to the cleanup of transaction commits. The method can be executed by a transaction commit cleanup device, which can be implemented in software and / or hardware and integrated into an electronic device. Further, the electronic device includes, but is not limited to, computers, laptops, smartphones, servers, etc. Figure 1 As shown, the method includes:
[0032] S110. Determine the list to be cleaned up. The list to be cleaned up includes multiple transaction commits. Each transaction commit includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction.
[0033] A cleanup list refers to a linked list that stores multiple transaction commits awaiting cleanup. The linked list can be a non-contiguous, non-sequential storage structure in physical memory; the logical order of data elements is achieved through the linking order of pointers within the list. A linked list consists of a series of nodes (each element in the list is called a node), which can be dynamically generated at runtime. Each node can include two parts: a data field storing the data element and a pointer field storing the address of the next node.
[0034] The list to be cleaned up is not limited; it can include multiple transaction commit items, which can refer to commit items generated when a database transaction is committed. A database transaction can be a logical unit in the execution process of a database system, consisting of a finite sequence of database operations. A database transaction typically contains a sequence of read or write operations on the database.
[0035] When a database transaction modifies data in a tablespace of the database system, the first identifier of the tablespace modified by the database transaction can be recorded, such as by recording the first identifier of the tablespace modified by the database transaction in the rollback record corresponding to the current database transaction. This invention does not limit the recording method of the first identifier. When the database transaction is committed, a corresponding transaction commit item can be generated. The transaction commit item may include the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction.
[0036] The transaction identifier can refer to the identifier of a database transaction. Each database transaction can have a unique transaction identifier. There are no restrictions on the transaction identifier, as long as it can distinguish different database transactions. For example, TRX_1 can be considered as the transaction identifier of a database transaction.
[0037] The first identifier can refer to the identifier of the tablespace modified by the database transaction. The first identifier can be used to identify the tablespace modified by the database transaction. The number of first identifiers can be determined according to the number of tablespaces modified by the database transaction. Different tablespaces modified by the database transaction can correspond to different first identifiers.
[0038] The first identifier is not limited, as long as it can identify the tablespace modified by the database transaction. For example, preset identifiers can be pre-assigned to all tablespaces in the database system according to actual application needs. Each tablespace has a unique preset identifier. When a database transaction modifies data in a tablespace, the preset identifier corresponding to that tablespace can be used as the first identifier. The preset identifier can be set according to actual application needs and is not specifically limited. For example, if a database transaction modifies two tablespaces, and these two tablespaces have preset identifiers TS_1 and TS_2 respectively, then TS_1 and TS_2 can be used as the first identifiers for these two tablespaces respectively.
[0039] In one embodiment, when the tablespaces modified by database transaction TRX_1 are TS_1 and TS_2, the corresponding transaction commit item can be represented as commit_item_01. Commit_item_01 can contain (TRX_1, TS_1, TS_2), that is, the transaction commit item includes the transaction identifier TRX_1 of the corresponding database transaction, and the first identifiers TS_1 and TS_2 of the tablespaces modified by the database transaction.
[0040] The method for determining the list to be cleaned up is not limited, as long as the list can be identified. For example, when the database system executes a database transaction commit, it can store the transaction commit items involved in the commit into a list to be cleaned up. This list can be pre-stored in the corresponding cleanup system of the database system. When the cleanup thread of the cleanup system is triggered, it can traverse the list to be cleaned up so that the target commit items in the list that need to be cleaned up can be cleaned up subsequently. Here, the cleanup system can refer to the system within the database system that cleans up transaction commit items, and the cleanup thread can refer to the thread within the database system that cleans up transaction commit items.
[0041] S120. Determine the second identifier of the tablespace to which the tablespace operation will be performed.
[0042] Tablespace operations can be operations on the tablespace itself. Tablespace operations can trigger the cleanup thread of the cleanup system. There are no restrictions on the tablespace operations, as long as they can trigger the cleanup thread of the cleanup system. For example, tablespace operations can be tablespace deletion, offline tablespace, or tablespace migration in a distributed cluster environment. The specific operations can be determined according to the database system in the actual application. Different database systems may have different tablespace operations that trigger the cleanup thread of the cleanup system.
[0043] Tablespace deletion can refer to the operation of deleting a tablespace; offline tablespace can refer to making the data in a tablespace inaccessible; tablespace migration in a distributed cluster environment can refer to migrating a tablespace from one database server to another in a distributed cluster environment.
[0044] The second identifier can refer to the identifier of the tablespace in which the tablespace operation is performed. The second identifier can be one or more of the multiple first identifiers. The second identifier can be used to identify the tablespace in which the tablespace operation is performed in the tablespace modified by the database transaction.
[0045] The method for determining the second identifier of the tablespace to be operated on is not limited, as long as the second identifier of the tablespace to be operated on can be determined. For example, preset identifiers can be pre-assigned to all tablespaces in the database system according to actual application needs. Each tablespace has a unique preset identifier. When a tablespace operation is performed on a certain tablespace, the preset identifier corresponding to that tablespace can be determined as the second identifier of that tablespace. For example, if the preset identifier corresponding to a certain tablespace is TS_1, when a tablespace deletion operation needs to be performed on that tablespace, the preset identifier TS_1 can be determined as the second identifier of that tablespace.
[0046] Furthermore, the second identifier is stored in the cleanup system when performing tablespace operations.
[0047] The second identifier is stored in the cleanup system when performing tablespace operations. This can be understood as follows: when performing tablespace operations on a certain tablespace, the second identifier corresponding to that tablespace can be stored in the cleanup system, such as in the global structure of the cleanup system, so that the cleanup system can access the global structure of the cleanup system and thus determine the second identifier of the tablespace to which the tablespace operation is performed.
[0048] S130. Based on the second identifier, select the target commit item to be cleaned from multiple transaction commit items in the list to be cleaned.
[0049] The target commit can refer to the transaction commit that needs to be cleaned up among multiple transaction commits in the cleanup list. Specifically, the transaction commit that needs to be cleaned up among the multiple transaction commits in the cleanup list is the transaction commit corresponding to the tablespace where the tablespace operation was performed. Therefore, the target commit can include a second identifier of the tablespace where the tablespace operation was performed.
[0050] The method for selecting the target commit item from multiple transaction commits in the list to be cleaned based on the second identifier is not limited, as long as it is possible to select the target commit item from multiple transaction commits in the list to be cleaned. For example, it can be done by a cleanup thread in the cleanup system, which traverses multiple transaction commits in the list to be cleaned based on the second identifier. The cleanup thread compares the second identifier with the first identifier in each transaction commit. If the second identifier is one or more of the multiple first identifiers of a certain transaction commit, then the transaction commit can be determined as the target commit, that is, the target commit includes the second identifier of the tablespace where the tablespace operation was performed.
[0051] S140, Clean up target commits.
[0052] There are no restrictions on the method of cleaning up the target commit, as long as it can clean up the target commit. For example, it can be cleaned up by the cleanup thread of the cleanup system. After the cleanup thread has finished cleaning up the target commit, it can remove the cleaned target commit from the cleanup list.
[0053] The technical solution of this invention first determines a list to be cleaned, which includes multiple transaction commits. Each transaction commit includes a transaction identifier of the corresponding database transaction and a first identifier of the tablespace modified by the database transaction. Next, a second identifier of the tablespace where the tablespace operation was performed is determined. Then, based on the second identifier, a target commit to be cleaned is selected from the multiple transaction commits in the list to be cleaned. Finally, the target commit is cleaned. This technical solution, by selecting the target commit to be cleaned from the multiple transaction commits in the list to be cleaned based on the second identifier of the tablespace where the tablespace operation was performed, and then cleaning the target commit, avoids cleaning all tablespaces involved in all transaction commits in the database system, thus improving the system performance of the database system when cleaning tablespaces involved in transaction commits.
[0054] Example 2
[0055] Figure 2 This is a flowchart of a transaction commit cleanup method according to Embodiment 2 of the present invention. This embodiment is a further refinement of Embodiment 1 above, specifically regarding the determination of the list to be cleaned and the selection of the target commit to be cleaned from multiple transaction commits in the list to be cleaned based on a second identifier. Figure 2 As shown, the method includes:
[0056] S111. After the cleanup thread is triggered, determine the list to be cleaned up.
[0057] In general, in database systems, when deleting database objects such as tables, indexes, or large fields, or deleting or modifying data rows, the transaction commit items involved in the database transaction are stored in a cleanup list during transaction commit. However, the storage space occupied by these objects is not immediately released. This is done for two reasons: first, to improve the performance of deleting objects or modifying data; and second, to prevent accidental operations, allowing data recovery using rollback records after the database transaction is committed. The actual release of the storage space occupied by the objects is handled by the cleanup system's cleanup thread at specific times—the specific times when the cleanup thread is triggered.
[0058] In scenarios such as tablespace deletion, offline tablespace migration, or tablespace migration in a distributed cluster environment (the specific scenarios may differ for different databases and are not limited to this invention), the cleanup system's cleanup thread will be triggered to clean up the tablespace and release the storage space occupied by the tablespace. When a tablespace operation is performed on a tablespace, the cleanup system's cleanup thread can be triggered. After the cleanup thread is triggered, it can traverse the cleanup list in the cleanup system to clean up the target commits that need to be cleaned up in the cleanup list.
[0059] Furthermore, the list to be cleaned is generated through the following operations:
[0060] Determine the first identifier of the tablespace being modified;
[0061] Generate a transaction commit item, which includes the transaction identifier and first identifier of the database transaction;
[0062] Store transaction commits in the cleanup system's pending cleanup list.
[0063] The first identifier of the tablespace to be modified can be determined by pre-assigning preset identifiers to all tablespaces in the database system according to the actual application needs. Each tablespace has a unique preset identifier. When a database transaction modifies the data of a tablespace in the database system, the preset identifier corresponding to that tablespace can be determined as the first identifier of that tablespace.
[0064] A transaction commit item is generated. The transaction commit item includes the transaction identifier and the first identifier of the database transaction. It can be understood that when the database transaction is committed, the first identifier of the modified tablespace and the transaction identifier of the database transaction can be registered in the transaction commit item. This generates the transaction commit item, which includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction.
[0065] Storing transaction commit items in the cleanup system's pending cleanup list means that the transaction commit items involved in database transaction commits can be stored in the pending cleanup list.
[0066] Furthermore, determining the first identifier of the modified tablespace includes:
[0067] When a database transaction modifies tablespace data, the first identifier of the tablespace being modified is determined.
[0068] When a database transaction modifies tablespace data, the first identifier of the tablespace being modified is determined. That is, when a database transaction modifies the data of a certain tablespace in the database system, the preset identifier corresponding to that tablespace is determined as the first identifier of that tablespace. Thus, the tablespace modified by the database transaction can be marked by the first identifier.
[0069] Furthermore, generate transaction commit items, including:
[0070] When a database transaction is committed, a transaction commit item is generated.
[0071] When a database transaction is committed, the first identifier of the modified tablespace and the transaction identifier of the database transaction can be registered in the transaction commit item, thereby generating a transaction commit item. The transaction commit items involved in the database transaction commit are then stored in the cleanup list so that the target commit items that need to be cleaned up in the cleanup list can be cleaned up later.
[0072] S120. Determine the second identifier of the tablespace to which the tablespace operation will be performed.
[0073] S131. When cleaning up the list to be cleaned up, compare the second identifier with the first identifier of each transaction commit item in the list to be cleaned up.
[0074] When cleaning up the list to be cleaned, there is no restriction on the method of comparing the second identifier with the first identifier of each transaction commit item in the list to be cleaned, as long as it is possible to compare the second identifier with the first identifier of each transaction commit item in the list to be cleaned. For example, the cleanup thread in the cleanup system can traverse each transaction commit item in the list to be cleaned based on the second identifier, and the cleanup thread can compare the second identifier with the first identifier in each transaction commit item to determine whether the first identifier in each transaction commit item includes the second identifier.
[0075] S132. For each transaction commit item in the list to be cleaned up, if the first identifier of the transaction commit item includes the second identifier, the transaction commit item is identified as the target commit item.
[0076] For each transaction commit in the list to be cleaned up, if the first identifier of the transaction commit includes the second identifier, the transaction commit is identified as the target commit. This can be understood as follows: when the first identifier of the transaction commit includes the second identifier, it indicates that the second identifier is one or more of the multiple first identifiers of the transaction commit, and the transaction commit can be identified as the target commit. That is, the target commit includes the second identifier of the tablespace to which the tablespace operation is performed.
[0077] In one embodiment, the list to be cleaned up includes two transaction commit items: commit_item_01 and commit_item_02. commit_item_01 includes the transaction identifier TRX_1 of the corresponding database transaction, and the first identifiers TS_1 and TS_2 of the tablespaces modified by the database transaction, i.e., commit_item_01 includes (TRX_1, TS_1, TS_2); commit_item_02 includes the transaction identifier TRX_2 of the corresponding database transaction, and the first identifiers TS_2, TS_3, and TS_4 of the tablespaces modified by the database transaction, i.e., commit_item_02 includes (TRX_2, TS_2, TS_3, TS_4); if the preset identifier corresponding to a certain tablespace is TS_... 1. When a tablespace deletion operation needs to be performed on the tablespace, the preset identifier TS_1 can be determined as the second identifier corresponding to the tablespace. Through the cleanup thread of the cleanup system, based on the second identifier TS_1, the transaction commit items included in the cleanup list are traversed, and the second identifier is compared with the first identifier of each transaction commit item in the cleanup list. Then, the first identifier in commit_item_01 includes the second identifier, while the first identifier in commit_item_02 does not include the second identifier. Therefore, commit_item_01 can be determined as the target commit item, while commit_item_02 is a transaction commit item that does not need to be cleaned up.
[0078] S140, Clean up target commits.
[0079] The technical solution of this invention compares the second identifier with the first identifier of each transaction commit item in the list to be cleaned. When the first identifier of a transaction commit item includes the second identifier, the transaction commit item is determined as the target commit item, and the target commit item is cleaned up. That is, it is not necessary to clean up all tablespaces involved in all transaction commits in the database system together, but only the target commit item needs to be cleaned up, which improves the system performance of the database system when cleaning up tablespaces involved in transaction commits.
[0080] Example 3
[0081] The embodiments of the present invention are exemplary descriptions of the above embodiments.
[0082] In certain scenarios, such as tablespace deletion, offline tablespace migration, or tablespace migration in a distributed cluster environment (the specific scenarios may differ for different databases and are not limited to this invention), the cleanup system's cleanup thread will be triggered to perform tablespace cleanup, releasing the storage space occupied by the tablespace. This cleanup action cleans up all tablespaces involved in all committed transactions in the database system. Tablespace cleanup involves a series of operations such as B-tree release, data page flushing input / output (I / O), or data page buffer cleanup, which has a certain impact on system performance. However, in the scenarios described above, it is not necessary to clean up all tablespaces involved in all committed transactions (i.e., tablespaces modified by database transactions); only the currently operating tablespace (i.e., the tablespace executing the tablespace operation) needs to be cleaned up. If operations such as flushing data pages to disk and cleaning data page buffers in other tablespaces are excluded, system performance can be significantly improved when the proportion of currently operating tablespace committed transactions to all tablespace committed transactions is small.
[0083] This invention provides a method for cleaning up data in a specified tablespace. By registering the tablespaces involved in data modification during a transaction (i.e., the tablespaces modified by the database transaction), the tablespace information (i.e., the first identifier of the modified tablespace) is registered in the transaction commit entries of the cleanup system upon transaction commit. When a user executes a tablespace operation, triggering the cleanup thread, the cleanup thread searches the transaction commit entries and only cleans up transactions that contain the tablespaces involved in the current operation. This invention, by selectively cleaning up tablespaces from committed transactions, can effectively improve system performance.
[0084] This invention records the tablespace identifier (IdentityDocument, ID) modified by the current transaction when modifying tablespace data. This ID is the first identifier of the modified tablespace. The invention does not restrict the method of recording the tablespace ID; for example, it can be recorded in the rollback record corresponding to the current transaction or in a specific data table. When the transaction is committed, this tablespace ID information is registered in the transaction commit item of the cleanup system, and the transaction commit item is placed in the cleanup system's pending cleanup list. When the execution of a tablespace operation triggers the cleanup thread to perform cleanup, the cleanup thread searches for the transaction commit item, compares the tablespace ID corresponding to the current operation (i.e., the second identifier) with the tablespace ID in the transaction commit item (i.e., the first identifier), and only cleans up the transaction commit items containing the tablespace IDs involved in the current operation (i.e., the target commit item). The transaction commit item contains the transaction ID (i.e., the transaction identifier) and all the tablespace IDs it modified (i.e., the first identifier).
[0085] The present invention provides a method for cleaning up data in a specified tablespace, the general steps of which are as follows:
[0086] 1) Start a transaction (assuming the transaction ID is TRX_1);
[0087] 2) When a transaction modifies tablespace data, it records all tablespace IDs modified by the transaction, which is the first identifier of the tablespace modified by the database transaction (assuming that the tablespace IDs modified by transaction TRX_1 are TS_1 and TS_2).
[0088] 3) When a transaction is committed, a transaction commit item (commit_item_01) is generated. The transaction commit item contains the current transaction ID. All tablespace ID information modified by the transaction is copied to the transaction commit item. The transaction commit item is then placed in the cleanup system's cleanup list (commit_item_01 contains (TRX_1, TS_1, TS_2).
[0089] 4) When performing tablespace operations (such as deleting a tablespace, offline tablespace, or tablespace migration in a distributed cluster environment), the tablespace ID of the current operation (i.e., the second identifier of the tablespace performing the tablespace operation) is recorded in the global structure of the cleanup system (assuming that the tablespace to be deleted is TS_1, TS_1 is recorded in the global structure of the cleanup system).
[0090] 5) The cleanup thread of the cleanup system begins to traverse the cleanup list and collect the transaction commits (i.e. target commits) that need to be cleaned up.
[0091] 6) When collecting transaction commits that need to be cleaned up, compare the tablespace ID (i.e., the second identifier) in the cleanup system's global structure with the tablespace ID (i.e., the first identifier) in the transaction commit. If the tablespace ID in the transaction commit contains the tablespace ID in the current cleanup system's global structure, then the transaction commit is a transaction commit that needs to be cleaned up; otherwise, the transaction commit is a transaction commit that does not need to be cleaned up (assuming the list to be cleaned up contains two transaction commits commit_item_01 and commit_item_02, commit_item_01 contains (TRX_1,TS_1,TS_2), and commit_item_02 contains (TRX_2,TS_2,TS_3,TS_4), then commit_item_01 is a transaction commit that needs to be cleaned up, and commit_item_02 is a transaction commit that does not need to be cleaned up).
[0092] 7) The cleanup thread cleans up the collected transaction commits one by one. The cleaned-up transaction commits will be removed from the cleanup system's cleanup list (after cleanup, the cleanup list will only contain the transaction commit_item_02).
[0093] This invention can effectively improve system performance by selectively cleaning up the tablespace of committed transactions.
[0094] Example 4
[0095] Figure 3 This is a schematic diagram of a transaction commit cleanup device according to Embodiment 4 of the present invention. This embodiment is applicable to situations involving the cleanup of transaction commits, such as... Figure 3 As shown, the specific structure of the device includes:
[0096] The module 21 for determining the list to be cleaned is used to determine the list to be cleaned. The list to be cleaned includes multiple transaction commits. Each transaction commit includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction.
[0097] The second identifier determination module 22 is used to determine the second identifier of the tablespace where the tablespace operation is performed;
[0098] The target commit selection module 23 is used to select the target commit to be cleaned from multiple transaction commits in the cleanup list based on the second identifier.
[0099] The target commit cleanup module 24 is used to clean up target commits.
[0100] The transaction commit cleanup device provided in this embodiment first determines the cleanup list through a cleanup list determination module. The cleanup list includes multiple transaction commits, each of which includes the transaction identifier of the corresponding database transaction and a first identifier of the tablespace modified by the database transaction. Then, a second identifier determination module determines the second identifier of the tablespace where the tablespace operation was performed. Next, a target commit selection module selects the target commit to be cleaned from the multiple transaction commits in the cleanup list based on the second identifier. Finally, a target commit cleanup module cleans up the target commit.
[0101] Furthermore, the list to be cleaned is generated through the following operations:
[0102] Determine the first identifier of the tablespace being modified;
[0103] Generate a transaction commit item, which includes the transaction identifier and first identifier of the database transaction;
[0104] Store transaction commits in the cleanup system's pending cleanup list.
[0105] Furthermore, determining the first identifier of the modified tablespace includes:
[0106] When a database transaction modifies tablespace data, the first identifier of the tablespace being modified is determined.
[0107] Furthermore, generate transaction commit items, including:
[0108] When a database transaction is committed, a transaction commit item is generated.
[0109] Furthermore, the second identifier is stored in the cleanup system when performing tablespace operations.
[0110] Furthermore, the target submission selection module 23 is specifically used for:
[0111] When cleaning up the list to be cleaned, compare the second identifier with the first identifier of each transaction commit item in the list to be cleaned;
[0112] For each transaction commit in the list to be cleaned, if the first identifier of the transaction commit includes the second identifier, the transaction commit is identified as the target commit.
[0113] Furthermore, the module 21 for determining the list to be cleaned is specifically used for:
[0114] After the cleanup thread is triggered, the list to be cleaned up is determined.
[0115] The transaction commit cleanup apparatus provided in this embodiment of the invention can execute the transaction commit cleanup method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the transaction commit cleanup method.
[0116] Example 5
[0117] Figure 4 A schematic diagram of an electronic device that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0118] like Figure 4 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 may also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0119] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0120] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as transaction commit cleanup methods.
[0121] In some embodiments, the transaction commit cleanup method may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the transaction commit cleanup method described above may be performed. Alternatively, in other embodiments, processor 11 may be configured to perform the transaction commit cleanup method by any other suitable means (e.g., by means of firmware).
[0122] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0123] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0124] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0125] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0126] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0127] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through a communication network. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0128] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and no limitation is imposed herein.
[0129] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for cleaning up transaction commit items, characterized in that, include: A list to be cleaned up is determined, which includes multiple transaction commit items. Each transaction commit item includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction. The first identifier is determined and recorded in the rollback record corresponding to the current database transaction when the database transaction modifies the tablespace data. A second identifier is determined for the tablespace to which the tablespace operation is performed, and this second identifier is stored in the cleanup system when the tablespace operation is performed; Based on the second identifier, selecting the target commit item to be cleaned from multiple transaction commit items in the list to be cleaned includes: when cleaning the list to be cleaned, comparing the second identifier with the first identifier of each transaction commit item in the list to be cleaned; for each transaction commit item in the list to be cleaned, if the second identifier is included in the first identifier of the transaction commit item, the transaction commit item is determined as the target commit item. Clean up the target commit.
2. The method according to claim 1, characterized in that, The linked list to be cleaned is generated through the following operations: Determine the first identifier of the tablespace being modified; Generate a transaction commit item, wherein the transaction commit item includes the transaction identifier of the database transaction and the first identifier; The transaction commit items are stored in the cleanup system's pending cleanup list.
3. The method according to claim 2, characterized in that, The determination of the first identifier of the modified tablespace includes: When a database transaction modifies tablespace data, the first identifier of the tablespace being modified is determined.
4. The method according to claim 2, characterized in that, The generation of transaction commit items includes: When the database transaction is committed, a transaction commit item is generated.
5. The method according to claim 1, characterized in that, The process of determining the linked list to be cleaned includes: After the cleanup thread is triggered, the list to be cleaned up is determined.
6. A transaction commit cleanup apparatus, characterized in that, include: The module for determining the list to be cleaned is used to determine the list to be cleaned. The list to be cleaned includes multiple transaction commit items. Each transaction commit item includes the transaction identifier of the corresponding database transaction and the first identifier of the tablespace modified by the database transaction. The first identifier is determined and recorded in the rollback record corresponding to the current database transaction when the database transaction modifies the tablespace data. The second identifier determination module is used to determine the second identifier of the tablespace to which the tablespace operation is performed. The second identifier is stored in the cleanup system when the tablespace operation is performed. The target commit selection module is used to select the target commit to be cleaned from multiple transaction commits in the list to be cleaned based on the second identifier. The target commit cleanup module is used to clean up the target commits; The target commit selection module is specifically used to: when cleaning the list to be cleaned, compare the second identifier with the first identifier of each transaction commit in the list to be cleaned; for each transaction commit in the list to be cleaned, if the second identifier is included in the first identifier of the transaction commit, determine the transaction commit as the target commit.
7. An electronic device, characterized in that, include: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor to enable the at least one processor to perform the method as described in any one of claims 1-5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1-5.
Citation Information
Patent Citations
Method, device and system for processing distributed transactions in SQL (Structured Query Language) database
CN114328613A