Transaction processing methods and apparatus

By establishing a mapping relationship between the target transaction, memory object, and data file in the Oracle database, data is stored in memory blocks in an orderly manner, which solves the performance overhead problem caused by memory caching of uncommitted transaction data in the existing technology and improves read and write efficiency.

CN116450751BActive Publication Date: 2026-04-03HUNDSUN TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-24
Publication Date
2026-04-03

AI Technical Summary

Technical Problem

Existing technologies require a large physical memory cache for uncommitted transaction data when processing Redo data in Oracle databases, resulting in high performance overhead and low read/write efficiency, especially affecting synchronization efficiency when there are many concurrent and large transactions.

Method used

By establishing a mapping relationship between the target transaction, the memory object, and the data file, the data in the data file is stored in the memory block contained in the memory object in an orderly manner, forming a storage link. Based on the storage link, the target data corresponding to the target transaction is read from the memory object, thus realizing orderly reading and writing.

Benefits of technology

It enables ordered writing and reading of data, reduces the performance overhead of random writing, improves read and write efficiency, and reduces performance overhead.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116450751B_ABST
    Figure CN116450751B_ABST
Patent Text Reader

Abstract

This specification provides a transaction processing method and apparatus for use in a database management terminal, which manages relational databases. The transaction processing method includes: determining a target transaction based on the database logs of the relational database; determining the data file corresponding to the target transaction in the relational database and the memory object corresponding to the target transaction in memory space; establishing a mapping relationship between the target transaction, the memory object, and the data file, and storing data from the data file into a memory block contained in the memory object based on the mapping relationship; wherein the memory blocks storing the data constitute a storage link; and reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link, for executing the target transaction. Storing data based on the mapping relationship achieves ordered data writing, avoiding the performance overhead of random writes; and reduces the number of bytes read during data reading, improving data reading efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a transaction processing method. This specification also relates to a transaction processing apparatus, a computing device, and a computer-readable storage medium. Background Technology

[0002] With the development of computer technology, the era of big data is gradually arriving. In the database field, this brings with it the problem of transaction concurrency. In existing technologies, to cope with the rapid generation of Redo data in Oracle databases, especially when there are many and large concurrent transactions, the uncommitted transaction data parsed from the Redo log file is usually cached in memory. After directly parsing the transaction control statement (Commit / Rollback), all the data of the corresponding transaction in memory are traversed again, merged, processed, and then passed down.

[0003] However, this approach requires allocating significant physical memory to the synchronization process to cache uncommitted transaction data. Each transaction control operation necessitates scanning the cache file, resulting in substantial performance overhead and low read / write efficiency. Therefore, an effective method is urgently needed to address these issues. Summary of the Invention

[0004] In view of this, embodiments of this specification provide a transaction processing method. This specification also relates to a transaction processing apparatus, a computing device, and a computer-readable storage medium to address the technical deficiencies existing in the prior art.

[0005] According to a first aspect of the embodiments of this specification, a transaction processing method is provided, applied to a database management terminal, the database management terminal being used to manage a relational database, including:

[0006] The target transaction is determined based on the database logs of the relational database;

[0007] The data file corresponding to the target transaction is determined in the relational database, and the memory object corresponding to the target transaction is determined in the memory space;

[0008] A mapping relationship is established between the target transaction, the memory object, and the data file, and the data in the data file is stored in the memory block contained in the memory object based on the mapping relationship; wherein, the memory block storing the data constitutes a storage link;

[0009] Based on the storage link, the target data corresponding to the target transaction is read from the memory block contained in the memory object, and used to execute the target transaction.

[0010] Optionally, determining the target transaction based on the database logs of the relational database includes:

[0011] In response to a data processing request, log records stored in the database log of the relational database are read, and the target log record is determined based on the reading result;

[0012] The target log record is parsed, and the target transaction is determined based on the parsing results.

[0013] Optionally, determining the memory object corresponding to the target transaction in the memory space includes:

[0014] Determine the amount of data in the data file;

[0015] Based on the amount of data, at least one memory block is requested in the memory space, and the memory object corresponding to the target transaction is composed of at least one memory block.

[0016] Optionally, storing the data from the data file into the memory block contained in the memory object based on the mapping relationship includes:

[0017] In the memory object, the i-th memory block is determined, and the data that is not stored in the data file is stored in the i-th memory block based on the mapping relationship, where i starts from 1 and is a positive integer;

[0018] When the i-th memory block is full and the data file contains unstored data, i is incremented sequentially, and the step of storing the unstored data in the data file into the i-th memory block based on the mapping relationship is executed.

[0019] Until the data file no longer contains unstored data, the step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link is executed to execute the target transaction.

[0020] Optionally, the nodes corresponding to memory blocks in the storage link have a linked storage relationship, and the index information of the memory block storing data includes a tag index item, a status index item, a data index item, a previous association index item, and a subsequent association index item;

[0021] In this storage link, two adjacent memory blocks are linked through the preceding association index and the following association index.

[0022] Optionally, reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link includes:

[0023] The memory block arrangement order is determined based on the storage link;

[0024] The target data corresponding to the target transaction is read from the memory blocks contained in the memory object according to the memory block arrangement order.

[0025] Optionally, after the step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link to execute the target transaction step, it further includes:

[0026] Once the target transaction is completed, the memory block in the memory object is released.

[0027] Optionally, reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link includes:

[0028] Merge the transaction records contained in the transaction record table corresponding to the target transaction, and determine the target transaction record table based on the merging result;

[0029] Based on the storage link, the target data corresponding to the target transaction record table is read from the memory block contained in the memory object.

[0030] Optionally, reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link includes:

[0031] Determine the j-th transaction record in the transaction record table of the target transaction;

[0032] Determine whether the j-th transaction record is a rollback record;

[0033] If so, update the transaction record table based on the j-th transaction record, use the updated transaction record table as the transaction record table, increment j sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction;

[0034] If not, based on the storage link, determine the j-th data corresponding to the j-th transaction record in the memory block contained in the memory object, where j is incremented sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction;

[0035] Until j increments to k, the determined data is used as the target data, where j starts from 1 and takes a value up to k and is a positive integer, and k is the number of transaction records in the transaction record table.

[0036] Optionally, if the transaction record is a rollback record, the termination memory block corresponding to the rollback record is determined in the storage link, and the record value of the data record index in the termination memory block is updated;

[0037] If the updated record value is less than or equal to zero, the preceding memory block corresponding to the terminating memory block is determined based on the storage link, and the terminating memory block is released.

[0038] The storage link is updated based on the release result and the preceding memory block, and the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the updated storage link.

[0039] According to a second aspect of the embodiments of this specification, a transaction processing apparatus is provided, applied to a database management terminal, the database management terminal being used to manage a relational database, comprising:

[0040] The first determining module is configured to determine the target transaction based on the database logs of the relational database;

