Transaction log segment file processing method, storage medium and equipment

By performing compression and marking processing according to the conditions of log pages in the KingbaseES database, the problem of compression and decompression of large XLOG logs is solved, and the reading accuracy of the database and system performance are improved.

CN118626461APending Publication Date: 2024-09-10CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310256867.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-08
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

In the KingbaseES database, the XLOG log volume is large, and the existing technology can only compress part of the data. The length after compression is inconsistent, which makes decompression difficult and reduces the reading accuracy.

Method used

By determining whether the log page is a log page to be compressed during the writing process of the transaction log, and performing compression operations when certain conditions are met, including determining whether the log page is empty or full, reducing the compression frequency, and within the compressed range. Write compression flags to distinguish between compressed and uncompressed intervals to improve read accuracy.

Benefits of technology

The compression frequency is reduced, the accuracy of compression operations and reading accuracy are improved, and the overall performance of the system is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626461A
    Figure CN118626461A
Patent Text Reader

Abstract

The invention relates to a database technology, in particular to a transaction log segment file processing method, a storage medium and equipment. The transaction log segment file comprises a plurality of log pages, and each log page comprises at least part of transaction logs. The transaction log segment file processing method comprises the steps of obtaining a log page in a writing process of a transaction log; judging whether the log page is a to-be-compressed log page or not; and if yes, performing compression operation on the to-be-compressed log page. According to the processing method of the transaction log segment file, the transaction log segment file is compressed with the log page as the compression granularity, the problem that the compression frequency is high due to the fact that the compression granularity is too small is avoided, the compression frequency is effectively reduced, and the overall performance of a system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to database technology, and in particular to a method, storage medium and device for processing transaction log segment files. Background Art

[0002] In the PostgreSQL database (KES database for short), the transaction log actually refers to the XLOG log. In some scenarios, the XLOG log volume is large, and a large number of XLOG logs will occupy a lot of bandwidth. Therefore, in these scenarios, the XLOG log needs to be compressed to reduce the XLOG log volume.

[0003] However, in the current XLOG log writing process of the KES database, only part of the data (pagedata) in the XLOG log can be compressed, and the compression frequency is relatively high. In addition, since the XLOG log contents in the XLOG log file are stored at a fixed position, and the length of the XLOG log after compression is inconsistent with the length of the XLOG log before compression, the information recording the XLOG log position is no longer available. Therefore, in the process of reading the compressed XLOG log, the existing XLOG log processing method has a high decompression frequency and is difficult to accurately decompress the XLOG log, which reduces the accuracy of the database's reading of the XLOG log. Summary of the invention

[0004] In view of the above problems, a method, storage medium and device for processing transaction log segment files are proposed to overcome the above problems or at least partially solve the above problems.

[0005] An object of the present invention is to provide a method for processing transaction log segment files, which can reduce compression frequency.

[0006] A further object of the present invention is to improve the accuracy of obtaining log pages to be compressed, so as to improve the accuracy of the compression operation.

[0007] Another further object of the present invention is to improve the convenience of identifying compressed log pages.

[0008] In particular, the present invention provides a method for processing a transaction log segment file, the transaction log segment file comprising a plurality of log pages, each log page comprising at least a portion of a transaction log; and the processing method comprises:

[0009] In the transaction log writing process, get the log page;

[0010] Determine whether the log page is a log page to be compressed;

[0011] If so, compress the log page to be compressed.

[0012] Optionally, the step of determining whether the log page is a log page to be compressed includes:

[0013] Determine whether the log page is an empty page;

[0014] If it is an empty page, it is determined that the log page is not a log page to be compressed;

[0015] If it is not an empty page, determine whether the log page is full;

[0016] If it is full, the log page is determined to be a log page to be compressed;

[0017] If it is not full, it is determined that the log page is not a log page to be compressed.

[0018] Optionally, the compressed log page includes an uncompressed interval and a compressed interval, wherein a first preset position for storing a transaction log compression mark is preset in the uncompressed interval; and

[0019] After the step of compressing the log page to be compressed, the processing method further includes:

[0020] A transaction log compression marker is written in a first predetermined position of the compressed log page.

[0021] Optionally, the compressed log page includes a log page header and a data area arranged in sequence; and

[0022] The uncompressed interval is the data area where the log page header is located, and the compressed interval is the data area where the data area is located; and

[0023] After the step of determining whether the log page is a log page to be compressed, the processing method further includes:

[0024] When it is determined that the log page is an empty page, a sequentially arranged log page header and a storage space of a predetermined length are added to the empty page;

[0025] Writing a transaction log compression mark in a first preset position of the added log page header;

[0026] A preset empty page mark is written into a storage space of a predetermined length.

[0027] Optionally, after the step of writing the transaction log compression mark in the first preset position of the compressed log page, the processing method further includes:

[0028] In the transaction log reading process, get the log page;

[0029] Determine whether the log page is a log page to be decompressed;

[0030] If so, decompress the log page to be decompressed.

[0031] Optionally, the step of determining whether the log page is a log page to be decompressed includes:

[0032] Obtaining whether the data in the first preset position of the log page is a transaction log compression mark;

[0033] If it is a transaction log compression mark, determine whether the log page is an empty page;

[0034] If it is an empty page, it is determined that the log page is not a log page to be decompressed;

[0035] If it is not an empty page, it is determined that the log page is a log page to be decompressed.

[0036] Optionally, the step of compressing the log page to be compressed includes:

[0037] The data area of ​​the log page to be compressed is used as the compression granularity, and the log page to be compressed is compressed.

[0038] Optionally, after the step of performing a compression operation on the log page to be compressed, the processing method further includes:

[0039] Writes compressed log pages to disk.

[0040] According to another aspect of the present invention, a machine-readable storage medium is provided, on which a machine executable program is stored. When the machine executable program is executed by a processor, any of the above transaction log segment file processing methods is implemented.

[0041] According to another aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, and the processor implements any of the above-mentioned transaction log segment file processing methods when executing the machine executable program.

[0042] The transaction log segment file processing method of the present invention obtains log pages in the writing process of the transaction log, determines whether the log page is a log page to be compressed, and if the log page is a log page to be compressed, compresses the log page to be compressed, thereby realizing compression of the transaction log segment file with the log page as the compression granularity, reducing the compression frequency and improving the overall performance of the system.

[0043] Furthermore, the transaction log segment file processing method of the present invention judges whether the log page is an empty page and whether the log page is full in turn, and only determines that the log page is a log page to be compressed when the log page is not an empty page and is full, thereby improving the accuracy of obtaining the log page to be compressed, thereby improving the accuracy of the compression operation.

[0044] Furthermore, the compressed log page in the transaction log segment file processing method of the present invention includes an uncompressed interval and a compressed interval, wherein a first preset position for storing a transaction log compression mark is preset in the uncompressed interval, thereby realizing the regional division of the compressed log page and storing the transaction log compression mark in the data area that does not need to be compressed. On this basis, the transaction log segment file processing method of the present invention also realizes the marking of the compressed log page by writing the transaction log compression mark in the first preset position of the compressed log page after the compression operation is performed on the log page to be compressed, thereby realizing the distinction between the compressed log page and the uncompressed log page, improving the convenience of identifying the compressed log page in the subsequent reading process, and further improving the overall performance of the system.

[0045] Based on the following detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more aware of the above and other objects, advantages and features of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Hereinafter, some specific embodiments of the present invention will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:

[0047] Figure 1 is a flow chart of a method for processing a transaction log segment file according to an embodiment of the present invention;

[0048] Figure 2 It is a flowchart of a transaction log writing process in a method for processing a transaction log segment file according to an embodiment of the present invention;

[0049] Figure 3 is a schematic diagram of the structure of a log page in a method for processing a transaction log segment file according to an embodiment of the present invention;

[0050] Figure 4 is a schematic diagram of the structure of a log page in a method for processing a transaction log segment file according to another embodiment of the present invention;

[0051] Figure 5 is a schematic diagram of the structure of a log page in a method for processing a transaction log segment file according to yet another embodiment of the present invention;

[0052] Figure 6 is a partial structural diagram of a transaction log segment file in a method for processing a transaction log segment file according to an embodiment of the present invention;

[0053] Figure 7is a structural schematic diagram of a log page decompression process in a method for processing a transaction log segment file according to an embodiment of the present invention;

[0054] Figure 8 is a flow chart of a method for processing a transaction log segment file according to another embodiment of the present invention;

[0055] Fig. 9 is a flow chart of a method for processing a transaction log segment file according to yet another embodiment of the present invention;

[0056] Fig.10 is a schematic diagram of the structure of a machine-readable storage medium according to an embodiment of the present invention; and

