Transaction log processing method, storage medium and equipment

By recording and obtaining the length in the transaction log writing and reading process, the transaction log is accurately decompressed, solving the problem of inaccurate decompression in the existing technology, and improving the database's reading accuracy and resource utilization efficiency of XLOG logs. .

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

Patent Information

Application Number
CN202310220612.0
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

When compressing and decompressing transaction logs, the existing technology cannot accurately obtain the data length before and after compression, resulting in inaccurate reading of XLOG logs by the database and reducing the accuracy of decompression.

Method used

Record the length before and after compression in the writing process of the transaction log, and obtain these lengths in the reading process, so as to accurately decompress the compressed transaction log. By calculating the length of the uncompressed and compressed intervals, combining the original data and compressed data, we can achieve Precise decompression of transaction logs.

Benefits of technology

It improves the decompression accuracy of transaction logs, reduces invalid decompression operations, reduces database resource consumption, and ensures accurate identification and accurate decompression of compressed transaction logs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626459A
    Figure CN118626459A
Patent Text Reader

Abstract

The invention relates to a database technology, in particular to a transaction log processing method, a storage medium and equipment. The transaction log processing method comprises the steps of recording the length of a transaction log before compression and the length of the transaction log after compression in a writing process of the transaction log; in the reading process of the transaction log, the length of the compressed transaction log before compression and the length of the compressed transaction log after compression are obtained; and according to the length of the compressed transaction log before compression and the length of the compressed transaction log after compression, performing decompression operation on the compressed transaction log to obtain a decompressed transaction log. According to the transaction log processing method, correct decompression of the compressed transaction log is realized according to the length of the compressed transaction log before compression and the length of the compressed transaction log after compression, the problem of inaccurate decompression caused by the lack of the length of the compressed transaction log is avoided, and the accuracy of decompression of the transaction log 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 transaction log processing method, storage medium and device. Background Art

[0002] In the DynamoDB 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. The compression algorithm currently used by the KES database (for example, the pglz compression algorithm) completes the compression and decompression operations of the XLOG log.

[0003] However, current compression methods generally only retain the length of the compressed data. The compression algorithm currently used by the KES database cannot perform correct decompression operations without obtaining the size data of the XLOG log before and after compression, 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 transaction log processing method, storage medium and device 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 transaction log processing method, which can improve the accuracy of decompressing the transaction log.

[0006] A further object of the present invention is to achieve accurate decompression of compressed transaction logs.

[0007] Another further object of the present invention is to reduce decompression scenarios.

[0008] In particular, the present invention provides a transaction log processing method, comprising:

[0009] In the transaction log writing process, record the length of the transaction log before compression and the length after compression;

[0010] In the transaction log reading process, obtain the length of the compressed transaction log before compression and the length after compression;

[0011] According to the length of the compressed transaction log before compression and the length after compression, the compressed transaction log is decompressed to obtain a decompressed transaction log.

[0012] Optionally, the compressed transaction log includes an uncompressed interval and a compressed interval; and

[0013] The steps of decompressing the compressed transaction log according to the length of the compressed transaction log before compression and the length of the compressed transaction log to obtain the decompressed transaction log include:

[0014] Calculate the length of the compressed interval before compression and the length after compression based on the length of the compressed transaction log before compression and the length after compression;

[0015] Decompressing the compressed data in the compressed interval according to the length of the compressed interval before compression and the length of the compressed interval after compression to obtain the original data before compression of the compressed data;

[0016] The original data and the data in the uncompressed interval are combined to obtain the decompressed transaction log.

[0017] Optionally, the compressed transaction log includes sequentially arranged XLogRecord structures, the remaining transaction log parts except the XLogRecord structures, and the additional storage space; wherein

[0018] The uncompressed area includes the data area where the XLogRecord structure is located and the data area where the additional storage space is located; and

[0019] The compressed data is the data of the remaining transaction log after compression;

[0020] The additional storage space stores the length of the compressed transaction log before compression.

[0021] Optionally, the step of calculating the length of the compressed interval before compression and the length after compression according to the length of the compressed transaction log before compression and the length after compression includes:

[0022] Calculate the length of the compressed interval before compression based on the length of the compressed transaction log before compression, the length of the XLogRecord structure, and the length of the additional storage space;

[0023] The length of the compressed interval is calculated based on the length of the compressed transaction log after compression, the length of the XLogRecord structure, and the length of the additional storage space.

[0024] Optionally, before the step of recording the length of the transaction log before compression and the length of the transaction log after compression, the processing method further includes:

[0025] The length of the additional storage space is determined according to the length of the remaining transaction log portion before the transaction log is compressed.

[0026] Optionally, the step of determining the length of the additional storage space according to the length of the remaining transaction log portion before compression of the transaction log includes:

[0027] The length of the remaining transaction log portion before the transaction log is compressed is compared with a preset length threshold interval, wherein different length threshold intervals are set according to the values ​​that can be stored under different lengths of storage space;

[0028] The length of the storage space corresponding to the length threshold interval to which the length of the remaining transaction log portion before compression of the transaction log belongs is used as the length of the additional storage space.

[0029] Optionally, the additional storage space also stores the length of the additional storage space.

[0030] Optionally, before the step of obtaining the length of the compressed transaction log before compression and the length after compression, the processing method further includes:

[0031] Get the transaction log;

[0032] Determine whether the acquired transaction log is marked;

[0033] If yes, it is confirmed that the acquired transaction log is a compressed transaction log.

[0034] 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 transaction log processing methods described above is implemented.

[0035] 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 transaction log processing methods when executing the machine executable program.

[0036] The transaction log processing method of the present invention records the length of the transaction log before compression and the length after compression in the transaction log writing process, thereby ensuring that the length of the transaction log before compression and the length after compression can be directly read in the subsequent process. In addition, the transaction log processing method of the present invention also obtains the length of the compressed transaction log before compression and the length after compression in the transaction log reading process, and decompresses the compressed transaction log according to the length of the compressed transaction log before compression and the length after compression to obtain the decompressed transaction log, thereby realizing decompression of the compressed transaction log according to a set of length data of the compressed transaction log before and after compression, thereby improving the accuracy of decompressing the transaction log.

[0037] Further, the compressed transaction log in the transaction log processing method of the present invention includes an uncompressed interval and a compressed interval. In addition, the transaction log processing method of the present invention calculates the length of the compressed interval before compression and the length after compression according to the length of the compressed transaction log before compression and the length after compression, and decompresses the compressed data in the compressed interval according to the length of the compressed interval before compression and the length after compression, obtains the original data before compression of the compressed data, and finally combines the original data with the data in the uncompressed interval to obtain the decompressed transaction log, thereby realizing targeted decompression of the data to be decompressed in the compressed transaction log, and realizing accurate decompression of the compressed transaction log. Read the transaction log, determine whether the read transaction log is marked, and if the read transaction log is marked, use the read transaction log as a compressed transaction log to achieve the acquisition of the compressed transaction log, improve the accuracy of accurately identifying the compressed transaction log according to the marking of the transaction log, and improve the accuracy of acquiring the compressed transaction log, thereby realizing the decompression operation only for the compressed transaction log, and further ensuring the accuracy of the decompressed transaction log.

[0038] Furthermore, the transaction log processing method of the present invention obtains the transaction log before decompressing the transaction log, determines whether the obtained transaction log is marked, and confirms that the obtained transaction log is a compressed transaction log when the obtained transaction log is marked. This achieves decompression operation only on the compressed transaction log, reduces decompression scenarios, and avoids invalid decompression operations, thereby effectively reducing database resource consumption.

[0039] 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

[0040] 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:

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

[0042] Figure 2 is a schematic diagram of the structure of a transaction log in a transaction log processing method according to an embodiment of the present invention;

[0043] Figure 3is a schematic diagram of the structure of a transaction log in a transaction log processing method according to another embodiment of the present invention;

[0044] Figure 4 is a schematic diagram of the structure of a transaction log in a transaction log processing method according to yet another embodiment of the present invention;

[0045] Figure 5 It is a schematic diagram of the structure of multiple additional storage spaces of different lengths in a transaction log processing method according to an embodiment of the present invention.