[0041] The second determining module is configured to determine the data file corresponding to the target transaction in the relational database and to determine the memory object corresponding to the target transaction in the memory space.

[0042] The storage module is configured to establish a mapping relationship between the target transaction, the memory object, and the data file, and to store data from the data file into a memory block contained in the memory object based on the mapping relationship; wherein the memory block storing the data constitutes a storage link;

[0043] The read module is configured to read the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link, and to execute the target transaction.

[0044] According to a third aspect of the embodiments of this specification, a computing device is provided, comprising:

[0045] Memory and processor;

[0046] The memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions, which, when executed by the processor, implement the steps of the transaction processing method.

[0047] According to a fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores computer-executable instructions that, when executed by a processor, implement the steps of the transaction processing method.

[0048] The transaction processing method provided in this specification is applied to a database management terminal used to manage relational databases. The transaction processing method includes: determining a target transaction based on the database logs of the relational database; determining the data file corresponding to the target transaction in the relational database and the memory object corresponding to the target transaction in memory space; establishing a mapping relationship between the target transaction, the memory object, and the data file, and storing data from the data file into a memory block contained in the memory object based on the mapping relationship; wherein the memory blocks storing the data constitute a storage link; and reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link, for executing the target transaction.

[0049] One embodiment of this specification establishes a mapping relationship between the target transaction, the memory object, and the data file. Based on this mapping relationship, data from the data file is stored in an orderly manner into the memory block contained in the memory object, achieving ordered data writing and avoiding the performance overhead of random writes. During data reading, the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the storage link, achieving ordered data reading, reducing the number of file bytes read, and improving data reading efficiency. Therefore, in mixed read / write operations, read / write efficiency is improved and performance overhead is reduced. Attached Figure Description

[0050] Figure 1 A schematic diagram of a transaction processing method according to an embodiment of this specification is shown;

[0051] Figure 2 A flowchart of a transaction processing method according to an embodiment of this specification is shown;

[0052] Figure 3a This diagram illustrates the construction of a storage link for a transaction processing method applied to data storage according to an embodiment of this specification.

[0053] Figure 3b A schematic diagram of transaction record table updating in a transaction processing method according to an embodiment of this specification is shown;

[0054] Figure 4 A flowchart illustrating a transaction processing method for data synchronization according to an embodiment of this specification is shown.

[0055] Figure 5 A schematic diagram of a transaction processing apparatus according to an embodiment of this specification is shown;

[0056] Figure 6 A structural block diagram of a computing device provided according to an embodiment of this specification is shown. Detailed Implementation

[0057] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this specification. Therefore, this specification is not limited to the specific implementations disclosed below.

[0058] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this specification refers to and includes any or all possible combinations of one or more associated listed items.

[0059] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this specification, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this specification, and similarly, second may also be referred to as first. Depending on the context, the word "if" as used herein may be interpreted as "when," "when," or "in response to a determination."

[0060] First, the terms and concepts used in one or more embodiments of this specification will be explained.

[0061] Mmap: A method for mapping files into memory. Mmap maps a file or other object into memory.

[0062] Oracle databases use Redo logs to ensure that database transactions can be replayed, enabling data recovery after a failure. Redo can be understood as redoing; in Oracle databases, Redo logs are used to re-execute database transactions. Correspondingly, the Redo log records database changes. Change Data Capture (CDC) technology based on Redo logs is currently the optimal implementation method. It involves parsing the database Redo logs to identify and capture changes made to the database (including data or table insertions, updates, and deletions) and transmitting them to downstream processes or systems in real time. In this way, CDC can provide efficient, low-latency data transmission to the data warehouse.

[0063] Oracle databases write data changes sequentially to the Redo log, including transaction control and DML (Insert, Delete, Update). When a single row of a DML operation spans multiple data blocks, multiple Redo log records are generated. In terms of transaction control, in addition to the normal commit of transaction data, there are also operations such as full transaction rollback and partial transaction rollback.

[0064] In existing technologies, to cope with the rapid generation of Redo log records in Oracle databases, especially when there are many concurrent and large transactions, the following methods are typically used: Uncommitted transaction data parsed from the Redo log file is cached in memory. Upon directly parsing a transaction control statement (Commit / Rollback), all data for the corresponding transaction in memory is traversed again, merged, and then passed down. Alternatively, data parsed from the Redo log records is sequentially written to a cache file. When a transaction control statement (Commit / Rollback) is parsed, all data for the corresponding transaction is searched in the cache file, merged, and then passed down. NoSQL (non-relational databases) can also be used instead of cache files. When a transaction control statement (Commit / Rollback) is parsed, all data for that transaction is quickly determined based on the transaction number, merged, and then passed down.

[0065] However, the methods described above require a large amount of physical memory to cache uncommitted transaction data for the synchronization process; each transaction control requires scanning the cache file, impacting synchronization efficiency; while NoSQL simplifies transaction writing, traversal, and cleanup / deletion logic, its write amplification severely affects synchronization efficiency. Therefore, this embodiment provides a method for caching parsed Redo log records using less physical memory and with extremely high access efficiency.

[0066] Figure 1 A schematic diagram of a transaction processing method according to an embodiment of this specification is shown, such as... Figure 1 As shown, the target transaction is determined based on the database logs of the relational database. The data file corresponding to the target transaction is identified in the relational database, and the memory object corresponding to the target transaction is identified in memory space. A mapping relationship is established between the target transaction, the memory object, and the data file, and data from the data file is stored in the memory block contained in the memory object based on this mapping relationship. The memory blocks storing the data constitute a storage link. Based on the storage link, the target data corresponding to the target transaction is read from the memory block contained in the memory object to execute the target transaction.

[0067] By establishing a mapping relationship between the target transaction, the memory object, and the data file, and storing the data from the data file sequentially into the memory block contained in the memory object based on this mapping relationship, ordered data writing is achieved, avoiding the performance overhead of random writes. During data reading, the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the storage link, achieving ordered data reading, reducing the number of file bytes read, and improving data reading efficiency. Therefore, in mixed read / write scenarios, read / write efficiency is improved while performance overhead is reduced.

[0068] This specification provides a transaction processing method, and also relates to a transaction processing apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.

[0069] Figure 2 A flowchart of a transaction processing method according to an embodiment of this specification is shown. The transaction processing method provided in this embodiment is applied to a database management terminal, which is used to manage a relational database, and specifically includes the following steps:

[0070] Step S202: Determine the target transaction based on the database logs of the relational database.

[0071] The transaction processing method provided in this specification is executed through a database management terminal, which is used to manage relational databases, such as Oracle, DB2, SQL Server, and MySQL. This embodiment uses Oracle as an example to illustrate the transaction processing method. The transaction processing procedures for other types of databases can be found in the same or corresponding descriptions in this embodiment, and will not be elaborated upon here.