[0057] Fig.11 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0058] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0059] In order to solve the above technical problem, an embodiment of the present invention proposes a method for processing a transaction log segment file. Figure 1 FIG. 1 is a schematic flow chart of a method for processing a transaction log segment file according to an embodiment of the present invention. Figure 1 As shown, the method for processing a transaction log segment file may generally include:

[0060] Step S102, in the transaction log writing process, obtaining a log page.

[0061] Step S104, determining whether the log page is a log page to be compressed.

[0062] Step S106: decompress the compressed log page according to the length of the compressed data to obtain a decompressed log page.

[0063] The transaction log segment file processing method of this embodiment obtains log pages in the transaction log writing process, determines whether the log pages are log pages to be compressed, and compresses the log pages to be compressed if the log pages are log pages to be compressed. This realizes compression of transaction log segment files with log pages as the compression granularity, reduces compression frequency, and improves the overall performance of the system.

[0064] It should be noted that KingbaseES refers to the Renmin University of China Kingbase database management system KingbaseES, which is a general relational database management system. Those skilled in the art should be able to recognize that in some optional embodiments, the transaction log segment file processing method of the present invention can be applied to the KES database, and in other optional embodiments, the transaction log segment file processing method of the present invention can also be applied to other relational databases.

[0065] For the KES database, the transaction log actually refers to the XLOG log (or WAL log), which records in detail the operation process of the service process on the KES database. The log page actually refers to the XLOG log page, or simply page. In the KES database, the default size of the XLOG log page is usually 8KB, that is, page_size = 8KB. Each XLOG log segment file consists of multiple XLOG log pages of fixed size. If the size of the XLOG log segment file is 16MB and the size of each XLOG log page is 8KB, then an XLOG log segment file contains 2048 XLOG log pages.

[0066] In some embodiments, after the above step S106, the processing method of the present invention may further include the following steps: writing the compressed XLOG log page to the disk. That is, this embodiment selects the "writing the page in the XLOG write cache to the disk stage" as the compression position.

[0067] In order to more clearly illustrate the compression position selected in this embodiment, Figure 2 , further explains the XLOG log writing process.

[0068] Figure 2 FIG. 1 is a flow chart of a transaction log writing process in a method for processing a transaction log segment file according to an embodiment of the present invention. Figure 2 As shown, in this embodiment, the XLOG log writing process may generally include:

[0069] Step S202: Generate XLOG log data. The operation object is the data in a single XLOG log, and does not involve XLOG log pages. Therefore, this stage is not suitable for compressing XLOG log pages.

[0070] Step S204, registering XLOG log data. The operation object is also the data in a single XLOG log, and does not involve XLOG log pages. Therefore, this stage is not suitable for compressing XLOG log pages.

[0071] Step S206, assembling XLOG log data. The operation object is also the data in a single XLOG log, and does not involve XLOG log pages. Therefore, this stage is not suitable for compressing XLOG log pages.

[0072] Step S208: pre-allocate the storage location of the XLOG log in the XLOG log write cache. The operation object is the location information of a single XLOG log, and does not involve the XLOG log page. Therefore, this stage is not suitable for compressing the XLOG log page.

[0073] Step S210: put the data of each part of the XLOG log into a continuous interval. The operation object is also the data in a single XLOG log, and does not involve the XLOG log page. Therefore, this stage is not suitable for compressing the XLOG log page.

[0074] Step S212, copy the XLOG data in the continuous interval to the XLOG write cache. Although this stage involves XLOG log pages, and the pages in the XLOG log write cache correspond one-to-one to the pages in the XLOG log file, since the current stage is within the protection range of the XLOG log write cache insert lock, performing compression operations at this stage will greatly extend the occupancy time of the insert lock and affect performance. In addition, if an XLOG log write cache page is not full, the write cache page is compressed, then the next time the XLOG log write cache is continued to be written, it is necessary to decompress it first, then write new data, and finally compress the XLOG log write cache page. This will cause frequent compression and decompression of the write cache page, seriously affecting performance. On the whole, this stage is also not suitable for compression operations on XLOG log pages.

[0075] Step S214: Write the page containing the XLOG log in the XLOG write cache to the disk file. Considering the following factors, this stage is suitable for compressing the XLOG log:

[0076] 1) This stage involves XLOG log pages, and in the KES database, XLOG log data is written to disk in pages. The XLOG log page can be compressed before being written to disk;