[0046] Figure 6 is a flow chart of a method for processing a transaction log according to another embodiment of the present invention;

[0047] Figure 7 is a schematic diagram of the structure of a machine-readable storage medium according to an embodiment of the present invention; and

[0048] Figure 8 is a schematic diagram of the structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0049] 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.

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

[0051] Step S102, in the transaction log writing process, record the length of the transaction log before compression and the length after compression. It should be noted that at least one of the length of the transaction log before compression, total_len, and the length of the transaction log after compression, total_len_compress, can be stored in the uncompressed data area of ​​the compressed transaction log, so as to be directly obtained in the subsequent transaction log reading process.

[0052] Step S104, in the transaction log reading process, obtain the length of the compressed transaction log before compression and the length after compression.

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

[0054] The transaction log processing method of the present embodiment records the length of the transaction log before compression and the length after compression in the transaction log writing process, thereby ensuring that the length of the transaction log before compression and the length after compression can be directly read in the subsequent process. In addition, the transaction log processing method of the present invention also obtains the length of the compressed transaction log before compression and the length after compression in the transaction log reading process, and decompresses the compressed transaction log according to the length of the compressed transaction log before compression and the length after compression to obtain the decompressed transaction log, thereby realizing decompression of the compressed transaction log according to a set of length data of the compressed transaction log before and after compression, thereby improving the accuracy of decompressing the transaction log.

[0055] 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 processing method of the present invention can be applied to the KES database, and in other optional embodiments, the transaction log processing method of the present invention can also be applied to other relational databases. For the KES database, the transaction log actually refers to the XLOG log. During the operation of the KES database, multiple XLOG logs will be generated.

[0056] In some embodiments, before the step of obtaining the length of the compressed XLOG log before compression and the length after compression in the above step S104, the transaction log processing method of the present invention may further include: obtaining the XLOG log; determining whether the obtained XLOG log is marked; if so, confirming that the obtained XLOG log is a compressed XLOG log. That is, before decompressing the XLOG log, first determine whether the read XLOG log is marked. If the read XLOG log is marked, the read XLOG log is used as a compressed XLOG log. If the read XLOG log is not marked, confirm that the read XLOG log is not a compressed XLOG log, and therefore, skip the decompression operation of the read XLOG log.

[0057] The transaction log processing method of this embodiment, by first identifying the compressed XLOG log to obtain the XLOG log before decompressing the XLOG log, realizes that the decompression operation is only performed on the compressed XLOG log, reduces the decompression scenarios, and also avoids invalid decompression operations, thereby effectively reducing the resource consumption of the database.

[0058] In some embodiments, the compressed XLOG log includes an uncompressed interval and a compressed interval. On this basis, the above step S102 can be specifically performed as follows: in the writing process of the XLOG log, a storage space of a preset length is added in the uncompressed interval of the compressed XLOG log; the length of the compressed XLOG log before compression is stored in the storage space of the preset length; and the length of the compressed XLOG log after compression is recorded. It should be noted that the length of the compressed XLOG log after compression can be stored in the uncompressed interval of the compressed XLOG log, or in the XLOG log cache.

[0059] In addition, the additional storage space can store not only the length of the compressed XLOG log before compression, but also the length of the additional storage space, so as to obtain data in the storage space of a preset length.

[0060] Furthermore, a first preset position for storing an XLOG log compression mark is preset in the uncompressed interval, and the compressed interval is a storage position interval where the compressed data is located. On this basis, in the XLOG log writing process, the processing method of this embodiment may also include the following steps: writing an XLOG log compression mark in the first preset position. It should be noted that the XLOG log compression mark is used to mark the compression status of the current XLOG log, so that in the subsequent XLOG log reading process, whether the XLOG log is compressed is judged based on whether the data in the first preset position is an XLOG log compression mark.

[0061] On this basis, the above step of determining whether the obtained XLOG log is marked can be specifically performed as follows: determining whether the data in the first preset position of the obtained XLOG log is a preset XLOG log compression mark; if so, determining that the obtained XLOG log is marked; if not, determining that the obtained XLOG log is not marked.