[0072] Specifically, a relational database is a database that uses a relational model to organize data. It stores data in rows and columns for easy user understanding. These rows and columns are called tables, and a group of tables makes up the database. Users retrieve data from the database through queries, which are executable codes used to limit specific areas within the database. The relational model can be simply understood as a two-dimensional table model, and a relational database is a data organization composed of two-dimensional tables and the relationships between them. The database log records all operations that modify the database's data, table structure, indexes, etc. The database log records complete modification records of all transactions, which help the database perform Undo / Redo operations when recovering data. Undo refers to reversing or restoring; Undo undoes the information needed to reverse the results of DML (Data Manipulation Language) statements and is also called "rollback data." For example, if data is modified, executing Undo undoes the modification. The target transaction is the database transaction corresponding to the database log. A target transaction is a sequence of database operations that access and may manipulate various data items; these operations are either all executed or none are executed, making it an indivisible unit of work. A transaction consists of all database operations performed between the start and end of the transaction.

[0073] Based on this, upon receiving a data processing request, the system responds by reading the log records stored in the relational database's database log, determining the target log record in the database log based on the reading results, and then parsing the target log record.

[0074] In practical applications, the relational database can be an Oracle database, and the data processing requests can be data synchronization, data migration, data backup, or they can be used to advance the execution of downstream business by obtaining the data corresponding to the target transaction, such as performing real-time calculations, statistics, and analysis on the obtained data corresponding to the target transaction.

[0075] Furthermore, in relational databases, data changes generate database logs in the order of the changes. When determining the target transaction, considering that directly retrieving the target transaction might result in incomplete data retrieval, a complete retrieval of the target transaction can be achieved by parsing the target log records. The specific implementation is as follows:

[0076] In response to a data processing request, log records stored in the database log of the relational database are read, and the target log record is determined based on the read results; the target log record is parsed, and the target transaction is determined based on the parsing results.

[0077] Specifically, a data processing request refers to a computer instruction submitted to the database to process the data in the database. Data processing requests can be data processing requests corresponding to operations such as data synchronization, data migration, and data backup. A log record refers to a descriptive record generated after each operation is performed on the database and stored in the database log. Correspondingly, the target log record is the log record selected from the database log for data processing. By parsing the target log record, the transaction corresponding to that log record, i.e., the target transaction, can be determined.

[0078] Based on this, the system receives data processing requests, identifies database logs in the relational database, responds to the data processing requests, reads log records stored in the database logs, determines the target log record based on the reading results, parses the target log record, and determines the target transaction based on the parsing results. When reading log records stored in the database logs, the reading can be performed according to the storage order of the log records in the database logs.

[0079] For example, when performing data synchronization based on redo log records, a complete analysis of transactions in the database is required. Upon receiving a data synchronization request, the database log records are read, and parsing these records reveals transaction 1. Transaction 1 may involve records spanning multiple data blocks. Regarding transaction control, in addition to normal transaction commits, there are also operations such as full transaction rollback and partial transaction rollback.

[0080] In summary, by parsing the target log records and determining the target transaction based on the parsing results, the accuracy of target transaction determination is improved, which facilitates the subsequent reading of the data corresponding to the target transaction to complete data processing.

[0081] Step S204: Determine the data file corresponding to the target transaction in the relational database, and determine the memory object corresponding to the target transaction in the memory space.

[0082] Specifically, after identifying the target transaction based on the database logs of the relational database, the corresponding data file in the relational database and the corresponding memory object in the memory space can be determined. The data file is the file that stores all the data of the target transaction. The memory space is a contiguous segment of storage space corresponding to the relational database used for temporary storage of the data corresponding to the target transaction. The memory space includes multiple contiguous memory blocks, which can be selected and used to store data. Once the data is read, the memory block storing the data can be released and selected by other transactions for data storage. The memory object is an object composed of at least one memory block selected from the memory space according to the required memory space size of the data file. The selected memory blocks can be multiple non-contiguous memory blocks in the memory space. Whether the multiple memory blocks are contiguous depends on whether the memory blocks in the memory space that are in a free state are contiguous.

[0083] Based on this, after identifying the target transaction from the relational database logs, the data file storing the target transaction is determined within the relational database, and a memory object corresponding to the target transaction is selected from the memory space. When selecting the memory object, the number of data blocks contained within the memory object is determined based on the data volume of the target transaction. This ensures that all the data corresponding to the target transaction can be stored in the memory object.

[0084] In practical applications, when determining the memory object corresponding to the target transaction in memory space, the data blocks contained in the memory object can be at least one non-contiguous data block. Since data blocks in memory space can be reused, when determining the memory object, at least one memory block that can store the data corresponding to the target transaction is selected from the memory object based on the amount of data corresponding to the target transaction; that is, a memory block in the memory object that is in a free state or not occupied is selected.

[0085] Furthermore, considering that the amount of data contained in the data files varies, storing the data in the data files requires a significant amount of memory space. To avoid insufficient memory space, at least one memory block corresponding to the amount of data in the data file can be allocated in memory before storing the data in the data file. The specific implementation is as follows:

[0086] Determine the amount of data in the data file; allocate at least one memory block in the memory space based on the amount of data, and form a memory object corresponding to the target transaction from at least one memory block.

[0087] Specifically, data volume refers to the size of the memory space occupied by the data contained in the data file, usually expressed in bytes; correspondingly, a memory block is a storage unit for storing data in the data file. A memory block can contain multiple data blocks for storing data; a memory object is composed of at least one memory block corresponding to the data file.

[0088] Based on this, the amount of data corresponding to the data file is calculated. At least one memory block corresponding to the data amount is allocated in memory space. This memory block forms the memory object corresponding to the target transaction, and the memory object is used to store all the data in the data file. Alternatively, the data in the data file can be grouped according to the amount of data that the memory blocks in memory space can store. Then, based on the number of groups in the data file, memory blocks corresponding to the number of groups are allocated in memory space, thereby storing each group of data separately in memory blocks.

[0089] Continuing with the previous example, we calculate the amount of data in the data file corresponding to transaction 1, estimate the number of memory blocks needed to store the data in the data file, and then allocate the corresponding number of memory blocks in the memory space. We can also calculate the number of data fragments contained in the data file, with each data fragment stored in one memory block; the number of memory blocks needed then corresponds to the number of data fragments in the data file.

[0090] In summary, by allocating at least one memory block in the memory space based on the amount of data in the data file, and forming a memory object from at least one memory block, the memory blocks can be allocated in sequence, thus avoiding excessive resource consumption and resource waste.

[0091] Step S206: Establish a mapping relationship between the target transaction, the memory object, and the data file, and store the data in the data file into the memory block contained in the memory object based on the mapping relationship; wherein, the memory block storing the data constitutes a storage link.