[0077] 2) In some scenarios, the XLOG log is written to disk by a dedicated process (WalWriter). If the XLOG log page is compressed in it, it will not affect other processes.

[0078] 3) In some scenarios, after a process finishes writing an XLOG log, it will proactively write the contents of the current XLOG log to disk. In this case, the pressure of writing to disk and compressing the XLOG log page falls on the process that writes the XLOG log. In such a scenario, the pressure of compressing the XLOG log page is generally dispersed.

[0079] 4) At this stage, KES will ensure that the XLOG logs in the XLOG log page are stored continuously. Therefore, it is easier to determine whether a certain XLOG log write page is full before compression.

[0080] In summary, this embodiment selects "the stage of writing pages in the XLOG write cache to disk" as the compression position.

[0081] In some embodiments, the above step S104 may include the following steps: determining whether the XLOG log page is an empty page; if it is an empty page, determining that the XLOG log page is not an XLOG log page to be compressed; if it is not an empty page, determining whether the XLOG log page is full; if it is full, determining that the XLOG log page is an XLOG log page to be compressed; if it is not full, determining that the XLOG log page is not an XLOG log page to be compressed.

[0082] Furthermore, the step of determining whether the XLOG log page is an empty page can be specifically performed as follows: directly check the page header of the XLOG log page. If the XLOG log segment file is switched, the unused part of the XLOG log segment file will be filled with 0, that is, the unused page of this XLOG log segment file is filled with all 0. Therefore, if a page is filled with all 0, it is considered to be an empty page.

[0083] In addition, the specific judgment process of judging whether the XLOG log page is full is as follows: obtain the end LSN (page_end_lsn) of the current XLOG log page and obtain the LSN (need_flush_to_lsn) to which the current flushing is required; judge whether need_flush_to_lsn is less than page_end_lsn; if so, determine that the XLOG log page is not full; if not, determine that the XLOG log page is full.

[0084] The transaction log segment file processing method of the embodiment of the present invention judges whether the XLOG log page is an empty page and whether the XLOG log page is full in turn, and only when the XLOG log page is not an empty page and is full, determines that the XLOG log page is the XLOG log page to be compressed, thereby improving the accuracy of obtaining the XLOG log page to be compressed, thereby improving the accuracy of the compression operation.

[0085] Figure 3 The diagram is a schematic diagram of the structure of a log page in a method for processing a transaction log segment file according to an embodiment of the present invention. Figure 4 FIG. 1 is a schematic diagram of the structure of a log page in a method for processing a transaction log segment file according to another embodiment of the present invention. Figure 3 and Figure 4 As shown, the XLOG log page to be compressed includes an interval that does not need to be compressed and an interval to be compressed. Correspondingly, the compressed XLOG log page includes an uncompressed interval and a compressed interval.

[0086] In the above embodiment, a first preset position for storing an XLOG log compression mark is preset in the uncompressed interval. In addition, after the above step S106, the processing method of the present invention may further include: writing an XLOG log compression mark in the first preset position of the compressed XLOG log page.

[0087] The compressed XLOG log page in the transaction log segment file processing method of the embodiment of the present invention includes an uncompressed interval and a compressed interval, wherein a first preset position for storing an XLOG log compression mark is preset in the uncompressed interval, so that the compressed XLOG log page is divided into regions, and the XLOG log compression mark is stored in the data region that does not need to be compressed. On this basis, the transaction log segment file processing method of the present invention also writes the XLOG log compression mark in the first preset position of the compressed XLOG log page after the compression operation is performed on the XLOG log page to be compressed, so as to mark the compressed XLOG log page, distinguish the compressed XLOG log page from the uncompressed XLOG log page, improve the convenience of identifying the compressed XLOG log page in the subsequent reading process, and further improve the overall performance of the system.

[0088] In some embodiments, Figure 3 and Figure 4As shown, the XLOG log page to be compressed includes a page header and a data area arranged in sequence, and correspondingly, the compressed XLOG log page includes a page header and a data area arranged in sequence. In the above embodiment, the uncompressed interval is the data area where the page header is located, and the compressed interval is the data area where the data area is located.

[0089] On this basis, the step of performing a compression operation on the XLOG log page to be compressed may include the following steps: taking the data area of ​​the XLOG log page to be compressed as the compression granularity, performing a compression operation on the XLOG log page to be compressed.

