Database processing method, storage medium and equipment

By monitoring the database running status and recording the information of the page data file into shared memory or files when appropriate, the problem of high complexity in page data file management is solved, and the efficiency of database usage and data integrity is improved.

CN120277038APending Publication Date: 2025-07-08CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311867955.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

In the prior art, when database restarts, the management complexity of page data files is high, resulting in low usage efficiency and unnecessary waste of space.

Method used

By monitoring the running status of the database, the file information of the page data file is recorded in the shared memory during normal operation, and it is recorded in the page data file when it is about to be closed. The information is obtained from the page data file when it is restarted, and it is recorded in the shared memory when it is successfully obtained. The settings of temporary files are cancelled and the management of page data files is optimized.

Benefits of technology

It reduces the management complexity of page data files, improves usage efficiency, ensures data integrity and accuracy, and reduces space waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277038A_ABST
    Figure CN120277038A_ABST
Patent Text Reader

Abstract

The invention provides a database processing method, a storage medium and equipment. Wherein a page data file is pre-created in the database, the page data file is used for storing page data separated from a transaction log of the database, and the processing method comprises the following steps: monitoring a running state of the database; under the condition that the running state is normal running, recording file information of the page data file into a shared memory; recording file information of the page data file into the page data file under the condition that the running state is to be closed; acquiring file information of the page data file from the page data file under the condition that the running state is restart; and if the file information is successfully acquired, determining that the database is normally closed before being restarted, and recording the acquired file information into the shared memory. The method has the advantages that the file information of the page data file can be safely and effectively recorded, and the management of the page data file is simplified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data synchronization, and particularly to a processing method, a storage medium and a device for a database. Background Art

[0002] Pre-creating a page data file in the database and storing the page data of the transaction log in the page data file can effectively reduce the generation amount of the transaction log.

[0003] To facilitate grasping the position where the last write to the page data file was aborted, when the database is about to be closed, the file information of the page data file can be recorded in a temporary file. After the database is restarted, the file information can be retrieved from the temporary file. When the retrieval fails, it indicates that the database was abnormally closed before the restart. In this case, to maintain the integrity and reliability of the data, what those skilled in the art may think of is to create a new page data file to store the new page data.

[0004] However, recording the file information of the page data file in a temporary file will increase the management complexity of the page data file. When the retrieval fails, directly creating a new page data file may lead to low usage efficiency of the page data file in use, causing unnecessary space waste. Therefore, there is still room for improvement.

[0005] The above information disclosed in this background art is only used to increase the understanding of the background art of the present application. Therefore, it may include prior art that is not known to those of ordinary skill in the art. Summary of the Invention

[0006] In view of the above problems, the present invention provides a processing method, a storage medium and a device for a database that can overcome or partially solve the above problems.

[0007] One object of the first aspect of the present invention is to make the management of the page data file more concise.

[0008] Another object of the first aspect of the present invention is to clean up the invalid data area in the page data file.

[0009] Another object of the first aspect of the present invention is to reasonably switch to a new page data file.

[0010] Specifically, according to the first aspect of the present invention, the present invention provides a processing method for a database. The database pre-creates a page data file, and the page data file is used to store the page data separated from the transaction log of the database. The processing method includes:

[0011] Monitoring the running state of the database;

[0012] When the running state is normal operation, record the file information of the page data file into the shared memory;

[0013] When the running state is about to shut down, record the file information of the page data file into the page data file;

[0014] When the running state is restart, obtain the file information of the page data file from the page data file;

[0015] If the acquisition is successful, determine that the database was normally shut down before restart, and record the obtained file information into the shared memory.

[0016] Optionally, after the step of obtaining the file information of the page data file from the page data file, it further includes:

[0017] If the acquisition fails, determine that the database was abnormally shut down before restart;

[0018] Check whether there is a page data file in use;

[0019] If there is, check whether the page data file in use has completed the write task;

[0020] If completed, switch to a new page data file;

[0021] Record the file information of the new page data file into the shared cache.

[0022] Optionally, after the step of checking whether the page data file in use has completed the write task, it further includes:

[0023] If not completed, check whether there is a data area in the page data file in use;