[0092] Specifically, after determining the data file corresponding to the target transaction in the relational database and the memory object corresponding to the target transaction in the memory space, a mapping relationship can be established between the target transaction, the memory object, and the data file. Based on the mapping relationship, the data in the data file is stored in the memory block contained in the memory object. The memory blocks storing the data constitute a storage link. In this embodiment, the mapping relationship refers to the pointing relationship between the target transaction and the memory object, and between the memory object and the data file. That is, the target transaction, the memory object, and the data file are connected by "pointers" to facilitate the subsequent storage of data in the data file into the memory object based on the mapping relationship. A storage link is a link composed of multiple memory blocks in the memory object connected end to end. In the storage link, the data in the data file is stored in the memory block of the storage link according to the storage order of the data in the data file, thereby realizing the ordered storage of data.

[0093] Based on this, after determining the data file corresponding to the target transaction in the relational database and the memory object corresponding to the target transaction in the memory space, a mapping relationship is established between the target transaction, the memory object, and the data file according to the mapping relationship establishment strategy. Based on the established mapping relationship, the data in the data file is stored sequentially into the memory blocks contained in the memory object. The memory blocks storing the data form a storage link according to the order in which the data is stored in the data file. The storage blocks contained in the storage link have a link relationship. The target transaction is linked with the starting memory block and the ending memory block contained in the storage link.

[0094] In practical applications, establishing a mapping relationship between a target transaction, a memory object, and a data file can involve establishing a mapping relationship between the target transaction and the memory object, and also establishing a mapping relationship between the memory object and the data file. When storing data from the data file into memory blocks contained in the memory object based on this mapping relationship, since the data in the data file may not fit entirely into a single memory block, it is necessary to store the data from the data file into multiple memory blocks within the memory object. During storage, the first memory block is determined within the memory object, and the data from the data file is stored into this first memory block according to the data storage order. If the first memory block is full, the next memory block is determined within the memory object, and the data from the data file that needs to be stored is stored into the next memory block, until all the data in the data file is stored in the memory object. The storage link composed of memory blocks in the memory object is determined according to the memory block selection order during data storage. The starting transaction index in the target transaction points to the first memory block in the storage link, and the ending index points to the last memory block in the storage link.

[0095] Furthermore, considering that a memory object defined in the memory space contains at least one memory block, and since memory blocks can be reused, the multiple memory blocks allocated are generally not contiguous. Therefore, when storing data from the data file into memory blocks, they can be written sequentially and links can be established between adjacent memory blocks to facilitate subsequent data retrieval. The specific implementation is as follows:

[0096] In the memory object, the i-th memory block is determined. Based on the mapping relationship, the data not stored in the data file is stored in the i-th memory block, where i starts from 1 and is a positive integer. When the i-th memory block is full and the data file contains unstored data, i is incremented sequentially, and the step of storing the unstored data in the data file into the i-th memory block based on the mapping relationship is executed. Until the data file no longer contains unstored data, the step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link is executed to execute the target transaction.

[0097] Based on this, a memory block is randomly selected from the multiple memory blocks contained in the memory object as the i-th memory block. Based on the pre-established mapping relationship between the target transaction, the memory object, and the data file, data not yet stored in the data file is stored in the i-th memory block until the i-th memory block is full. The value of i starts from 1 and is a positive integer. When the i-th memory block is full and the data file still contains unstored data, i increments sequentially, and data not yet stored in the data file is stored in the (i+1)-th memory block based on the mapping relationship. This process continues until the data file no longer contains unstored data, indicating that all data in the data file has been stored in the memory block. After determining the (i+1)-th memory block corresponding to the i-th memory block, a link can be established between the i-th and (i+1)-th memory blocks. When data reading is required, the target data corresponding to the target transaction is read from the memory blocks contained in the memory object based on the storage link formed by the sequential arrangement and linking of the memory blocks, for the execution of the target transaction.

[0098] Furthermore, during data storage, links between memory blocks can be established based on the index information of the memory blocks. Specifically, the nodes corresponding to memory blocks in the storage link have a linked storage relationship. The index information of the memory block storing data includes a tag index item, a status index item, a data index item, a previous association index item, and a subsequent association index item. Among them, two adjacent memory blocks in the storage link are linked through the previous association index item and the subsequent association index item.

[0099] Based on this, the i-th memory block is determined in the memory object, and a link is established between the starting transaction item of the target transaction and the tag index item of the i-th memory block, as well as a link is established between the ending transaction item of the target transaction and the tag index item of the i-th memory block. Based on the mapping relationship, the data that has not been stored in the data file is stored in the i-th memory block. When the i-th memory block is full and the data file contains data that has not been stored, the (i+1)-th memory block is determined in the memory object, the link between the ending transaction item of the target transaction and the tag index item of the i-th memory block is canceled, a link is established between the ending transaction item of the target transaction and the tag index item of the (i+1)-th memory block, a link is established between the subsequent associated index item of the i-th memory block and the tag index item of the (i+1)-th memory block, and a link is established between the tag index item of the i-th memory block and the preceding associated index item of the (i+1)-th memory block, thereby realizing the establishment of the link between the i-th memory block and the (i+1)-th memory block. This process continues until all the data in the data file is stored in the memory blocks, and the memory blocks that have stored the data form a storage link.

[0100] Following the example above, Figure 3a This diagram illustrates a storage link construction method for data storage according to an embodiment of this specification, where a transaction processing method is applied to data storage. Figure 3a As shown in (a), when there are 3 memory blocks requested, and the memory block tag indexes are 01, 03 and 06 respectively, the memory block with tag index 01 is selected as the starting memory block. A link is established between the start flag of the target transaction 001 and the tag index of the memory block with tag index 01, and a link is established between the end flag of the target transaction 001 and the tag index of the memory block with tag index 01.

[0101] In the data file, determine the data to be stored, 'a', and store it sequentially into the memory block marked with index 01 until the memory block marked with index 01 is full. Then, select the memory block marked with index 03 from the three allocated memory blocks that has not yet stored data. Establish a link between the memory blocks marked with index 01 and index 03, with the subsequent associated index entry of the memory block marked with index 01 pointing to the associated index entry of the memory block marked with index 03, and the preceding associated index entry of the memory block marked with index 03 pointing to the associated index entry of the memory block marked with index 01. Store the data 'b' that has not yet been stored in the data file into the memory block marked with index 03. Continue in this manner until all data in the data file is stored in the memory blocks. The memory block marked with index 06 is designated as the last memory block, and a link is established between the termination flag of the target transaction 001 and the preceding associated index entry of the memory block marked with index 06.

[0102] In summary, storage links are generated during the storage of data in data files, thereby achieving orderly storage of data in the data files and improving data reading efficiency during subsequent data retrieval.

[0103] Step S208: Based on the storage link, read the target data corresponding to the target transaction from the memory block contained in the memory object, and use it to execute the target transaction.