[0090] In addition, after the above step S106, the processing method of the present invention may further include: writing an XLOG log compression mark in a first preset position of the page header of the compressed XLOG log page; adding a storage space of a predetermined length that does not need to be compressed between the uncompressed interval and the compressed interval; and writing the length compressed_len of the compressed interval in the storage space of the predetermined length.

[0091] In one embodiment, after the above step S104, the processing method of the present invention may further include: when it is determined that the XLOG log page is an empty page, adding a sequentially arranged page header and a storage space of a predetermined length to the empty page; writing an XLOG log compression mark in a first preset position of the added page header; writing a preset empty page mark in the storage space of a predetermined length. It should be noted that the preset empty page mark may be the length of compressed data of the empty page, compressed_len. Specifically, since the length of the data to be compressed in the empty page is 0, the compressed_len of the empty page is 0.

[0092] Figure 5 FIG. 1 is a schematic diagram of the structure of a log page in a method for processing a transaction log segment file according to another embodiment of the present invention. Figure 5 As shown, the first preset position may be the 4th bit (recorded as XLR_COMPRESS_TOKEN, the first 3 bits have been used) of the "uint16 xlp_info" variable in the page header of the XLOG log page. The XLOG log compression flag may be set to 1.

[0093] On this basis, the step of writing the XLOG log compression mark in the first preset position can be specifically performed as follows: the 4th bit XLR_COMPRESS_TOKEN of the "uint16 xlp_info" variable in the page header is set to 1. Using the above method, the XLOG log compression mark does not need to add additional storage space, reducing space occupancy.

[0094] In some embodiments, the predetermined length may be 4 bytes. That is, 4 bytes are immediately following the page header of the XLOG log page for storing the length compressed_len of the compressed interval in the XLOG log page for subsequent retrieval.

[0095] Figure 6 FIG. 1 is a schematic diagram of a portion of a transaction log segment file in a method for processing a transaction log segment file according to an embodiment of the present invention. Figure 6 As shown, the XLOG log segment file may include a compressed XLOG log page, an uncompressed XLOG log page, and a null page.

[0096] In this embodiment, after the step of writing the XLOG log compression mark in the first preset position of the compressed XLOG log page, the processing method of the present invention may further include the following steps: in the XLOG log reading process, obtaining the XLOG log page; determining whether the XLOG log page is an XLOG log page to be decompressed; if so, decompressing the XLOG log page to be decompressed.

[0097] The transaction log segment file processing method of this embodiment realizes different processing of different XLOG log pages by first determining whether the XLOG log page is an XLOG log page to be compressed in the XLOG log reading process, thereby improving the accuracy of data reading and the overall performance of the system.

[0098] Further, the step of determining whether the XLOG log page is an XLOG log page to be decompressed may include: obtaining whether the data in the first preset position of the XLOG log page is an XLOG log compression mark; if it is an XLOG log compression mark, determining whether the XLOG log page is an empty page; if it is an empty page, determining that the XLOG log page is not an XLOG log page to be decompressed; if it is not an empty page, determining that the XLOG log page is an XLOG log page to be decompressed.

[0099] The transaction log segment file processing method of this embodiment improves the accuracy of obtaining the XLOG log page to be decompressed by sequentially judging whether the XLOG log page is marked and whether the XLOG log page is an empty page in the XLOG log reading process.

[0100] Figure 7 FIG. 1 is a schematic diagram of a log page decompression process in a method for processing a transaction log segment file according to an embodiment of the present invention. Figure 7As shown in the figure, the decompressed XLOG log page includes a page header and a data area.

[0101] In this embodiment, the step of performing a decompression operation on the XLOG log page to be decompressed may include: taking the data area of ​​the XLOG log page to be decompressed as the decompression granularity, and performing a decompression operation on the XLOG log page to be decompressed. Specifically, the data area of ​​the XLOG log page to be decompressed is first decompressed, and the content of the decompressed data area is placed after the page header to obtain a complete decompressed XLOG log page, so as to complete the decompression operation on the XLOG log page to be decompressed.

[0102] In addition, if Figure 7 As shown, the decompressed XLOG log page has removed the space of the preset length added in the XLOG log writing process.

[0103] For some compression algorithms, such as pglz, the length information of the compressed data before and after compression needs to be known during decompression. Therefore, in some embodiments, the above step of decompressing the data area of ​​the XLOG log page to be decompressed can be specifically performed as follows: obtaining the length of the compressed interval of the XLOG log page to be decompressed, compressed_len; calculating the length of the compressed interval before compression, need_compress_len, according to the length of the compressed interval, compressed_len, the length of the XLOG log page, and the length of the page header of the XLOG log page, header_len; decompressing the data in the compressed interval of the XLOG log page to be decompressed according to the length of the compressed interval before and after compression, need_compress_len and compressed_len.