[0024] If there is, clean the invalid data area in the data area;

[0025] Optionally, the step of cleaning the invalid data area in the data area includes:

[0026] Check whether there is a transaction log to be redone in the abnormal recovery process of the database;

[0027] If there is, obtain the sequence number of the last transaction log to be redone, denoted as the reference sequence number;

[0028] Delete the page data in the page data file whose sequence number is greater than the reference sequence number.

[0029] Optionally, after the step of checking whether there is a transaction log to be redone in the abnormal recovery process of the database, it further includes:

[0030] If not, record the sequence number of the last valid transaction log as the reference sequence number.

[0031] Optionally, after the step of cleaning the invalid data areas in the data area, the method further includes:

[0032] Check whether there is a valid data area in the page data file being used;

[0033] If there is, traverse the valid data areas in the data area;

[0034] Record the file information of the page data file being used into the shared memory.

[0035] Optionally, after the step of checking whether there is a valid data area in the page data file being used, the method further includes:

[0036] If not, delete the page data file being used.

[0037] Optionally, the page data file includes a file header and a data area, and the file information of the page data file is recorded into the file header.

[0038] According to a second aspect of the present invention, there is provided a machine-readable storage medium having a machine-executable program stored thereon, and when the machine-executable program is executed by a processor, any one of the above database processing methods is implemented.

[0039] According to a third aspect of the present invention, there is provided a computer device including a memory, a processor, and a machine-executable program stored on the memory and running on the processor, and when the processor executes the machine-executable program, any one of the above database processing methods is implemented.

[0040] The database processing method of the present invention monitors the running state of the database. When the running state is normal operation, it records the file information of the page data file into the shared memory. When the running state is about to be closed, it records the file information of the page data file into the page data file. When the running state is restart, it obtains the file information of the page data file from the page data file. If the acquisition is successful, it indicates that the database was normally closed before restart, and then records the obtained file information into the shared memory. Thus, by recording the file information of the page data file into the page data file itself, the setting of the temporary file can be cancelled, which is beneficial to optimizing the management of the page data file and reducing the management complexity of the page data file.

[0041] Further, in the method for processing the database of the present invention, after checking whether the page data file being used has completed the write task, if it is found that the page data file being used has not completed the write task, it is possible to further check whether there is a data area in the page data file. If there is, the invalid data area in the data area is cleared. Thus, the storage space of the page data file can be released, the data quality in the page data file can be improved, which is beneficial to maintaining the integrity and accuracy of the data.

[0042] Furthermore, in the method for processing the database of the present invention, when there is a transaction log to be redone, the sequence number of the last transaction log to be redone is recorded as the reference sequence number, and then the page data in the page data file with a sequence number greater than the reference sequence number is deleted. When there is no transaction log to be redone, the sequence number of the last valid transaction log is recorded as the reference sequence number. In this way, after the database is restarted, it can continue to write page data after the reference sequence number without switching the page data file, which is beneficial to improving the usage efficiency of the page data file.

[0043] Based on the following detailed description of the specific embodiments of the present invention in conjunction with the accompanying drawings, those skilled in the art will become more clear about the above and other objects, advantages and features of the present invention. Description of the Drawings

[0044] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. Moreover, throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0045] Figure 1 is a schematic structural diagram of a page data file according to an embodiment of the present invention;

[0046] Figure 2 is a schematic structural diagram of a page data file according to another embodiment of the present invention;

[0047] Figure 3 is a flowchart of a method for processing a database according to an embodiment of the present invention;

[0048] Figure 4 is a flowchart of a method for processing a database when the file information acquisition of the page data file fails;

[0049] Figure 5 is a schematic diagram of a machine-readable storage medium according to an embodiment of the present invention;

[0050] Figure 6 is a schematic diagram of a computer device according to an embodiment of the present invention.

[0051] Reference Numerals:

[0052] 10. Machine-readable storage medium; 11. Machine-executable program; 20. Computer device; 210. Processor; 220. Memory. Detailed implementation manners

[0053] Those skilled in the art should understand that the embodiments described below are only a part of the embodiments of the present invention, rather than all the embodiments of the present invention. This part of the embodiments is intended to explain the technical principles of the present invention and is not intended to limit the protection scope of the present invention. Based on the embodiments provided by the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall still fall within the protection scope of the present invention.