[0104] Specifically, after establishing the mapping relationship between the target transaction, the memory object, and the data file, and storing the data from the data file into the memory block contained in the memory object based on the mapping relationship, the target data corresponding to the target transaction can be read from the memory block contained in the memory object based on the storage link. The target data is the data read from the memory block contained in the memory object. The target data can be all the data in the data file or a part of the data in the data file.

[0105] Based on this, after establishing the mapping relationship between the target transaction, the memory object, and the data file, and storing the data from the data file into the memory block contained in the memory object based on the mapping relationship, when reading the data corresponding to the target transaction, the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the storage link, for the execution of the target transaction. During data reading, the first memory block in the storage link is determined, and the data stored in the first memory block is read. Then, the next memory block in the storage link linked to the first memory block is determined and its data is read, until all the data corresponding to the storage link has been read.

[0106] In practical applications, when rolling back Oracle database redo log records, a stack-like approach is used, meaning that the write and rollback order is strictly consistent, i.e., first-in-last-out (LIFO) or last-in-first-out (LIFO). Based on this characteristic, this embodiment uses direct modification of metadata information when handling rollbacks, i.e., directly modifying the data in the memory block of the memory object, without needing to operate on the actual data in the data file, thereby improving efficiency.

[0107] Furthermore, during data reading, considering that random access cannot guarantee the continuity of data reading, and since the storage link is composed of memory blocks contained in memory objects, and the data in the data file is also stored according to the arrangement order of the memory blocks in the storage link, in order to ensure that the read data is in the same order as the data in the data file, it is necessary to determine the arrangement order of the memory blocks in the storage link during data reading. The specific implementation is as follows:

[0108] The memory block arrangement order is determined based on the storage link; the target data corresponding to the target transaction is read from the memory blocks contained in the memory object according to the memory block arrangement order.

[0109] Therefore, the memory block arrangement order refers to the linking order between memory blocks in a storage link composed of memory blocks. Since the target data corresponding to the target transaction is stored in memory blocks in the storage link, and the target data has a storage order, when reading the target data corresponding to the target transaction, the arrangement order of the memory blocks in the storage link is first determined. Based on the arrangement order of the memory blocks in the storage link, the target data corresponding to the target transaction is read from the memory blocks contained in the memory object. At this time, the read target data corresponds to the data in the data file.

[0110] For example, such as Figure 3a As shown in (b), target transaction 04001 corresponds to the storage link consisting of memory blocks 01, 04, and 12; target transaction 04002 corresponds to the storage link consisting of memory blocks 02 and 03; and target transaction 04003 corresponds to the storage link consisting of memory blocks 05 and 06. During data reading, the data is read according to the order of the memory blocks in the storage link corresponding to each target transaction, thus ensuring that the order of the acquired data is the same as the data storage order in the data file. That is, data R0-R5 in memory block 01, data R10-R15 in memory block 04, and data R20-R25 in memory block 12 corresponding to target transaction 04001 are read until the data reading of each target transaction is completed.

[0111] In summary, by reading target data from the memory blocks contained in the memory object based on the arrangement order of memory blocks in the storage link, the accuracy of target data reading is ensured. Sequential reading of data stored in the memory blocks contained in the memory object improves the order of data reading, thereby facilitating the execution of downstream services.

[0112] Furthermore, prolonged occupation of memory blocks can lead to unnecessary resource waste. Therefore, once the data stored in a memory block has been read or is in a useless state, the memory block can be released, thereby achieving memory block reuse. The specific implementation is as follows:

[0113] Once the target transaction is completed, the memory block in the memory object is released.

[0114] Based on this, when the target transaction is completed, it means that the memory object corresponding to the target transaction no longer needs to store the data in the data file corresponding to the target transaction. At this time, the memory block contained in the memory object occupied by the data file can be released and returned to the memory space for other transactions to apply for and use, thereby achieving the purpose of memory block reuse and breaking the mapping relationship between the target transaction, the memory object and the data file.

[0115] Continuing with the previous example, the target transaction can be data synchronization, data migration, data backup, or it can be a transaction that drives downstream business operations by acquiring data, such as performing real-time calculations, statistics, and analysis on the acquired data. Once the target transaction is completed, memory blocks 01, 03, and 06 occupied by the target transaction can be released.

[0116] In summary, once the target transaction is completed, the memory blocks in the memory object are released, thereby enabling memory block reuse, reducing performance overhead, and improving resource utilization.

[0117] Furthermore, when handling rollbacks, considering that the transaction record table corresponding to the target transaction contains a large number of transaction records, each transaction record can be analyzed separately and then merged to update the transaction record table. Data can then be read based on the updated transaction record table. The specific implementation is as follows:

[0118] The transaction records contained in the transaction record table corresponding to the target transaction are merged, and the target transaction record table is determined based on the merging result; the target data corresponding to the target transaction record table is read from the memory block contained in the memory object based on the storage link.

[0119] Specifically, the transaction record table is the table corresponding to the target transaction and stores the operation records corresponding to the transaction. In addition to storing the records of data that have been committed normally, the transaction record table also stores the rollback records (undo records). Merging refers to the merging operation performed on the records in the transaction record table corresponding to the target transaction, including the offsetting operation of the data committed normally and its corresponding rollback records.

[0120] Based on this, the transaction record table corresponding to the target transaction is determined. Different types of transaction records contained in the transaction record table corresponding to the target transaction are merged, and the target transaction record table is determined based on the merging result. The target data corresponding to the target transaction record table is read from the memory block contained in the memory object based on the storage link.

[0121] Following the example above, Figure 3b This diagram illustrates a transaction record table update in a transaction processing method according to an embodiment of this specification, as shown below. Figure 3bAs shown, the transaction record table records information such as sequence number, transaction identifier, data row number, split identifier, operation, and rollback. The nine records stored in the transaction record table are merged. XR represents an undo operation, the purpose of which is to undo the previous transaction record XA closest to XR, canceling them out pairwise. Therefore, according to the arrow, transaction record 101-XA cancels out its closest transaction record 101-XR, transaction record 101-XA cancels out its transaction record 102-XR, and transaction record 102-XA cancels out its closest transaction record 102-XR. By merging the transaction records in the transaction record table, transaction record 100-XA can be obtained, and the data corresponding to this transaction record can be read as the target data.

[0122] In summary, by uniformly merging the transaction records contained in the transaction record table, and then reading the target data corresponding to the target transaction record table from the memory block contained in the memory object based on the storage link, the efficiency of reading the target data is improved.

[0123] Furthermore, in addition to merging the transaction records contained in the transaction record table corresponding to the target transaction, the transaction records can also be processed one by one, as specifically implemented as follows:

[0124] Determine the j-th transaction record in the transaction record table of the target transaction; determine whether the j-th transaction record is a rollback record; if yes, update the transaction record table based on the j-th transaction record, use the updated transaction record table as the transaction record table, increment j sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction; if no, determine the j-th data corresponding to the j-th transaction record in the memory block contained in the memory object based on the storage link, increment j sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction; until j increments to k, use the determined data as the target data, where j starts from 1 up to k and is a positive integer, and k is the number of transaction records in the transaction record table.