[0062] The compressed XLOG log in the transaction log processing method of this embodiment includes an uncompressed interval and a compressed interval, which realizes the regional division of the compressed XLOG log and stores the XLOG log compression mark in the data area that does not need to be compressed. On this basis, the transaction log processing method of the present invention also obtains the data in the first preset position of the compressed XLOG log to determine whether the data in the first preset position is an XLOG log compression mark. In the case where the data in the first preset position is an XLOG log compression mark, it is determined that the read XLOG log is marked, and in the case where the data in the first preset position is not an XLOG log compression mark, it is determined that the read XLOG log is not marked, which realizes the judgment of whether the read XLOG log is marked according to the XLOG log compression mark, improves the accuracy of judging whether the XLOG log is marked, and thus improves the accuracy of identifying the compressed XLOG log.

[0063] In some embodiments, the above step S106 may include the following steps: calculating the length of the compressed interval before compression and the length after compression according to the length of the compressed XLOG log before compression and the length after compression; decompressing the compressed data in the compressed interval according to the length of the compressed interval before compression and the length after compression to obtain the original data before compression of the compressed data; combining the original data with the data in the uncompressed interval to obtain the decompressed XLOG log.

[0064] The transaction log processing method of this embodiment calculates the length of the compressed interval before compression and the length after compression according to the length of the compressed XLOG log before compression and the length after compression, and decompresses the compressed data in the compressed interval according to the length of the compressed interval before compression and the length after compression to obtain the original data before compression of the compressed data, and finally combines the original data with the data in the uncompressed interval to obtain the decompressed XLOG log, thereby achieving targeted decompression of the data that needs to be decompressed in the compressed XLOG log, and achieving accurate decompression of the compressed XLOG log.

[0065] Figure 2 1 is a schematic diagram of the structure of a transaction log in a transaction log processing method according to an embodiment of the present invention. Figure 2 , the structure of the compressed XLOG log is described in detail. Specifically, for the KES database, the transaction log is the XLOG log.

[0066] Some XLOG logs only include an XLOG log header, but do not have an XLOG log data area. Figure 2As shown, some other XLOG logs include both an XLOG log header and an XLOG log data area. Specifically, the XLOG log data area includes main data and / or at least one block area, each block area contains page data and / or tuple data. The front of the XLOG log header is an XLogRecord structure.

[0067] It should be noted that different types of XLOG logs have different structures. Some types of XLOG logs only have an XLOG log header, while other types of XLOG logs include both an XLOG log header and an XLOG log data area. If an XLOG log has an XLOG log data area, then the XLOG log header of the XLOG log will include a sequentially arranged XLogRecord structure and header information corresponding to the blocks part and / or the main data part in the XLOG log data area. For an XLOG log whose XLOG log header only includes an XLogRecord structure, it does not have an XLOG log data area, and the data length is extremely small, and does not need to be compressed. For an XLOG log that has both an XLOG log header and an XLOG log data area, at least the XLOG log data area needs to be compressed. In other words, if Figure 2 As shown, a compressed XLOG log includes an XLOG log header and an XLOG log data area arranged in sequence.

[0068] In addition, the data structure in the XLOG log header and the XLOG log data area are set correspondingly. In the case where an XLOG log only includes an XLOG log header and does not have an XLOG log data area, the XLOG log header should only include an XLogRecord structure. In the case where an XLOG log includes both an XLOG log header and an XLOG log data area, the XLOG log header may include a sequentially arranged XLogRecord structure and a remaining XLOG log header other than the XLogRecord structure. The remaining XLOG log header includes at least one of the header data of each block data area, the header data of the main data data area, and a record mark.

[0069] Since the compressed XLOG log can include both the XLOG log header and the XLOG log data area, the XLOG log header of the compressed XLOG log can include both the XLogRecord structure and the remaining XLOG log header except the XLogRecord structure. Figure 3As shown, in some embodiments, the XLOG log to be compressed may include sequentially arranged XLogRecord structures, the remaining XLOG log part before compression, and an additional storage space of a preset length (the length is nbyte). Correspondingly, the compressed XLOG log may include sequentially arranged XLogRecord structures, the remaining XLOG log part after compression, and an additional storage space of a preset length. It should be noted that, as Figure 2 As shown, the remaining XLOG log part includes the remaining XLOG log header and the XLOG log data area except the XLogRecord structure.