[0054] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other systems that can fetch instructions from the instruction execution system, apparatus, or device and execute the instructions), or used in combination with these instruction execution systems, apparatuses, or devices.

[0055] In the KingbaseES database (abbreviated as KES database), the transaction log actually refers to the XLOG log, also called the WAL (write ahead log) log. A very important function of the XLOG log is to be used to build the primary and standby database clusters. When the primary machine fails, the standby machine can immediately become the primary and take over the primary machine to continue to provide services externally.

[0056] In the present invention, to reduce the data volume of the XLOG log, a page data file, that is, a pagedata file, can be pre-created in the database. In the assembly stage of the XLOG log, the page data in the XLOG log is separated and continuously stored in the page data file.

[0057] Figure 1 is a schematic structural diagram of a page data file according to an embodiment of the present invention, Figure 2 is a schematic structural diagram of a page data file according to another embodiment of the present invention;

[0058] The page data file mainly consists of two parts: a file header and a data area.

[0059] The file header may contain minLsn, maxLsn, lsn[N], ptr[N], N, and totalLen. The specific structure of the file header is not shown in the figure. For the sake of understanding, it is only described in words here.

[0060] (1) minLsn: The lsn (Log Sequence Number) recorded in the first page data data area in the current file. Here, it is the sequence number of the XLOG log corresponding to the page data.

[0061] (2) maxLsn: The lsn recorded in the last page data data area in the current file.

[0062] (3) lsn[N]: There may be multiple page data data areas in a page data file. According to minLsn and maxLsn, it can be determined whether the target page data is in the current file. When it is found that the lsn of the XLOG log corresponding to the target page data is between minLsn and maxLsn, then this page data file needs to be traversed to try to find the target page data. To speed up this process, in the page data file, except for the file header, the lsn value of the XLOG log to which the page data data area located at a fixed distance (such as 1MB) belongs is recorded every fixed distance. This lsn value is stored in the lsn[N] array.

[0063] (4) ptr[N]: ptr[i] is the starting address of the page data data area (pd_i) corresponding to lsn[i] in the page data file (i = 0, 1,..., N - 1). Its purpose is to quickly locate the starting position of the specified page data data area in the file.

[0064] (5) N: The maximum length of the lsn[] and ptr[] arrays. For example, if the page data file size is 64MB and the interval is 1MB, then N = 64MB / 1MB = 64. It can be seen that after the page data file size and interval are fixed, N is a fixed value.

[0065] (6) totalLen: The total length of the valid data area plus the header of the current file, that is, the total length of each independent page data data area plus the file header length.

[0066] The data area is further divided into a valid data area and an unused area. The valid data area stores the page data area, while the unused part has no page data-related data. There are two main reasons for the unused part: one is that when the remaining space of the current file is not enough to store a complete page data area, a new file will be switched to store this page data area; the other is that in some scenarios, the page data file will be forcibly switched, which will also result in an unused area in the page data file.

[0067] The file header is at the very front of the file, and then each page data area is stored in sequence. It should be noted that each page data area is stored in ascending order of its lsn. During the XLOG log assembly stage, a page_data_list_local linked list node is created for each pagedata, and then the page data and related information are respectively placed into the page_data_list_local linked list node. Finally, these linked list nodes are connected in the order of their page data in the XLOG log to form the page_data_list_local linked list of the current XLOG log, and then the page_data_list_local linked list is connected to the end of the current XLOG log assembly linked list.

[0068] The content of each linked list node can include: RelFileNode, BlockNumber, page data header, page data, len, and lsn.

[0069] (1) RelFileNode: The location information of the table where the page corresponding to the page data is located on the data disk.

[0070] (2) BlockNumber: The block number of the page corresponding to the page data in the table to which it belongs. BlockNumber and RelFileNode together determine the position of the page on the data disk. When searching, a version of the target page data can be determined based on these two values.

[0071] (3) page data header: The header information corresponding to the page data in the XLOG log. This part of information will also be recorded in the XLOG log that needs to record the pagedata. This part is mainly reserved for subsequent support of block repair.