[0125] Based on this, the rollback record is the same as the revert record. The process begins by determining the j-th transaction record in the target transaction's transaction record table; then determining if the j-th transaction record is a rollback record. If it is, the j-th transaction record cannot be executed, and its preceding transaction record will be undone. The transaction record table is updated based on the j-th transaction record, deleting its preceding transaction record. The updated transaction record table is then used as the target transaction record table. The next step is to determine the (j+1)-th transaction record in the target transaction's transaction record table and check if it is a rollback record. If it is not a rollback record, the j-th transaction record can be executed, meaning the data corresponding to it can be committed. The process involves determining the j-th data corresponding to the j-th transaction record in the memory block contained in the memory object based on the storage link, and then determining the (j+1)-th transaction record in the target transaction's transaction record table. The j-th data is used to execute the target transaction, enabling data deletion, modification, and other operations. This process continues until j increments to k, and the determined data is used as the target data.

[0126] Continuing with the previous example, the first transaction record is identified in the transaction record table of the target transaction. It is then determined whether the first transaction record is a rollback record. If it is, it means the first transaction record cannot be executed, and the preceding transaction record will be undone. The transaction record table is updated based on the first transaction record, deleting the preceding transaction record. The updated transaction record table is then used as the target transaction record table. The second transaction record is then identified in the target transaction record table, and its rollback status is further determined. If the first transaction record is not a rollback record, it means it can be executed, meaning the data corresponding to it can be committed. Based on the storage link, the first data corresponding to the first transaction record is identified in the memory block contained in the memory object. The second transaction record is then identified in the target transaction record table. This first data is used to execute the target transaction, enabling data deletion, modification, and other operations. This process continues until all transaction records in the transaction record table have been processed and the target data is retrieved.

[0127] In summary, by processing each transaction record individually, the accuracy and completeness of the target data can be improved.

[0128] Furthermore, when handling rollback, considering the possibility that all data stored in a memory block within the storage link may be rolled back, the memory block can be released after all data stored in it has been rolled back. The specific implementation is as follows:

[0129] If the transaction record is a rollback record, the terminating memory block corresponding to the rollback record is determined in the storage link, and the record value of the data record index in the terminating memory block is updated; if the updated record value is less than or equal to zero, the preceding memory block corresponding to the terminating memory block is determined based on the storage link, and the terminating memory block is released; the storage link is updated according to the release result and the preceding memory block, and the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the updated storage link.

[0130] Based on this, a stack-like approach is adopted when performing transaction rollback, meaning the rollback is performed in the reverse order of data writing. The last memory block in the storage link is determined, and the last transaction record in the transaction record table is identified. If the last transaction record is a rollback record, the memory block corresponding to the rollback record in the storage link is designated as the termination memory block. The record value of the data record index in the termination memory block is decremented. If the updated record value is less than or equal to zero, the preceding memory block corresponding to the termination memory block is determined based on the storage link, and the termination memory block is released. The storage link is then updated, and the target data corresponding to the target transaction is read from the memory blocks contained in the memory object based on the updated storage link.

[0131] Continuing with the previous example, the memory blocks in the storage link are arranged in the order of memory block 01, memory block 03, and memory block 06. During transaction rollback, the rollback is performed in the reverse order of data writing. The last memory block in the storage link is memory block 06. The transaction record table contains 10 records. Reading the 10th record, if it is a rollback record, decrement the record value (records) in memory block 06. If the decremented value is less than or equal to zero, it means that memory block 06 no longer contains the data corresponding to the target transaction, and memory block 06 can be released. At this point, the storage link only contains memory blocks 01 and 03. The records in the transaction record table are then read and processed again until the transaction rollback is complete. The updated data from the transaction record table is then read as the target data.

[0132] In summary, by establishing a mapping relationship between the target transaction, the memory object, and the data file, and then storing the data from the data file sequentially into the memory block contained in the memory object based on this mapping relationship, ordered data writing is achieved, avoiding the performance overhead of random writes. During data reading, the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the storage link, achieving ordered data reading, reducing the number of file bytes read, and improving data reading efficiency. Therefore, in mixed read / write scenarios, read / write efficiency is improved while performance overhead is reduced.

[0133] The following is in conjunction with the appendix Figure 4 Taking the application of the transaction processing method provided in this specification in data synchronization as an example, the transaction processing method will be further explained. Among other things, Figure 4 A flowchart illustrating a transaction processing method for data synchronization according to an embodiment of this specification is shown, specifically including the following steps:

[0134] Step S402: In response to the data synchronization request, read the target log record stored in the database log of the relational database.

[0135] Oracle databases use redo logs to ensure that database transactions can be replayed, enabling data recovery after a failure. When performing CDC data synchronization based on redo logs, a complete analysis of transactions is required, including multi-block merging and data rollback (undoing corresponding rows). During data synchronization, log records in the Oracle database logs are read.

[0136] Step S404: Parse the target log record and determine the target transaction based on the parsing results.

[0137] Step S406: Select at least one file slot based on the data volume of the data file, and form a data storage object corresponding to the target transaction from at least one file slot.

[0138] If a data file contains 100MB of data, it can be divided into 10 equal parts, with each part (file offset) corresponding to a file slot. The 10 file slots corresponding to the data file constitute a data storage object.

[0139] Step S408: Determine the i-th file slot in the data storage object, and store the data that has not been stored in the data file into the i-th file slot, where i starts from 1 and is a positive integer.

[0140] In step S410, if the i-th file slot is full and the data file contains unstored data, i is incremented sequentially, and step S408 is executed.

[0141] Step S412: Data storage is completed if the data file does not contain any data that has not been stored.

[0142] The file slot information is located using the transaction number (xid). In the data storage object consisting of 10 file slots, the first unused file slot is found, and the mapping information between the new transaction and the file slot is established. The information of the current transaction is obtained. If the transaction's `first_slot` cell points to null, both the `first_slot` and `last_slot` cells are set to point to the slot of the first unused file slot until this file slot is full. Then, the next unused file slot is found in the data storage object, and the transaction's `last_slot` is set to point to that file slot. The file mapping offset is calculated, and the data file is mapped to process memory using `Mmap`. Data from the current Redo log is copied to the mapped space.

[0143] Mmap maps data files to the process's address space, establishing a one-to-one correspondence between the file's disk address and a segment of virtual address in the process's virtual address space. This accelerates data read and write efficiency, and ensures rapid data recovery when the process exits abnormally, guaranteeing the data reliability of the entire caching system.

[0144] Step S414: Read the target data corresponding to the target transaction from the file slots contained in the data storage object according to the file slot arrangement order in the storage link.

[0145] Ten file slots form a data storage object, and each file slot is linked sequentially to form a bidirectional storage link, which facilitates data reading based on the storage link.