[0070] Figure 3 FIG. 1 is a schematic diagram of the structure of a transaction log in a transaction log processing method according to another embodiment of the present invention. Figure 2 and Figure 3 , the division method of the uncompressed interval and the compressed interval of the XLOG log is explained in detail.

[0071] In this embodiment, in order to reduce the byte occupation of the XLOG log compression mark, the first preset position can be the third bit (denoted as XLR_ENCRYPTION_TOKEN) of the xl_info variable in the XLogRecord structure. For a compressed XLOG log, its XLR_COMPRESS_TOKEN bit is set to 1, otherwise it is set to 0. Therefore, in order to facilitate the direct reading of the data in the first preset position before decompression in the subsequent XLOG log reading process, the XLogRecord structure of the XLOG log to be compressed is not compressed.

[0072] On this basis, the uncompressed interval of the compressed XLOG log includes the data area where the XLogRecord structure is located and the data area where the additional storage space is located. The compressed interval of the compressed XLOG log is the data area where the remaining XLOG log part is located, and the compressed data is the data of the remaining XLOG log part after compression.

[0073] In some embodiments, the step of combining the original data with the data in the uncompressed interval to obtain the decompressed XLOG log may include the following steps: placing the original data into the XLogRecord structure in the continuous storage space and the additional storage space to obtain the decompressed XLOG log.

[0074] Figure 4 FIG. 1 is a schematic diagram of the structure of a transaction log in a transaction log processing method according to another embodiment of the present invention. Figure 4 , the calculation process of the length of the compressed interval before compression and the length after compression is explained.

[0075] In a specific embodiment, the above step of calculating the length of the compressed interval before compression and the length after compression according to the length of the compressed XLOG log before compression and the length after compression may include the following steps: calculating the length of the compressed interval before compression according to the length of the compressed XLOG log before compression, the length of the XLogRecord structure, and the length of the additional storage space; calculating the length of the compressed interval according to the length of the compressed XLOG log after compression, the length of the XLogRecord structure, and the length of the additional storage space. That is, the length of the compressed interval before compression, origin_len, in this embodiment can be calculated by the length of the compressed XLOG log total_len_compress, the length of the XLogRecord SizeOfXLogRecord, and the length of the additional storage space. The calculation formula is: origin_len = total_len - SizeOfXLogRecord (length of XLogRecord) - the length of the additional storage space. In addition, the length of the compressed interval after compression, dec_len, can be calculated by the length of the compressed XLOG log, total_len_compress, the length of the XLogRecord, SizeOfXLogRecord, and the length of the additional storage space. The calculation formula is: dec_len = total_len_compress - SizeOfXLogRecord - the length of the additional storage space. It should be noted that SizeOfXLogRecord is generally a fixed value, or can be obtained through simple calculation.

[0076] In an optional embodiment, the preset length may be a preset fixed value, such as 4 bytes. That is, the length of the additional storage space may always be 4 bytes. In this case, the length origin_len of the compressed interval before compression and the length dec_len of the compressed interval after compression may be directly calculated.

[0077] In another optional embodiment, in order to reduce the byte occupancy of the additional storage space. The preset length can be determined based on the length of the remaining XLOG log portion before the compression of the XLOG log. On this basis, before the step of recording the length of the XLOG log before compression and the length after compression in the above step S102, the transaction log processing method of this embodiment can also include the following steps: determining the length of the additional storage space based on the length of the remaining XLOG log portion before compression of the XLOG log. In addition, after the above step S102, the transaction log processing method of this embodiment can also include the following steps: storing the length of the additional storage space in the additional storage space.