[0072] (4) page data: The page data in the XLOG log.

[0073] (5) len: The total length of the current page data data area (including RelFileNode, BlockNumber, page data header, page data, lsn, len). It can be used to calculate the starting address of the next page data data area in the file and is used when traversing the file.

[0074] (6) lsn: The starting position of the XLOG log where the page data is located.

[0075] The creation of a page data file can include the following content:

[0076] 1. Creation timing

[0077] (1) When the database is initialized, the first page data file is created.

[0078] (2) When the previous page data file is used up, a new file is created.

[0079] (3) When the use of the previous page data file is forcibly ended and there is new page data to be written to disk, a new file is created.

[0080] 2. Creation process

[0081] (1) Confirm the N value (such as 64MB / 1MB).

[0082] (2) Initialize the file header and fill in the N field.

[0083] 3. Creation optimization

[0084] Introduce a pre-creation mechanism, similar to the pre-creation of XLOG log files.

[0085] Switching of page data files:

[0086] 1. Switching timing

[0087] (1) When the space of the current page data file is used up, switch the page data file.

[0088] (2) Before performing a base backup, switch the page data file.

[0089] (3) Manually and forcibly switch the page data file.

[0090] 2. Switching process

[0091] (1) Fill in the totalLen and maxLsn fields in the online_page_data_file file header. The minLsn field can be filled in when the first page data is written.

[0092] (2) Rename the online_page_data_file file name to a string composed of timeline, minLsn, and maxLsn, such as 00000001_0_45000098_0_46000098.

[0093] (3) Obtain a new file.

[0094] (4) Update the usage information of the online_page_data_file file (including the disk location, etc.).

[0095] It should be noted here that a file naming method that can distinguish between historical page data files and online page data files can be selected. For example:

[0096] When the page data file is just created, the name is online_page_data_file.

[0097] When the page data file is normally switched, the name is changed to a string composed of timeline, minLsn, and maxLsn, such as 00000001_0_45000098_0_46000098.

[0098] timeline: The XLOG log timeline, such as 00000001. Since the XLOG logs on different timelines may have the same lsn value, it is necessary to distinguish them by the timeline;

[0099] minLsn: The lsn stored in the first page data data area of the page data file, such as 0_45000098. The 32 high bits of the lsn are in front of the underscore, and the 32 low bits of the lsn are behind the underscore;

[0100] maxLsn: The lsn stored in the last page data data area of the page data file, such as 0_46000098. The 32 high bits of the lsn are in front of the underscore, and the 32 low bits of the lsn are behind the underscore.

[0101] Figure 3 It is a schematic diagram of a database processing method according to an embodiment of the present invention. As Figure 3 shown, the database processing method may include the following steps S302 to step S310.

[0102] Step S302, monitor the running status of the database.

[0103] Step S304, when the running status is normal operation, record the file information of the page data file into the shared memory.

[0104] Step S306, when the running status is about to shut down, record the file information of the page data file into the page data file.

[0105] Step S308, when the running status is restart, obtain the file information of the page data file from the page data file.

[0106] Step S310, if the acquisition is successful, determine that the database was normally shut down before restart, and record the acquired file information into the shared memory.

[0107] For the processing method of the database in this embodiment, by monitoring the running status of the KES database, it is possible to know whether the KES database is operating normally, about to shut down, or restarting.

[0108] When the KES database is operating normally, record the file information of the page data file into the shared memory. At this time, the content of the file information in the page data file is empty. The shared memory is an area shared by multiple processes. Recording the file information into the shared memory can ensure that other processes or components can quickly access this information.

[0109] When the KES database is about to shut down, record the file information of the page data file into the page data file. The page data file has an area for temporarily storing its file information so that these information can be reloaded and used after the database restarts.

[0110] When the KES database restarts, its file information can be obtained from the page data file. If the acquisition is successful, it means that the database was normally shut down before restart. At this time, the acquired file information can be recorded into the shared memory.

[0111] Thus, the setting of temporary files can be cancelled, which is beneficial to optimizing the management of the page data file and reducing the management complexity of the page data file. At the same time, recording the file information of the page data file into the page data file safely and effectively is beneficial to clearly mastering the usage situation of the page data file.