[0146] Step S416: Determine the j-th transaction record in the transaction record table of the target transaction;

[0147] Oracle database redo logs use a stack-like approach for rollback, meaning the write and rollback order is strictly consistent (Last-In-First-Out, Last-In-First-Out). Based on this characteristic, when processing rollbacks, data is modified directly without needing to manipulate the actual data in the cache file, achieving extremely high efficiency.

[0148] In practical applications, the file slot is determined by the transaction number, which in turn determines the file slot at the end of the data storage object corresponding to the transaction, i.e., the file slot pointed to by the transaction's last_slot unit.

[0149] Step S418: Determine whether the j-th transaction record is a rollback record; if yes, proceed to step S420; if no, proceed to step S422.

[0150] Step S420: Update the transaction record table based on the j-th transaction record, and use the updated transaction record table as the transaction record table, with j incremented sequentially.

[0151] Step S422: Based on the storage link, determine the j-th data corresponding to the j-th transaction record in the file slot contained in the data storage object, where j is incremented sequentially.

[0152] Step S424: Determine if j has incremented to k; if yes, proceed to step S426; if no, proceed to step S416.

[0153] Step S426: Use the determined data as the target data, where j starts from 1 and takes a value up to k and is a positive integer, and k is the number of transaction records in the transaction record table.

[0154] Step S428: If the transaction record is a rollback record, determine the termination file slot corresponding to the rollback record in the storage link, and update the record value of the data record index in the termination file slot.

[0155] When the transaction record is a rollback record, the data count in the file slot, m_records, is decremented by 1. If m_records is less than or equal to 0 after decrementing by 1, the transaction's pointing information is modified, the current file slot is released, and the last_slot unit in the transaction points to the previous file slot of the current file slot.

[0156] In step S430, if the updated record value is less than or equal to zero, determine the preceding file slot corresponding to the termination file slot based on the storage link, and release the termination file slot.

[0157] Step S432: Update the storage link based on the release result and the preceding file slot, and read the target data corresponding to the target transaction from the file slot contained in the data storage object based on the updated storage link to perform data synchronization.

[0158] One embodiment of this specification uses Mmap technology to optimize file I / O. By using the Slot concept, it ensures that Redo log data can be written in an orderly manner to a certain extent, avoiding the performance overhead caused by random file I / O. At the same time, it uses metadata to locate data files, similar to database indexing technology, which greatly reduces the number of file bytes read when scanning data by transaction, thereby improving scanning efficiency.

[0159] In summary, one embodiment of this specification establishes a mapping relationship between the target transaction, the memory object, and the data file, and stores the data from the data file in an orderly manner into the memory block contained in the memory object based on this mapping relationship. This achieves ordered data writing and avoids the performance overhead caused by random writing. During data reading, the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the storage link, achieving ordered data reading, reducing the number of file bytes read, and improving data reading efficiency. Therefore, in mixed read and write operations, read and write efficiency is improved while performance overhead is reduced.

[0160] Corresponding to the above method embodiments, this specification also provides embodiments of a transaction processing apparatus. Figure 5 A schematic diagram of a transaction processing apparatus according to an embodiment of this specification is shown. The transaction processing apparatus provided in this embodiment is applied to a database management terminal, which manages a relational database. Figure 5 As shown, the device includes:

[0161] The first determining module 502 is configured to determine the target transaction based on the database logs of the relational database;

[0162] The second determining module 504 is configured to determine the data file corresponding to the target transaction in the relational database and to determine the memory object corresponding to the target transaction in the memory space.

[0163] Storage module 506 is configured to establish a mapping relationship between the target transaction, the memory object, and the data file, and to store data from the data file into a memory block contained in the memory object based on the mapping relationship; wherein the memory block storing the data constitutes a storage link;

[0164] The reading module 508 is configured to read the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link, and to execute the target transaction.

[0165] In an optional embodiment, the first determining module 502 is further configured to:

[0166] In response to a data processing request, log records stored in the database log of the relational database are read, and the target log record is determined based on the read results; the target log record is parsed, and the target transaction is determined based on the parsing results.

[0167] In an optional embodiment, the second determining module 504 is further configured to:

[0168] Determine the amount of data in the data file; allocate at least one memory block in the memory space based on the amount of data, and form a memory object corresponding to the target transaction from at least one memory block.

[0169] In an optional embodiment, the storage module 506 is further configured to:

[0170] In the memory object, the i-th memory block is determined. Based on the mapping relationship, the data not stored in the data file is stored in the i-th memory block, where i starts from 1 and is a positive integer. When the i-th memory block is full and the data file contains unstored data, i is incremented sequentially, and the step of storing the unstored data in the data file into the i-th memory block based on the mapping relationship is executed. Until the data file no longer contains unstored data, the step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link is executed to execute the target transaction.

[0171] In an optional embodiment, the storage module 506 is further configured to:

[0172] The nodes corresponding to memory blocks in the storage link have a linked storage relationship. The index information of the memory block storing data includes a tag index item, a status index item, a data index item, a previous association index item, and a subsequent association index item.

[0173] In this storage link, two adjacent memory blocks are linked through the preceding association index and the following association index.

[0174] In an optional embodiment, the reading module 508 is further configured to:

[0175] The memory block arrangement order is determined based on the storage link; the target data corresponding to the target transaction is read from the memory blocks contained in the memory object according to the memory block arrangement order.

[0176] In an optional embodiment, the reading module 508 is further configured to:

[0177] Once the target transaction is completed, the memory block in the memory object is released.

[0178] In an optional embodiment, the reading module 508 is further configured to:

[0179] The transaction records contained in the transaction record table corresponding to the target transaction are merged, and the target transaction record table is determined based on the merging result; the target data corresponding to the target transaction record table is read from the memory block contained in the memory object based on the storage link.

[0180] In an optional embodiment, the reading module 508 is further configured to:

[0181] Determine the j-th transaction record in the transaction record table of the target transaction; determine whether the j-th transaction record is a rollback record; if yes, update the transaction record table based on the j-th transaction record, use the updated transaction record table as the transaction record table, increment j sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction; if no, determine the j-th data corresponding to the j-th transaction record in the memory block contained in the memory object based on the storage link, increment j sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction; until j increments to k, use the determined data as the target data, where j starts from 1 up to k and is a positive integer, and k is the number of transaction records in the transaction record table.

[0182] In an optional embodiment, the reading module 508 is further configured to:

[0183] If the transaction record is a rollback record, the terminating memory block corresponding to the rollback record is determined in the storage link, and the record value of the data record index in the terminating memory block is updated; if the updated record value is less than or equal to zero, the preceding memory block corresponding to the terminating memory block is determined based on the storage link, and the terminating memory block is released; the storage link is updated according to the release result and the preceding memory block, and the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the updated storage link.