[0104] It should be noted that the length of each XLOG log page is fixed, such as 8KB by default in KES. The length of the page header of the non-first XLOG log page in the XLOG log segment file is also fixed, denoted as header_len. Therefore, the calculation formula for the length of the compressed interval of the non-first XLOG log page in the XLOG log segment file before compression is: need_compress_len = 8KB-4 bytes-header_len. In addition, the length of the page header of the first page in the XLOG log segment file is first_header_len, which is also a fixed value. Therefore, the calculation formula for the length of the compressed interval of the first XLOG log page in the XLOG log segment file before compression is: first_need_compress_len = 8KB-4 bytes-first_header_len.

[0105] Figure 8 FIG. 1 is a flow chart of a method for processing a transaction log segment file according to another embodiment of the present invention. Figure 8 , the process steps of this embodiment are specifically described.

[0106] Step S802: In the XLOG log writing process, an XLOG log page is obtained. It should be noted that the obtained XLOG log page may be an XLOG log page to be compressed, or may be an XLOG log page that does not need to be compressed.

[0107] Step S804, determine whether the XLOG log page is an empty page, if so, execute step S806, if not, execute step S812.

[0108] Step S806: Add a sequentially arranged page header and a storage space of a predetermined length for the empty page.

[0109] Step S808: Write the XLOG log compression mark in the first preset position of the added page header. Specifically, mark the 4th bit of the uint16 xlp_info variable in the added page header as 1.

[0110] Step S810, write a preset empty page mark in a storage space of a predetermined length. Specifically, the preset empty page mark may be the length of the empty page, that is, 0. At this point, this process ends.

[0111] Step S812, determine whether the XLOG log page is full, if so, execute step S814, if not, execute step S818.

[0112] Step S814: Using the data area of ​​the XLOG log page as the compression granularity, a compression operation is performed on the XLOG log page.

[0113] Step S816, writing an XLOG log compression mark in the first preset position of the compressed XLOG log page. Specifically, the 4th bit of the uint16xlp_info variable in the page header of the compressed XLOG log page is marked as 1. At this point, this process ends.

[0114] Step S818: Skip the compression operation on the XLOG log page. This completes the process.

[0115] The transaction log segment file processing method of this embodiment obtains an XLOG log page in the XLOG log writing process, determines whether the XLOG log page is an XLOG log page to be compressed, and compresses the XLOG log page to be compressed when the XLOG log page is an XLOG log page to be compressed, thereby compressing the XLOG log segment file with the XLOG log page as the compression granularity, reducing the compression frequency and improving the overall performance of the system.

[0116] Fig. 9 FIG. 1 is a flow chart of a method for processing a transaction log segment file according to another embodiment of the present invention. Fig. 9 , the process steps of this embodiment are specifically described.

[0117] Step S902: In the XLOG log reading process, an XLOG log page is obtained. It should be noted that the obtained XLOG log page may be a compressed XLOG log page or an uncompressed XLOG log page.

[0118] Step S904, determine whether the data in the first preset position of the XLOG log page is an XLOG log compression mark, if yes, execute step S906, if no, execute step S914. Specifically, determine whether the 4th bit of the uint16 xlp_info variable in the page header of the XLOG log page is 1.

[0119] Step S906, determine whether the data in the storage space of the predetermined length of the XLOG log page is 0, if so, execute step S912, if not, execute step S908. Specifically, the data in the storage space of the predetermined length is the length of the compressed interval of the XLOG log page.

[0120] Step S908: decompress the XLOG log page.

[0121] Step S910: After all compressed XLOG log pages of the XLOG log segment file are decompressed, all XLOG log pages of the XLOG log segment file are spliced ​​to obtain a decompressed XLOG log segment file. At this point, this process ends.

[0122] Step S912: set an 8KB interval to zero as an empty page after decompression. This process ends here.

[0123] Step S914: Skip the decompression operation of the XLOG log page. This is the end of the process.

[0124] The transaction log segment file processing method of this embodiment realizes different processing of different XLOG log pages by sequentially judging whether the XLOG log page is an XLOG log page to be compressed and whether the XLOG log page is an empty page in the XLOG log reading process, thereby improving the accuracy of data reading and the overall performance of the system.