[0112] The file information of the page data file may include: file name, file path, the end address of the last disk-written data area in the file, and the remaining storage space of the file.

[0113] In an alternative embodiment, the file information can be stored in the totalLen field of the page data file. The file name of the page data file being used can be denoted as online_page_data_file. The path of the directory where the file is located can be denoted as sys_wal / wal_pagedata. The end address of the page data data area where the file was last flushed to disk can be denoted as flushed_to. The remaining storage space of the file can be denoted as remained_len.

[0114] In this way, in practical applications, after the database is restarted, by obtaining the file information in the page data file, the position information where the last file write was aborted can be accurately known to ensure data consistency and integrity.

[0115] In an alternative embodiment, after obtaining the file information of the page data file from the page data file, if the acquisition fails, it indicates that the database was abnormally shut down before restart. At this time, it can be checked whether there is a page data file being used. If there is, it is further checked whether the page data file being used has completed the write task. If it has, a new page data file is switched, and then the file information of the new page data file is recorded in the shared cache.

[0116] That is to say, in the case where the database was abnormally shut down before restart, if there is a page data file being used, it can be checked whether the page data file has completed the write task. If it has, it means that the switching opportunity of the page data file is met at this time. A new page data file can be switched, and the file information of the new page data file is recorded in the shared cache, and then written from the shared cache to the shared memory. In this way, the data processing efficiency can be improved, and the overall performance and response speed of the database system can be enhanced.

[0117] In an alternative embodiment, after checking whether there is a page data file being used, if it is found that there is no page data file being used, a new page data file can be directly switched, and then the file information of the new page data file is recorded in the shared cache.

[0118] The steps to check whether the page data file being used has completed the write task can be: check whether there is a minLsn (the lsn recorded in the first page data data area) and a maxLsn (the lsn recorded in the last page data data area) in the file header of the page number file. If both exist, it can be indicated that the page data file has completed the write task at this time.

[0119] In an alternative embodiment, after checking whether the page data file in use has completed the write task, if it is found that the write task is not completed, it is possible to further check whether there is a data area in the page data file in use. If there is, the invalid data areas in the data area are cleaned up. Thereby, the storage space of the page data file can be released, the data quality in the page data file can be improved, which is conducive to maintaining the integrity and accuracy of the data.

[0120] Specifically, the steps for cleaning up the invalid data areas in the data area can be as follows: Check whether there is a transaction log to be redone in the abnormal recovery process of the database. If there is, obtain the sequence number of the last transaction log to be redone, denoted as the reference sequence number, and then delete the page data in the page data file whose sequence number is greater than the reference sequence number.

[0121] Furthermore, if there is no transaction log to be redone, the sequence number of the last valid transaction log can be denoted as the reference sequence number.

[0122] In this way, after the database restarts, it can automatically continue writing page data after the reference sequence number without switching the page data file, which is conducive to improving the usage efficiency of the page data file.

[0123] After cleaning up the invalid data areas in the data area, it is also possible to check whether there is a valid data area in the page data file in use. If there is a valid data area, traverse the valid data areas in the data area, and then record the file information of the page data file in use into the shared memory. If there is no valid data area, directly delete the page data file in use.

[0124] The fact that there are still valid data areas in the page data file indicates that the page data file has been partially occupied. The purpose of traversing the valid data areas in the data area is to obtain and set the minLsn (the lsn recorded in the first page data data area), maxLsn (the lsn recorded in the last page data data area), and totalLen (the total length of each independent pagedata data area plus the file header length) of this file, so as to record its file information into the shared memory.

[0125] In addition, after obtaining the file information of the page data file from the page data file, if the acquisition is successful, it indicates that the database was shut down normally before restarting. Record the obtained file information into the shared memory, and then it is also possible to delete the file information recorded in the page data file to reduce the data volume.

[0126] In the technical solution of the present invention, the temporary file is removed, and the file information of the page data file recorded in the temporary file is directly recorded into the totalLen field at the head of the page data file. totalLen records the total length of the valid data area plus the head of the current page data file, and this value is only set when the file is switched. Before the file is switched, this field is empty. And when the file is switched, in fact, the values of flushed_to and totalLen are equal. Therefore, the value of flushed_to can be directly stored in the totalLen field, which will not affect the normal use of the totalLen field. And remained_len = 64MB - flushed_to, so remained_len does not need to be directly recorded, but can be obtained by calculation.