[0184] In summary, one embodiment of this specification establishes a mapping relationship between the target transaction, the memory object, and the data file, and stores the data from the data file in an orderly manner into the memory block contained in the memory object based on this mapping relationship. This achieves ordered data writing and avoids the performance overhead caused by random writing. During data reading, the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the storage link, achieving ordered data reading, reducing the number of file bytes read, and improving data reading efficiency. Therefore, in mixed read and write operations, read and write efficiency is improved while performance overhead is reduced.

[0185] The above is an illustrative scheme of a transaction processing apparatus according to this embodiment. It should be noted that the technical solution of this transaction processing apparatus and the technical solution of the above-described transaction processing method belong to the same concept. For details not described in detail in the technical solution of the transaction processing apparatus, please refer to the description of the technical solution of the above-described transaction processing method.

[0186] Figure 6A structural block diagram of a computing device 600 according to an embodiment of this specification is shown. The components of the computing device 600 include, but are not limited to, a memory 610 and a processor 620. The processor 620 is connected to the memory 610 via a bus 630, and a database 650 is used to store data.

[0187] The computing device 600 also includes an access device 640, which enables the computing device 600 to communicate via one or more networks 660. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 640 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.

[0188] In one embodiment of this specification, the above-described components of the computing device 600 and Figure 6 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 6 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.

[0189] The computing device 600 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 600 can also be a mobile or stationary server.

[0190] The processor 620 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the transaction processing method described above.

[0191] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the transaction processing method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the transaction processing method described above.

[0192] An embodiment of this specification also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the steps of the transaction processing method described above.

[0193] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the transaction processing method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the transaction processing method described above.

[0194] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0195] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.

[0196] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this specification is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this specification. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this specification.

[0197] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0198] The preferred embodiments disclosed above are merely illustrative of this specification. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. These embodiments have been selected and specifically described in this specification to better explain the principles and practical applications of this specification, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.

Claims

1. A transaction processing method, characterized in that, It is applied to a database management terminal, which is used to manage relational databases, including: The target transaction is determined based on the database logs of the relational database; The data file corresponding to the target transaction is determined in the relational database, and the memory object corresponding to the target transaction is determined in the memory space; Establish a mapping relationship between the target transaction, the memory object, and the data file; In the memory object, the i-th memory block is determined, and the data not stored in the data file is stored in the i-th memory block based on the mapping relationship. When the i-th memory block is full and the data file contains unstored data, i is incremented sequentially, and the step of storing the unstored data in the data file into the i-th memory block based on the mapping relationship is executed until the data file no longer contains unstored data. Here, i starts from 1 and is a positive integer. The memory blocks storing data form a storage link. The nodes corresponding to the memory blocks in the storage link have a linked storage relationship. The index information of the memory blocks storing data includes a tag index item, a status index item, a data index item, a previous association index item, and a subsequent association index item. Based on the storage link, the target data corresponding to the target transaction is read from the memory block contained in the memory object, and used to execute the target transaction.

2. The method according to claim 1, characterized in that, The determination of the target transaction based on the database logs of the relational database includes: In response to a data processing request, log records stored in the database log of the relational database are read, and the target log record is determined based on the reading result; The target log record is parsed, and the target transaction is determined based on the parsing results.

3. The method according to claim 1, characterized in that, The step of determining the memory object corresponding to the target transaction in the memory space includes: Determine the amount of data in the data file; Based on the amount of data, at least one memory block is requested in the memory space, and the memory object corresponding to the target transaction is composed of at least one memory block.

4. The method according to any one of claims 1-3, characterized in that, Two adjacent memory blocks in the storage link are linked through the preceding association index and the following association index.

5. The method according to claim 1, characterized in that, The step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link includes: The memory block arrangement order is determined based on the storage link; The target data corresponding to the target transaction is read from the memory blocks contained in the memory object according to the memory block arrangement order.

6. The method according to claim 1, characterized in that, After the step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link to execute the target transaction step, it further includes: Once the target transaction is completed, the memory block in the memory object is released.

7. The method according to claim 1, characterized in that, The step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link includes: Merge the transaction records contained in the transaction record table corresponding to the target transaction, and determine the target transaction record table based on the merging result; Based on the storage link, the target data corresponding to the target transaction record table is read from the memory block contained in the memory object.

8. The method according to claim 1, characterized in that, The step of reading the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link includes: Determine the j-th transaction record in the transaction record table of the target transaction; Determine whether the j-th transaction record is a rollback record; If so, update the transaction record table based on the j-th transaction record, use the updated transaction record table as the transaction record table, increment j sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction; If not, based on the storage link, determine the j-th data corresponding to the j-th transaction record in the memory block contained in the memory object, where j is incremented sequentially, and execute the step of determining the j-th transaction record in the transaction record table of the target transaction; Until j increments to k, the determined data is used as the target data, where j starts from 1 and takes a value up to k and is a positive integer, and k is the number of transaction records in the transaction record table.

9. The method according to claim 8, characterized in that, Also includes: In the case that the transaction record is a rollback record, the termination memory block corresponding to the rollback record is determined in the storage link, and the record value of the data record index in the termination memory block is updated. If the updated record value is less than or equal to zero, the preceding memory block corresponding to the terminating memory block is determined based on the storage link, and the terminating memory block is released. The storage link is updated based on the release result and the preceding memory block, and the target data corresponding to the target transaction is read from the memory block contained in the memory object based on the updated storage link.

10. A transaction processing apparatus, characterized in that, It is applied to a database management terminal, which is used to manage relational databases, including: The first determining module is configured to determine the target transaction based on the database logs of the relational database; The second determining module is configured to determine the data file corresponding to the target transaction in the relational database and to determine the memory object corresponding to the target transaction in the memory space. The storage module is configured to establish a mapping relationship between the target transaction, the memory object, and the data file; determine the i-th memory block in the memory object; store unstored data from the data file into the i-th memory block based on the mapping relationship; when the i-th memory block is full and the data file contains unstored data, i increments sequentially, and the step of storing unstored data from the data file into the i-th memory block based on the mapping relationship is executed until the data file no longer contains unstored data. Here, i starts from 1 and is a positive integer; the memory blocks storing data form a storage link; the nodes corresponding to the memory blocks in the storage link have a linked storage relationship; the index information of the memory blocks storing data includes a tag index item, a status index item, a data index item, a previous association index item, and a subsequent association index item. The read module is configured to read the target data corresponding to the target transaction from the memory block contained in the memory object based on the storage link, and to execute the target transaction.

11. A computing device, characterized in that, It includes a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute the computer-executable instructions to implement the steps of the transaction processing method according to any one of claims 1 to 9.

12. A computer-readable storage medium storing computer instructions, characterized in that, When executed by the processor, this instruction implements the steps of the transaction processing method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Spatial data engine and method applying management spatial data thereof

    CN101639848A

  • Computer method and apparatus for file system block allocation with multiple redo

    US6185663B1