[0078] Specifically, the step of determining the length of the additional storage space according to the length of the remaining XLOG log part before the compression of the XLOG log may include the following steps: comparing the length of the remaining XLOG log part before the compression of the XLOG log with a preset length threshold interval, wherein different length threshold intervals are set according to the values ​​that can be stored under different lengths of the storage space; and taking the length of the storage space corresponding to the length threshold interval to which the length of the remaining XLOG log part before the compression of the XLOG log belongs as the length of the additional storage space. For example, the maximum number that can be stored in 1 byte is 255, so the length threshold interval corresponding to 1 byte is [0 to 255].

[0079] Figure 5 FIG. 1 is a schematic diagram of a structure of multiple storage spaces of different lengths added in a transaction log processing method according to an embodiment of the present invention. Figure 5 As shown, the last two bits of each additional storage space are used to store the length of the additional storage space.

[0080] In a specific embodiment, different contents may be recorded in the last two bits of each additional storage space to indicate the length of the additional storage space. The corresponding relationship between the contents of the last two bits of the additional storage spaces of different lengths and the lengths of the additional storage spaces they represent is as follows:

[0081] 1) The contents of the last two bits are 00, and the length of the additional storage space is 1 byte;

[0082] 2) The contents of the last two bits are 01, and the length of the additional storage space is 2 bytes;

[0083] 3) The content of the last two bits is 10, and the length of the additional storage space is 3 bytes;

[0084] 4) The content of the last two bits is 11, and the length of the additional storage space is 4 bytes.

[0085] In a specific embodiment, the length of the additional storage space is equal to the remaining XLOG log portion before compression (i.e. Figure 3 The corresponding relationship between the length of the interval to be compressed in is as follows:

[0086] 1) The length of the additional storage space is 1 byte, and the maximum length of the interval to be compressed is 63 (111111) bytes;

[0087] 2) The length of the additional storage space is 2 bytes, and the maximum length of the interval to be compressed is 16383 (11111111111111) bytes;

[0088] 3) The length of the additional storage space is 3 bytes, and the maximum length of the interval to be compressed is 4194303 (111111111111111111111 11) bytes;

[0089] 4) The length of the additional storage space is 4 bytes, and the maximum length of the interval to be compressed is 1073741823 (11111111111111111111111111111 11) bytes (approximately equal to 131072 8KB pages. In practice, an XLOG log generally stores at most dozens of pages of data).

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

[0091] Step S602, in the XLOG log reading process, obtain the XLOG log. It should be noted that the obtained XLOG log may be a compressed XLOG log or an uncompressed XLOG log. For a compressed XLOG log, the compressed XLOG log can be obtained from the XLOG log file according to the total_len_compress recorded in the XLOG log.

[0092] Step S604, determining whether the read XLOG log is a compressed XLOG log, if so, executing step S606, if not, executing step S616. In a specific embodiment, the step of determining whether the read XLOG log is a compressed XLOG log can be specifically executed as follows: determining whether the data in the XLR_ENCRYPTION_TOKEN of the XLOG log is 1; if so, determining that the read XLOG log is a compressed XLOG log; if not, determining that the read XLOG log is not a compressed XLOG log.

[0093] Step S606, obtaining the length of the additional storage space of the compressed XLOG log. In a specific embodiment, the number of bytes n occupied by the additional storage space of the XLOG log can be directly obtained by reading the data in the last 2 bits of the XLOG log.

[0094] Step S608, obtaining the length of the compressed XLOG log before compression. In a specific embodiment, the data in the last n bytes of the XLOG log is read and right-shifted by 2 bits to directly obtain the length of the compressed XLOG log before compression.

[0095] Step S610, calculate the length of the compressed interval before compression and the length after compression. The specific calculation formula is: the length of the compressed interval before compression origin_len = total_len - SizeOfXLogRecord (XLogRecord length) - n bytes, and the length of the compressed interval after compression dec_len = total_len_compress - SizeOfXLogRecord - the length of the additional storage space - n bytes.

[0096] Step S612, decompressing the compressed data according to the length of the compressed interval before compression and the length after compression to obtain the original data of the compressed data before compression.

[0097] Step S614: put the decompressed original data after the XLogRecord structure to obtain the decompressed XLOG log. At this point, this process ends.