[0127] Figure 4 It is a flowchart of the processing method of the database when the file information acquisition of the page data file fails. As Figure 4 shown, the processing method at least includes the following steps S402 to step S422.

[0128] Step S402, the file information acquisition fails, and it is determined that the database was abnormally shut down before restarting.

[0129] Step S404, check whether there is a page data file in use. If there is, execute step S406. If not, execute step S408.

[0130] Step S406, check whether the page data file in use has completed the write task. If it has, execute step S408. If not, execute step S412.

[0131] Step S408, switch to a new page data file.

[0132] Step S410, record the file information of the new page data file into the shared cache.

[0133] Step S412, check whether there is a data area in the page data file in use. If so, execute step S414. If not, execute step S422.

[0134] Step S414, clean up the invalid data area in the data area.

[0135] Step S416, check whether there is a valid data area in the page data file in use. If so, execute step S418. If not, execute step S422.

[0136] Step S418, traverse the valid data areas in the data area.

[0137] In this step, the purpose of traversing the valid data area in the data area is to obtain and set the minLsn, maxLsn, and totalLen of the current page data file.

[0138] Step S420, record the file information of the page data file in use into the shared memory.

[0139] In this step, at this time, the content regarding the file information in the totalLen field is empty, and this page data file can be used subsequently.

[0140] Step S422, delete the page data file in use.

[0141] Thus, a method for cleaning the page data file in use after a database crash is given, which can ensure that the database can correctly recover and manage the page data file after an abnormal shutdown, and ensure the integrity of the data and the stability of the system.

[0142] This embodiment also provides a machine-readable storage medium 10 and a computer device 20. Figure 5 It is a schematic diagram of a machine-readable storage medium 10 according to an embodiment of the present invention. Figure 6 It is a schematic diagram of a computer device 20 according to an embodiment of the present invention.

[0143] A machine-executable program 11 is stored on the machine-readable storage medium 10. When the machine-executable program 11 is executed by a processor 210, it implements the processing method of the database in any of the above embodiments.

[0144] The computer device 20 may include a memory 220, a processor 210, and a machine-executable program 11 stored on the memory 220 and running on the processor 210. When the processor 210 executes the machine-executable program 11, it implements the processing method of the database in any of the above embodiments.

[0145] It should be noted that the logic and / or steps represented in the flowchart or described in other ways herein, for example, can be considered as a definite sequence list of executable instructions for implementing logical functions, and can be specifically implemented in any machine-readable storage medium 10 for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor 210, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or in combination with these instruction execution systems, apparatus, or devices.

[0146] For the purposes of the description of this embodiment, the machine-readable storage medium 10 can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection (electronic device) having one or more wirings, a portable computer diskette (magnetic device), a random access memory 220 (RAM), a read-only memory 220 (ROM), an erasable programmable read-only memory 220 (EPROM or flash memory 220), an optical fiber device, and a portable compact disc read-only memory 220 (CDROM). Additionally, the machine-readable storage medium 10 can even be paper or other suitable medium on which a program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpretation, or otherwise processing as appropriate, and then stored in a computer memory 220.

[0147] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware, or a combination thereof. In the above-described embodiment, multiple steps or methods can be implemented by software or firmware stored in the memory 220 and executed by a suitable instruction execution system.

[0148] The computer device 20 can be, for example, a server, a desktop computer, a laptop computer, a tablet computer, or a smartphone. In some examples, the computer device 20 can be a cloud computing node. The computer device 20 can be described in the general context of computer system-executable instructions, such as program modules, executed by a computer system. Generally, program modules can include routines, programs, object programs, components, logic, data structures, etc. that perform specific tasks or implement specific abstract data types. The computer device 20 can be implemented in a distributed cloud computing environment where tasks are performed by remote processing devices linked through a communication network. In a distributed cloud computing environment, program modules can be located on local or remote computing system storage media including storage devices.