[0125] This embodiment also provides a machine-readable storage medium and a computer device. Fig.10 is a schematic diagram of the structure of a machine-readable storage medium 10 according to an embodiment of the present invention, Fig.11 is a schematic diagram of the structure of a computer device 20 according to an embodiment of the present invention.

[0126] The machine-readable storage medium 10 stores a machine executable program 11 thereon. When the machine executable program 11 is executed by a processor, the method for processing a transaction log segment file of any of the above embodiments is implemented.

[0127] The computer device 20 may include a memory 220, a processor 210, and a machine executable program 11 stored in the memory 220 and running on the processor 210, and the processor 210 implements the transaction log segment file processing method of any of the above embodiments when executing the machine executable program 11.

[0128] The flow chart provided by the present embodiment is not intended to indicate that the operation of the method will be performed in any particular order, or that all operations of the method are included in all every case. In addition, the method may include additional operations. Within the scope of the technical thinking provided by the present embodiment method, additional changes may be made to the above method.

[0129] At this point, those skilled in the art should recognize that, although multiple exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications that conform to the principles of the present invention can still be directly determined or derived based on the content disclosed in the present invention without departing from the spirit and scope of the present invention. Therefore, the scope of the present invention should be understood and recognized as covering all these other variations or modifications.

Claims

1. A method for processing a transaction log segment file, wherein the transaction log segment file comprises a plurality of log pages, each of the log pages comprises at least a portion of a transaction log; and the processing method comprises: In the transaction log writing process, get the log page; Determining whether the log page is a log page to be compressed; If so, a compression operation is performed on the log page to be compressed.

2. The method for processing transaction log segment files according to claim 1, wherein: The step of determining whether the log page is a log page to be compressed comprises: Determine whether the log page is an empty page; If it is an empty page, determining that the log page is not a log page to be compressed; If it is not an empty page, determining whether the log page is full; If it is full, determining that the log page is a log page to be compressed; If it is not full, it is determined that the log page is not a log page to be compressed.

3. The method for processing transaction log segment files according to claim 2, wherein: The compressed log page includes an uncompressed interval and a compressed interval, wherein a first preset position for storing a transaction log compression mark is preset in the uncompressed interval; and After the step of compressing the log page to be compressed, the processing method further includes: The transaction log compression mark is written in a first preset position of the compressed log page.

4. The method for processing transaction log segment files according to claim 3, wherein: The compressed log page includes a log page header and a data area arranged in sequence; and The uncompressed interval is the data area where the log page header is located, and the compressed interval is the data area where the data area is located; and After the step of determining whether the log page is a log page to be compressed, the processing method further includes: In the case where it is determined that the log page is an empty page, adding a sequentially arranged log page header and a storage space of a predetermined length to the empty page; Writing the transaction log compression mark into a first preset position in the added log page header; A preset empty page mark is written into the storage space of the predetermined length.

5. The method for processing transaction log segment files according to claim 4, wherein: After the step of writing the transaction log compression mark in the first preset position of the compressed log page, the processing method further includes: In the transaction log reading process, get the log page; Determining whether the log page is a log page to be decompressed; If so, decompress the log page to be decompressed.

6. The method for processing transaction log segment files according to claim 5, wherein: The step of determining whether the log page is a log page to be decompressed comprises: Obtaining whether data in a first preset position of the log page is the transaction log compression mark; If it is the transaction log compression mark, determining whether the log page is an empty page; If it is an empty page, it is determined that the log page is not a log page to be decompressed; If it is not an empty page, it is determined that the log page is a log page to be decompressed.

7. The method for processing transaction log segment files according to claim 4, wherein: The step of compressing the log page to be compressed includes: The data area of ​​the log page to be compressed is used as the compression granularity, and a compression operation is performed on the log page to be compressed.

8. The method for processing transaction log segment files according to claim 6, wherein: After the step of compressing the log page to be compressed, the processing method further includes: Writes compressed log pages to disk.

9. A machine-readable storage medium having a machine executable program stored thereon, wherein the machine executable program, when executed by a processor, implements the method for processing a transaction log segment file according to any one of claims 1 to 8.

10. A computer device comprising a memory, a processor, and a machine executable program stored in the memory and running on the processor, wherein the processor implements the transaction log segment file processing method according to any one of claims 1 to 8 when executing the machine executable program.