[0098] Step S616: Skip the decompression operation. If the read XLOG log is not a compressed XLOG log, there is no need to perform the decompression process. At this point, this process ends.

[0099] The transaction log processing method of this embodiment obtains a compressed XLOG log in the reading process of the XLOG log, calculates the length of the compressed data in the compressed XLOG log, and decompresses the compressed XLOG log according to the length of the compressed data to obtain the decompressed XLOG log, thereby accurately obtaining the data to be decompressed in the compressed XLOG log according to the length of the compressed data, thereby improving the accuracy of decompressing the XLOG log.

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

[0101] The machine-readable storage medium 10 stores a machine-executable program 11 , and when the machine-executable program 11 is executed by a processor, the processing method of any of the above embodiments is implemented.

[0102] 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 processing method of any of the above embodiments when executing the machine executable program 11.

[0103] 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.

[0104] 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 transaction logs, include: In the transaction log writing process, record the length of the transaction log before compression and the length after compression; In the transaction log reading process, obtain the length of the compressed transaction log before compression and the length after compression; According to the length of the compressed transaction log before compression and the length after compression, the compressed transaction log is decompressed to obtain a decompressed transaction log.

2. The method for processing transaction logs according to claim 1, in, The compressed transaction log includes an uncompressed interval and a compressed interval; and The step of decompressing the compressed transaction log according to the length of the compressed transaction log before compression and the length after compression to obtain the decompressed transaction log comprises: Calculating the length of the compressed interval before compression and the length after compression according to the length of the compressed transaction log before compression and the length after compression; Decompressing the compressed data in the compressed interval according to the length of the compressed interval before compression and the length of the compressed interval after compression to obtain the original data of the compressed data before compression; The original data and the data in the uncompressed interval are combined to obtain the decompressed transaction log.

3. The method for processing transaction logs according to claim 2, in, The compressed transaction log includes a sequentially arranged XLogRecord structure, a remaining transaction log portion other than the XLogRecord structure, and an additional storage space; wherein The uncompressed interval includes the data area where the XLogRecord structure is located and the data area where the additional storage space is located; and The compressed data is the data of the remaining transaction log portion after compression; The additional storage space stores the length of the compressed transaction log before compression.

4. The method for processing transaction logs according to claim 3, in, The step of calculating the length of the compressed interval before compression and the length after compression according to the length of the compressed transaction log before compression and the length after compression comprises: Calculate the length of the compressed interval before compression according to the length of the compressed transaction log before compression, the length of the XLogRecord structure, and the length of the additional storage space; The length of the compressed interval is calculated according to the length of the compressed transaction log after compression, the length of the XLogRecord structure, and the length of the additional storage space.

5. The method for processing transaction logs according to claim 3, in, Before the step of recording the length of the transaction log before compression and the length of the transaction log after compression, the processing method further includes: The length of the additional storage space is determined according to the length of the remaining transaction log portion before compression of the transaction log.

6. The method for processing transaction logs according to claim 5, in, The step of determining the length of the additional storage space according to the length of the remaining transaction log portion before compression of the transaction log comprises: Comparing the length of the remaining transaction log portion before compression of the transaction log with a preset length threshold interval, wherein different length threshold intervals are set according to values ​​that can be stored under different lengths of the storage space; The length of the storage space corresponding to the length threshold interval to which the length of the remaining transaction log portion before compression of the transaction log belongs is used as the length of the added storage space.

7. The method for processing transaction logs according to claim 3, in, The additional storage space also stores the length of the additional storage space.

8. The method for processing transaction logs according to claim 1, in, Before the step of obtaining the length of the compressed transaction log before compression and the length after compression, the processing method further includes: Get the transaction log; Determine whether the acquired transaction log is marked; If yes, it is confirmed that the acquired transaction log is a compressed transaction log.

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 transaction log processing method 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 processing method according to any one of claims 1 to 8 when executing the machine executable program.

Citation Information

Patent Citations

  • Methods, devices and systems for compressing and decompressing data

    CN108886367A

  • Data processing method

    JP2000188692A

  • Forward compatibility guaranteed data compression and decompression method and apparatus thereof

    US20120271802A1