[0149] The computer device 20 can include a processor 210 adapted to execute stored instructions and a memory 220 that provides temporary storage space for the operation of the instructions during operation. The processor 210 can be a single-core processor 210, a multi-core processor 210, a computing cluster, or any other number of other configurations. The memory 220 can include a random access memory 220 (RAM), a read-only memory 220, a flash memory, or any other suitable storage system.

[0150] The processor 210 may be connected via a system interconnect (such as PCI, PCI-Express, etc.) to an I / O interface (input / output interface) adapted to connect the computer device 20 to one or more I / O devices (input / output devices). The I / O devices may include, for example, a keyboard and a pointing device, where the pointing device may include a touchpad or a touch screen, etc. The I / O devices may be built-in components of the computer device 20, or may be devices externally connected to the computing device.

[0151] The processor 210 may also be linked via a system interconnect to a display interface adapted to connect the computer device 20 to a display device. The display device may include a display screen as a built-in component of the computer device 20. The display device may also include a computer monitor, a television, a projector, etc. externally connected to the computer device 20. In addition, a network interface controller (NIC) may be adapted to connect the computer device 20 to a network via a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as Internet Small Computer System Interface, etc.) to transmit data. The network may be a cellular network, a radio network, a wide area network (WAN), a local area network (LAN), or the Internet, etc. Remote devices may be connected to the computing device via the network.

[0152] At this point, those skilled in the art should recognize that although numerous exemplary embodiments of the present invention have been shown and described in detail herein, many other variations or modifications consistent with the principles of the present invention can still be directly determined or derived from the disclosed content of 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 construed as covering all such other variations or modifications.

Claims

1. A method for processing a database, where a page data file is pre-created in the database, and the page data file is used to store page data separated from the transaction log of the database. The processing method includes: Monitoring the running state of the database; When the running state is normal operation, recording the file information of the page data file into the shared memory; When the running state is about to be closed, recording the file information of the page data file into the page data file; When the running state is restarting, obtaining the file information of the page data file from the page data file; If the obtaining is successful, determining that the database was normally closed before restarting, and recording the obtained file information into the shared memory.

2. The processing method of the database according to claim 1, wherein, After the step of obtaining the file information of the page data file from the page data file, it further includes: If the obtaining fails, determining that the database was abnormally closed before restarting; Checking whether there is a page data file in use; If there is, checking whether the page data file in use has completed the write task; If completed, switching to a new page data file; Recording the file information of the new page data file into the shared cache.

3. The processing method of the database according to claim 2, wherein, After the step of checking whether the page data file in use has completed the write task, it further includes: If not completed, checking whether there is a data area in the page data file in use; If there is, cleaning the invalid data areas in the data area.

4. The processing method of the database according to claim 3, wherein, The step of cleaning the invalid data areas in the data area includes: Checking whether there is a transaction log to be redone in the abnormal recovery process of the database; If there is, obtaining the sequence number of the last transaction log to be redone, denoted as the reference sequence number; Deleting the page data in the page data file whose sequence number is greater than the reference sequence number.

5. The processing method of the database according to claim 4, wherein, After the step of checking whether there is a transaction log to be redone in the abnormal recovery process of the database, it further includes: If not, denoting the sequence number of the last valid transaction log as the reference sequence number.

6. The processing method of the database according to claim 3, wherein, After the step of cleaning the invalid data areas in the data area, it further includes: Checking whether there is a valid data area in the page data file in use; If there is, traversing the valid data areas in the data area; Recording the file information of the page data file in use into the shared memory.

7. The processing method of the database according to claim 6, wherein, After the step of checking whether there is a valid data area in the page data file in use, it further includes: If not, deleting the page data file in use.

8. According to the method for processing a database according to claim 1, wherein, The page data file includes a file header and a data area, and the file information of the page data file is recorded into the file header.

9. A machine-readable storage medium, on which a machine-executable program is stored, and when the machine-executable program is executed by a processor, it implements the mathematical method of the database according to any one of claims 1 to 8.

10. A computer device, comprising a memory, a processor, and a machine-executable program stored on the memory and running on the processor, and when the processor executes the machine-executable program, implementing the method for processing the database according to any one of claims 1 to 8.