Transaction log segment file processing method, storage medium and equipment
By creating a compression status file in the KingbaseES database and writing compression marks in the log file, the problem of large XLOG log volumes is solved, compression efficiency and accuracy are improved, and system performance is improved.
Patent Information
- Application Number
- CN202310220614.X
- 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
The amount of XLOG logs in the KingbaseES database is large, the existing compression method is inefficient, and the writing process conflicts with the compression process, affecting performance.
Create a compression status file after the transaction log writing process, obtain the transaction log segment file to be compressed based on this file, and perform compression operations on it during the compression process. Compressed and compressed files are distinguished from compressed and Uncompressed intervals, reducing compression frequency and improving accuracy.
It improves the compression efficiency of transaction log segment files, reduces the compression frequency, eliminates the performance impact of compression on the writing process, and improves the overall system performance.
Smart Images

Figure CN118626460A
Abstract
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, the current XLOG log writing process of the KES database can only compress part of the data (pagedata) in the XLOG log, and the compression frequency is high. In addition, the XLOG log writing process and the compression process of the current compression method may conflict with each other, so multiple locking operations are required, the compression efficiency of the XLOG log is low, and the performance of the XLOG log writing process is reduced. 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 improve compression efficiency.
[0006] A further object of the present invention is to improve the accuracy of obtaining transaction log segment files to be compressed.
[0007] Another further object of the present invention is to improve the ease of identifying compressed transaction log segment files.
[0008] In particular, the present invention provides a method for processing a transaction log segment file, wherein the transaction log segment file is stored in a log file directory; and the processing method comprises:
[0009] After the transaction log writing process, a compression status file is created in the log file directory, wherein the compression status file is used to identify each transaction log segment file in the log file directory that is ready for compression;
[0010] After the compression process is started, the transaction log segment file to be compressed is obtained according to the compression status file;
[0011] Compress the transaction log segment files to be compressed.
[0012] Optionally, the file name of the compression status file includes the transaction log segment file name and the ready-to-compress flag; and
[0013] The steps of obtaining the transaction log segment file to be compressed according to the compression status file include:
[0014] Get the transaction log segment file name in the compressed state file;
[0015] According to the acquired transaction log segment file name, the corresponding transaction log segment file is read in the log file directory as the transaction log segment file to be compressed.
[0016] Optionally, before the step of obtaining the transaction log segment file to be compressed according to the compression status file, the processing method further includes:
[0017] Traverse the compressed status files in the log file directory;
[0018] Determine whether the file name of the compressed state file exists;
[0019] If not, skip the compression operation.
[0020] Optionally, after the step of obtaining the transaction log segment file name in the compressed state file, the processing method further includes:
[0021] Determine whether there is a transaction log segment file corresponding to the obtained transaction log segment file name in the log file directory;
[0022] If not, skip the compression operation.
[0023] Optionally, the compressed transaction log segment file 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
[0024] After the step of compressing the transaction log segment file to be compressed, the processing method further includes:
[0025] A transaction log compression marker is written in a first preset position of the compressed transaction log segment file.
[0026] Optionally, the transaction log segment file includes a plurality of log pages, each log page includes a page header and a data area arranged in sequence; and
[0027] After the step of compressing the transaction log segment file to be compressed, the processing method further includes:
[0028] Add a storage space of a predetermined length after the page header of the first log page of the compressed transaction log segment file;
[0029] The length of the compressed interval is written into the additional storage space of predetermined length; wherein
[0030] The uncompressed interval is the data area where the page header of the first log page of the compressed transaction log segment file is located and the data area where the additional storage space of the predetermined length is located. The compressed interval is the remaining data area of the compressed transaction log segment file except the data area where the page header of the first log page is located and the data area where the additional storage space of the predetermined length is located.
[0031] Optionally, after the step of compressing the transaction log segment file to be compressed, the processing method further includes:
[0032] A transaction log compression marker is written in a first preset position of the compressed transaction log segment file.
[0033] Optionally, after the step of writing the transaction log compression mark in the first preset position of the compressed transaction log segment file, the processing method further includes:
[0034] In the transaction log reading process, obtain the transaction log segment file;
[0035] Determine whether the transaction log segment file contains the transaction log compression mark;
[0036] If yes, decompress the transaction log segment file.
[0037] 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.
[0038] 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.
[0039] The transaction log segment file processing method of the present invention creates a compression status file for identifying each transaction log segment file in the log file directory that is ready to be compressed after the transaction log writing process, obtains the transaction log segment file to be compressed according to the compression status file after the compression process is started, and performs compression operation on the transaction log segment file to be compressed, thereby realizing that after the transaction log writing process, the transaction log segment file is compressed with the transaction log segment file as the compression granularity, reducing the compression frequency, and eliminating the influence of the compression process on the transaction log writing process performance, effectively improving the compression efficiency, and thus improving the overall performance of the system.
[0040] Furthermore, the file name of the compressed state file in the transaction log segment file processing method of the present invention includes the transaction log segment file name and a ready-to-compress mark. On this basis, the transaction log segment file processing method of the present invention obtains the transaction log segment file name in the compressed state file, and reads the corresponding transaction log segment file in the log file directory according to the obtained transaction log segment file name, thereby obtaining the transaction log segment file to be compressed, thereby improving the accuracy of obtaining the transaction log segment file to be compressed, thereby improving the accuracy of the compression operation.
[0041] Furthermore, the compressed transaction log segment file 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 transaction log segment file 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 transaction log segment file by writing the transaction log compression mark in the first preset position of the compressed transaction log segment file after the compression operation is performed on the transaction log segment file to be compressed, thereby realizing the distinction between the compressed transaction log segment file and the uncompressed transaction log segment file, improving the convenience of identifying the compressed transaction log segment file in the subsequent reading process, and further improving the overall performance of the system.
[0042] 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
[0043] 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:
[0044] Figure 1 is a flow chart of a method for processing a transaction log segment file according to an embodiment of the present invention;
[0045] Figure 2 is a schematic diagram of the structure of a transaction log segment file in a method for processing a transaction log segment file according to an embodiment of the present invention;
[0046] Figure 3 is a schematic diagram of the structure of a transaction log segment file in a method for processing a transaction log segment file according to another embodiment of the present invention;
[0047] Figure 4is a schematic diagram of a partial structure of a transaction log segment file in a method for processing a transaction log segment file according to an embodiment of the present invention;
[0048] Figure 5 is 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;
[0049] Figure 6 is a flow chart of a method for processing a transaction log segment file according to another embodiment of the present invention;
[0050] Figure 7 is a flow chart of a method for processing a transaction log segment file according to yet another embodiment of the present invention;
[0051] Figure 8 is a schematic diagram of the structure of a machine-readable storage medium according to an embodiment of the present invention; and
[0052] Fig. 9 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0053] 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.
[0054] 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:
[0055] Step S102: after the transaction log writing process, a compression status file is created in the log file directory, wherein the compression status file is used to identify each transaction log segment file in the log file directory that is ready for compression.
[0056] Step S104: after the compression process is started, the transaction log segment file to be compressed is obtained according to the compression status file.
[0057] Step S106: compress the transaction log segment file to be compressed.
[0058] The transaction log segment file processing method of the present embodiment creates a compression status file for identifying each transaction log segment file in the log file directory that is ready to be compressed after the transaction log writing process, obtains the transaction log segment file to be compressed according to the compression status file after the compression process is started, and performs a compression operation on the transaction log segment file to be compressed, thereby realizing compression of the transaction log segment file with the transaction log segment file as the compression granularity after the transaction log writing process, further reducing the XLOG log volume, greatly reducing the compression frequency, and eliminating the influence of the compression process on the performance of the transaction log writing process, effectively improving the compression efficiency, thereby improving the overall performance of the system, and having great practical value.
[0059] 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.
[0060] 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 transaction log segment file is the XLOG log segment file. In the KES database, each XLOG log segment file consists of multiple XLOG log pages of fixed size. The default size of the XLOG log page is usually 8KB, that is, page_size = 8KB. 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.
[0061] In addition, the log file directory may be a sys_wal directory. The step of creating a compressed status file in the log file directory in step S102 may be specifically performed as follows: adding a subdirectory compress_status to the sys_wal directory; and creating a compressed status file in the sys_wal / compress_status directory.
[0062] In some embodiments, in the above step S104, the file name of the compressed state file includes the XLOG log segment file name and a ready-to-compress flag. In a specific embodiment, the ready-to-compress flag may be ready. For example, the file name of the compressed state file may be 000000010000000000000001.ready, indicating that an XLOG log segment file with a file name of 000000010000000000000001 is ready to be compressed.
[0063] Furthermore, the step of obtaining the XLOG log segment file to be compressed according to the compression status file in the above step S104 may include: obtaining the XLOG log segment file name in the compression status file; and reading the corresponding XLOG log segment file in the log file directory according to the obtained XLOG log segment file name as the XLOG log segment file to be compressed.
[0064] The transaction log segment file processing method of this embodiment obtains the XLOG log segment file to be compressed by reading the corresponding XLOG log segment file in the log file directory according to the obtained XLOG log segment file name, thereby improving the accuracy of obtaining the XLOG log segment file to be compressed, thereby improving the accuracy of the compression operation.
[0065] In some embodiments, after the above step S106, the processing method of the present invention may further include the following steps: the step of obtaining the XLOG log segment file to be compressed according to the compression status file includes: deleting the corresponding compression status file that has been compressed. Using the above method, the compression status file can be updated in real time.
[0066] In some embodiments, before the above step S106, the processing method of the present invention may further include the following steps: traversing the compressed status files in the log file directory; determining whether the file name of the compressed status file exists; if not, skipping the compression operation.
[0067] By using the above method, when the file name of the compressed status file in the log file directory does not exist, the compression operation is skipped, thereby reducing the compression frequency and improving the compression accuracy.
[0068] Furthermore, after the above step of obtaining the XLOG log segment file name in the compressed state file, the processing method of the present invention may also include the following steps: determining whether there is an XLOG log segment file corresponding to the obtained XLOG log segment file name in the log file directory; if not, skipping the compression operation.
[0069] Using the above method, when the file name of the compressed status file in the log file directory exists but the XLOG log segment file corresponding to the obtained XLOG log segment file name does not exist in the log file directory, the compression operation is skipped, the compression frequency is reduced, the unnecessary compression process is terminated in time, and the compression accuracy is improved.
[0070] Figure 2 The diagram is a schematic diagram of the structure 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 3 FIG. 1 is a schematic diagram of the structure of a transaction log segment file in a method for processing a transaction log segment file according to another embodiment of the present invention. Figure 2 and Figure 3 As shown, the XLOG log segment file to be compressed includes an interval that does not need to be compressed and an interval to be compressed. Correspondingly, the compressed XLOG log segment file includes an uncompressed interval and a compressed interval.
[0071] 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 segment file.
[0072] The compressed XLOG log segment file in the transaction log segment file processing method of this embodiment 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 segment file 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 segment file after the compression operation is performed on the XLOG log segment file to be compressed, so as to mark the compressed XLOG log segment file, distinguish the compressed XLOG log segment file from the uncompressed XLOG log segment file, improve the convenience of identifying the compressed XLOG log segment file in the subsequent reading process, and further improve the overall performance of the system.
[0073] In some embodiments, Figure 2As shown, the XLOG log segment file to be compressed includes multiple XLOG log pages, and each XLOG log page includes a page header and a data area arranged in sequence. In the above embodiment, after the above step S106, the processing method of the present invention may further include the following steps: adding a storage space of a predetermined length after the page header of the first XLOG log page of the compressed XLOG log segment file; writing the length of the compressed interval compressed_len in the added storage space of the predetermined length. At this point, the compression process of the XLOG log segment file to be compressed is completed.
[0074] like Figure 3 As shown, the uncompressed interval of the compressed XLOG log segment file is the data area where the page header of the first XLOG log page of the compressed XLOG log segment file is located and the data area where the additional storage space of the predetermined length is located. The compressed interval of the compressed XLOG log segment file is the remaining data area of the compressed XLOG log segment file except the data area where the page header of the first XLOG log page is located and the data area where the additional storage space of the predetermined length is located.
[0075] In some embodiments, after the step of compressing the XLOG log segment file to be compressed, the processing method of the present invention may further include the following step: writing an XLOG log compression mark in a first preset position of the compressed XLOG log segment file.
[0076] Figure 4 FIG. 1 is a schematic diagram of a partial structure 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 4 As shown, the first preset position may be the 4th bit (recorded as XLR_COMPRESS_TOKEN, the first 3 bits are already used) of the "uint16 xlp_info" variable in the page header of the first XLOG log page of the XLOG log segment file. The XLOG log compression flag may be set to 1.
[0077] On this basis, the step of writing the XLOG log compression mark in the first preset position can be specifically performed as follows: setting the 4th bit XLR_COMPRESS_TOKEN of the "uint16 xlp_info" variable in the page header of the first XLOG log page of the XLOG log segment file to 1. Using the above method, the XLOG log compression mark does not need to add additional storage space, reducing space occupancy.
[0078] 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 of the compressed interval in the XLOG log page for subsequent retrieval.
[0079] In some embodiments, after the above step of writing the XLOG log compression mark in the first preset position of the compressed XLOG log segment file, the processing method of the present invention may further include the following steps: in the XLOG log reading process, obtaining the XLOG log segment file; determining whether the XLOG log segment file contains the XLOG log compression mark; if so, decompressing the XLOG log segment file.
[0080] Specifically, the above step of determining whether the XLOG log segment file contains the XLOG log compression mark can be specifically performed as follows: determining whether the 4th bit XLR_COMPRESS_TOKEN of the "uint16 xlp_info" variable in the page header of the first XLOG log page of the XLOG log segment file is 1; if so, determining that the XLOG log segment file contains the XLOG log compression mark; if not, determining that the XLOG log segment file does not contain the XLOG log compression mark.
[0081] The transaction log segment file processing method of this embodiment improves the accuracy of obtaining the XLOG log segment file to be decompressed by determining whether the obtained XLOG log segment file is the XLOG log segment file to be decompressed according to the judgment result of whether the XLOG log page contains the XLOG log compression mark in the XLOG log reading process, thereby improving the decompression accuracy.
[0082] Figure 5 FIG. 1 is a schematic diagram of a structure of an XLOG log segment file decompression process in a method for processing a transaction log segment file according to an embodiment of the present invention. Figure 5 As shown in the figure, the decompressed XLOG log segment file includes the page header and data area.
[0083] In this embodiment, the step of performing a decompression operation on the XLOG log segment file to be decompressed may include: taking the compressed interval of the XLOG log segment file to be decompressed as the decompression granularity, and performing a decompression operation on the XLOG log segment file to be decompressed. Specifically, firstly decompress the data in the compressed interval of the XLOG log segment file to be decompressed, and put the decompressed content after the page header of the first XLOG log page of the XLOG log segment file to obtain a complete decompressed XLOG log segment file, so as to complete the decompression operation on the XLOG log segment file to be decompressed.
[0084] In addition, if Figure 5 As shown, the decompressed XLOG log segment file has removed the space of the preset length added in the writing process of the XLOG log.
[0085] For some compression algorithms, such as pglz, it is necessary to know the length information of the compressed data before and after compression during decompression. Therefore, in some embodiments, the above step of decompressing the data area of the XLOG log segment file to be decompressed can be specifically performed as the following steps: obtaining the length of the compressed interval of the XLOG log segment file 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 segment file, and the length of the page header of the first XLOG log page of the XLOG log segment file, first_header_len; decompressing the data in the compressed interval of the XLOG log segment file to be decompressed according to the length of the compressed interval before and after compression, need_compress_len and compressed_len.
[0086] It should be noted that the length of each XLOG log segment file is fixed, such as 16MB by default in KES. The length of the page header of the first page in the XLOG log segment file, first_header_len, is also a fixed value. Therefore, the calculation formula for the length of the compressed interval before compression in the XLOG log segment file to be decompressed is: need_compress_len = 16MB-first_header_len.
[0087] The transaction log segment file processing method of this embodiment can calculate the length of the compressed interval in the XLOG log segment file before compression during the decompression stage, without setting up additional storage space to store this length data, thereby reducing space occupancy.
[0088] Figure 6 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 6 , the process steps of this embodiment are specifically described.
[0089] Step S602, start the compression process. Specifically, add a compression subprocess in the KES database system, or start a process by writing an XLOG log compression script (shell, python, etc.).
[0090] Step S604, traverse the compression status files in the sys_wal / compress_status directory.
[0091] Step S606, determine whether the file name of the compressed state file exists, if so, execute step S608, if not, execute step S622.
[0092] Step S608: Obtain the XLOG log segment file name from the file name of the compressed state file.
[0093] Step S610, determining whether there is an XLOG log segment file corresponding to the obtained XLOG log segment file name in the log file directory, if so, executing step S612, if not, returning to step S604.
[0094] Step S612: compress the corresponding XLOG log segment file.
[0095] Step S614, recording the length of the compressed interval of the compressed XLOG log segment file. Specifically, the length of the compressed interval of the compressed XLOG log segment file is stored in 4 bytes added after the page header of the first page of the compressed XLOG log segment file.
[0096] Step S616, write the XLOG log compression mark in the first preset position of the page header of the first page of the compressed XLOG log segment file. Specifically, mark the 4th bit of the uint16 xlp_info variable in the page header of the first page of the compressed XLOG log segment file as 1. So far, this process ends.
[0097] Step S618: Store the compressed XLOG log segment file in the sys_wal directory to replace the original file. Specifically, the file name of the compressed XLOG log segment file is the same as the original file name.
[0098] Step S620: Delete the compression status file corresponding to the compressed XLOG log segment file in the sys_wal / compress_status directory. This process ends.
[0099] Step S622: skip the compression operation. At this point, this process ends.
[0100] The transaction log segment file processing method of this embodiment obtains the XLOG log segment file to be compressed according to the compression status file after the compression process is started, and performs a compression operation on the XLOG log segment file to be compressed, so that after the XLOG log writing process, the XLOG log segment file is compressed with the XLOG log segment file as the compression granularity, thereby reducing the compression frequency and eliminating the influence of the compression process on the performance of the XLOG log writing process, effectively improving the compression efficiency, and thus improving the overall performance of the system.
[0101] Figure 7 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 7 , the process steps of this embodiment are specifically described.
[0102] Step S702: In the XLOG log reading process, an XLOG log segment file is obtained.
[0103] Step S704, determine whether the XLOG log segment file contains an XLOG log compression mark, if yes, execute step S706, if no, execute step S714. Specifically, determine whether the 4th bit of the uint16 xlp_info variable in the page header of the first page of the XLOG log segment file is 1.
[0104] Step S706, obtaining the length of the compressed interval of the XLOG log segment file. Specifically, the 4 bytes after the page header of the first page of the XLOG log segment file are read to obtain the compressed data area length (compressed_len), and the data (compressed_data) of the compressed_len size is read after the 4 bytes.
[0105] Step S708, calculate the length of the compressed interval of the XLOG log segment file before compression. The specific calculation formula is: need_compress_len = 16MB-first_header_len.
[0106] Step S710: decompress the data of the compressed interval according to the length of the compressed interval of the XLOG log segment file before and after compression.
[0107] Step S712: After the decompressed compressed interval data is placed in the page header of the first page of the XLOG log segment file, the decompressed XLOG log segment file is obtained. At this point, this process ends.
[0108] Step S714: skip the decompression operation. At this point, this process ends.
[0109] The transaction log segment file processing method of this embodiment improves the accuracy of data reading and the overall performance of the system by performing differentiated processing on the XLOG log segment files to be decompressed in the XLOG log reading process.
[0110] This embodiment also provides a machine-readable storage medium and a computer device. Figure 8 is a schematic diagram of the structure of a machine-readable storage medium 10 according to an embodiment of the present invention, Fig. 9 is a schematic diagram of the structure of a computer device 20 according to an embodiment of the present invention.
[0111] 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.
[0112] 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.
[0113] 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.
[0114] 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 is stored in a log file directory; and the processing method comprises: After the transaction log writing process, creating a compression status file in the log file directory, wherein the compression status file is used to identify each transaction log segment file in the log file directory that is ready for compression; After the compression process is started, the transaction log segment file to be compressed is obtained according to the compression status file; A compression operation is performed on the transaction log segment file to be compressed.
2. The method for processing transaction log segment files according to claim 1, wherein: The file name of the compression status file includes the transaction log segment file name and a ready-to-compress mark; and The step of obtaining the transaction log segment file to be compressed according to the compression status file comprises: Obtaining the transaction log segment file name in the compressed state file; According to the acquired transaction log segment file name, the corresponding transaction log segment file is read in the log file directory as the transaction log segment file to be compressed.
3. The method for processing transaction log segment files according to claim 2, wherein: Before the step of obtaining the transaction log segment file to be compressed according to the compression status file, the processing method further includes: Traversing the compressed status files in the log file directory; Determine whether the file name of the compressed state file exists; If not, skip the compression operation.
4. The method for processing transaction log segment files according to claim 2, wherein: After the step of obtaining the transaction log segment file name in the compressed state file, the processing method further includes: Determine whether there is a transaction log segment file corresponding to the acquired transaction log segment file name in the log file directory; If not, skip the compression operation.
5. The method for processing transaction log segment files according to claim 1, wherein: The compressed transaction log segment file 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 transaction log segment file to be compressed, the processing method further includes: The transaction log compression mark is written into a first preset position of the compressed transaction log segment file.
6. The method for processing transaction log segment files according to claim 5, wherein: The transaction log segment file includes a plurality of log pages, each of which includes a page header and a data area arranged in sequence; and After the step of compressing the transaction log segment file to be compressed, the processing method further includes: Adding a storage space of a predetermined length after the page header of the first log page of the compressed transaction log segment file; The length of the compressed interval is written into the additional storage space of predetermined length; wherein The uncompressed interval is the data area where the page header of the first log page of the compressed transaction log segment file is located and the data area where the additional storage space of the predetermined length is located, and the compressed interval is the remaining data area of the compressed transaction log segment file except the data area where the page header of the first log page is located and the data area where the additional storage space of the predetermined length is located.
7. The method for processing transaction log segment files according to claim 5, wherein: After the step of compressing the transaction log segment file to be compressed, the processing method further includes: The transaction log compression mark is written into a first preset position of the compressed transaction log segment file.
8. The method for processing transaction log segment files according to claim 7, wherein: After the step of writing the transaction log compression mark in the first preset position of the compressed transaction log segment file, the processing method further includes: In the transaction log reading process, obtain the transaction log segment file; Determining whether the transaction log segment file contains the transaction log compression mark; If yes, decompress the transaction log segment file.
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.
