CN115599756A - Data writing method, storage medium and device for database - Google Patents
Data writing method, storage medium and device for database Download PDFInfo
- Publication number
- CN115599756A CN115599756A CN202211327411.2A CN202211327411A CN115599756A CN 115599756 A CN115599756 A CN 115599756A CN 202211327411 A CN202211327411 A CN 202211327411A CN 115599756 A CN115599756 A CN 115599756A
- Authority
- CN
- China
- Prior art keywords
- data
- double
- page
- write
- writing
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/17—Details of further file system functions
- G06F16/172—Caching, prefetching or hoarding of files
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/18—File system types
- G06F16/1805—Append-only file systems, e.g. using logs or journals to store data
- G06F16/1815—Journaling file systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/901—Indexing; Data structures therefor; Storage structures
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Human Computer Interaction (AREA)
- Software Systems (AREA)
- Quality & Reliability (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a data flashing method, a storage medium and equipment of a database. The data flashing method of the database comprises the following steps: copying a page to be flushed into a disk in the buffer pool into a pre-configured double-write buffer area in a memory; acquiring a trigger event for starting data brushing; writing the data of the double-write buffer area into a double-write file configured in advance in a table space of a disk; judging whether the process of writing the data into the double-write file is successfully completed or not; and if so, writing the data in the double writing buffer areas into a data file of the disk. The scheme of the invention can effectively avoid the page fracture condition and can also avoid the expansion problem of the WAL log file.
Description
Technical Field
The invention relates to the technical field of databases, in particular to a data flashing method, a storage medium and equipment of a database.
Background
When the page in the database buffer pool is modified, the changed page in the buffer pool needs to be synchronized to the database data file on the corresponding disk, so as to persistently store the updating operation of the user on the data. In addition, the database system needs to configure a buffer replacement policy, and when a new page is read in from the buffer pool, part of old data in the buffer pool needs to be eliminated and replaced with new data, so as to improve the hit rate of the cache.
In the process that the database system refreshes the page of the buffer pool to the disk file, the problem of page fracture may exist. The reason for this problem is that: the page size of a typical operating system is 4KB, while a database typically sets the page size to 8KB or 16KB, and when a page block of a database is flushed to a file system, the file system may perform 2 or 4 write operations to complete the write operation of the page block of the database.
The flush procedure after completing the flush of the previous pages, if the operating system fails for some reason, the following pages are not successfully flushed to the disk file. That is, the partial page write succeeds, the partial page write fails, and a page break occurs. The root cause of such failures is that the page size used by the database is not consistent with the page size of the operating system, so that the operating system needs to use multiple IO operations to write a page of the database to the disk file.
For the problem of Page fragmentation, some databases in the prior art use Full Page Write technology. This technique is accomplished by storing all page blocks that were first modified in their entirety into a WAL (Write Ahead Log) file after each checkpoint. If a fault occurs during data writing, the aim of recovering the data can be achieved by reading the page block stored in the WAL file and combining the page block with the redo log. However, this method will store a large number of pages of the database in the WAL log file, which will cause the expansion of the WAL file space and occupy too much disk space.
Disclosure of Invention
An object of the present invention is to provide a method, a storage medium, and an apparatus for flushing data in a database, which can solve any of the above problems.
A further object of the present invention is to avoid that the WAL file occupies too much disk space due to the whole page write.
It is another further object of the present invention to avoid page fragmentation problems that occur during a page flush to a disk file.
Particularly, the invention provides a data flashing method of a database, which comprises the following steps:
copying a page to be flushed into a disk in the buffer pool into a pre-configured double-write buffer area in a memory;
acquiring a trigger event for starting data brushing;
writing the data of the double-write buffer area into a double-write file pre-configured in a table space of a disk;
judging whether the process of writing the data into the double-write file is successfully completed or not;
and if so, writing the data in the double writing buffer areas into the data file of the disk.
Optionally, the page to be flushed to the disk includes a dirty page and a cache obsolete page; the double-writing buffer area comprises a dirty page buffer area and a rejected page buffer area; and the double-write file includes a dirty page double-write file and an obsolete page double-write file.
Optionally, dirty page buffers and obsolete page buffers are applied by the database system to the operating system, and
the size of the dirty page double-writing file is configured to be consistent with the size of the dirty page buffer area, and the size of the eliminated page double-writing file is configured to be consistent with the size of the eliminated page buffer area.
Optionally, the acquiring a trigger event for starting data scrubbing includes:
detecting the quantity of dirty pages which are not flushed in a pre-configured dirty page queue;
and acquiring a disk-brushing event of which the number of the dirty pages exceeds a set threshold.
Optionally, the acquiring a trigger event for starting data scrubbing includes: and obtaining a buffer page replacement event of the database, and determining a cache elimination page.
Optionally, in a case that the process of writing data into the double-write file fails, the method further includes: determining that the data write operation is invalid; and writing the data of the double-writing buffer into the double-writing file again according to the log check point and the redo log.
Optionally, after the step of writing the data of the double write buffer into the data file of the disk, the method further includes:
judging whether the process of writing data into the data file is successfully completed or not;
if not, performing data recovery according to the data of the double-write file and the redo log.
Optionally, in a case that the process of writing the data into the data file is successfully completed, it is determined that the data is successfully flushed;
the status information of the buffer pool, the double write file, and the double write buffer is updated.
According to another aspect of the present invention, there is also provided a machine-readable storage medium having stored thereon a machine-executable program which, when executed by a processor, implements a data flashing method for a database according to any of the above.
According to yet another aspect of the present invention, there is also provided a computer device, including a memory, a processor, and a machine executable program stored on a data brushing method memory of a database and running on a data brushing method processor of the database, and when the data brushing method processor of the database executes the data brushing method machine executable program of the database, the data brushing method according to any one of the above-mentioned databases is implemented.
The data flushing method of the database comprises the steps of configuring a double-write buffer area in a memory in advance, configuring a double-write file in a table space of a disk, wherein the double-write buffer area is used for copying a page to be flushed into the disk in the buffer area, and when data flushing is carried out, the page in the double-write buffer area is firstly written into the double-write file and then written into the data file of the disk. The two writing processes of the Page in the double-writing buffer area can effectively avoid the Page fracture condition, and can also avoid the problem of expansion of the WAL log file caused by a Full _ Page _ Write scheme adopted by a similar PostgreSQL database.
Further, the data disk-flushing method of the database of the present invention sets a dirty page buffer area and a dirty page double-write file respectively for dirty pages (pages modified in the memory after the last check point) and cache obsolete pages (pages to be replaced out of the buffer pool due to capacity problems), and the obsolete page buffer area and the obsolete page double-write file simultaneously satisfy the disk-flushing requirements of the dirty pages and the obsolete pages.
Furthermore, the data flashing method of the database judges whether to recover the data by determining the state of the data file and the data writing double-write file of the double-write buffer area. That is, if the writing of the double-write file is successful and the writing of the data file is also successful, the operation of flushing dirty or replacing eliminated pages is determined to be successful; if writing the dual write file is successful but writing the data file fails, then the data is recovered by combining the dual write file on the disk with the redo log. If the double-write file writing fails, the operation of flushing dirty or replacing eliminated pages is not executed, and the data can be recovered according to the check points and the redo logs, so that the data can be reliably written into the disk, and the reliability of the database is improved.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof taken in conjunction with the accompanying drawings.
Drawings
Some specific embodiments of the invention will be described in detail hereinafter by way of example and not by way of limitation with reference to the accompanying drawings. The same reference numbers in the drawings identify the same or similar elements or components. Those skilled in the art will appreciate that the drawings are not necessarily drawn to scale. In the drawings:
FIG. 1 is a schematic flow diagram of a data flushing method for a database according to one embodiment of the invention;
FIG. 2 is a data flow diagram of a data flushing method of a database according to the prior art;
FIG. 3 is a data flow diagram illustrating a successful completion of a data flush method for a database according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating a data recovery method for a database according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of a machine-readable storage medium according to one embodiment of the invention; and
FIG. 6 is a schematic diagram of a computer device according to one embodiment of the invention.
Detailed Description
It should be understood by those skilled in the art that the embodiments described below are only a part of the embodiments of the present invention, not all of the embodiments of the present invention, and the part of the embodiments are intended to explain the technical principles of the present invention and not to limit the scope of the present invention. All other embodiments, which can be obtained by a person skilled in the art based on the embodiments provided by the present invention without inventive effort, shall still fall within the scope of protection of the present invention.
FIG. 1 is a schematic flow chart diagram of a data flushing method of a database according to one embodiment of the invention. The data flashing method of the database generally comprises the following steps:
and step S102, copying the page to be flushed into the disk in the buffer pool into a pre-configured double-write buffer area in the memory.
The page to be flushed to the disk includes a dirty page in the buffer pool and a cache eviction page, where the dirty page is a modified page in the buffer pool, that is, a page in the buffer pool where data may not be consistent with a data file in the disk, the cache eviction page needs to be replaced out of the buffer pool due to a capacity problem, the cache eviction page may be determined by using various buffer replacement algorithms, for example, LRU (Least Recently Used), LFU (Least Frequently Used), FIFO (First Input First Output, first in First out in this embodiment), and the like. In the method of this embodiment, the double write buffer is configured with a dirty page buffer for dirty pages, and an evicted page buffer for cache evicted pages.
The dirty page buffer and the obsolete page buffer may be applied to the operating system by the database system when the database system is started, and the occupied space may be set according to the processing capabilities of the database, the operating system, and the memory, for example, the default size may be configured to 2MB.
And step S104, acquiring a trigger event for starting data brushing. The trigger event is used for triggering data to be flushed.
For example, for a dirty page, the step of acquiring a trigger event that initiates a data flush may include: detecting the quantity of dirty pages which are not flushed in a pre-configured dirty page queue; and acquiring a disk-brushing event of which the number of the dirty pages exceeds a set threshold.
For another example, for a cache eviction page, acquiring a trigger event for starting data flushing includes: and obtaining a buffer page replacement event of the database, and determining a cache elimination page.
And step S106, writing the data of the double-writing buffer area into a double-writing file configured in advance in a table space of the disk. In the method of this embodiment, the double-write file is configured with the dirty-page double-write file for the dirty pages, and is configured with the obsolete-page double-write file for the cache obsolete pages. The size of the dirty page double-write file is configured to be consistent with the size of the dirty page buffer, and the size of the obsolete page double-write file is configured to be consistent with the size of the obsolete page buffer, and the specific size may be configured according to the processing capabilities of the database and the operating system, for example, the default configuration is 2MB, and may also be adjusted in some embodiments.
Step S108, judging whether the process of writing the data into the double-write file is successfully completed;
and step S110, writing the data in the double-write buffer into the data file of the disk under the condition that the data is successfully written into the double-write file.
The data flushing method of the database of the embodiment is characterized in that a double-write buffer area is configured in a memory in advance, a double-write file is configured in a table space of a disk, the double-write buffer area is used for copying a page to be flushed into the disk in the buffer area, and when data flushing is performed, the page in the double-write buffer area is firstly written into the double-write file and then written into a data file of the disk. The two writing processes of the page in the double-writing buffer area can effectively avoid the page fracture condition and can also avoid the expansion problem of the WAL log file.
In the case that it is determined that the process of writing data into the double-write file fails, the data flushing method of the database of this embodiment may further include: determining that the data write operation is invalid; and writing the data of the double-writing buffer into the double-writing file again according to the log check point and the redo log. That is, if writing a double write file fails, then this flush or swap out obsolete page operation may be deemed not to be performed, which may restore data based on the checkpoint and the redo log.
After the step of writing the data in the double write buffer into the data file of the disk, the solution of this embodiment may further include: judging whether the process of writing the data into the data file is successfully completed or not; and if not, performing data recovery according to the data of the double-write file and the redo log. That is, if writing a double write file succeeds, but writing the data file fails, the data can be recovered by combining the double write file on the disk with the redo log. In this case, the double write file stores a copy of the written page blocks, which we can use for data recovery. For example, when the database is restored, a copy of the page is first obtained from the double-write file of the disk, and is loaded into the data buffer pool, and then data restoration can be realized by applying the redo log.
Under the condition that the process of writing the data into the data file is successfully completed, judging that the data is successfully written; at this point, the buffer pool, the double write file, and the status information of the double write buffer may be updated for preparing the next data flush. The status information of the buffer pool, the double write file, and the double write buffer may include an identification for determining various statuses of the buffer pool, the double write file, and the double write buffer. The writing process of the data file is identified by updating the state information.
The dirty pages and the eliminated pages are respectively stored by two double-write buffer areas and two double-write files, so that the performance bottleneck caused by sharing the double-write files can be effectively reduced.
The method of the present embodiment introduces: dirty page double write Buffer (Dirty double write Buffer), obsolete page double write Buffer (LRU double write Buffer), dirty page double write File (Dirty double write File), obsolete page double write File (LRU double write File). These memory spaces and disk files are important differences of the method of this embodiment with respect to the prior art, and reliability of the database is provided by these memory spaces and disk files, and page breaks are avoided.
A Dirty page double write Buffer (Dirty double write Buffer) is a region in the memory, the size of the space can be regarded as 2MB by default (those skilled in the art can adjust the size of the space as needed), and the Dirty page double write Buffer is applied to an Operating System (abbreviated as OS) during the starting process of the database and is used for storing the Dirty page data written from the Dirty page queue.
A Dirty page double write File (Dirty double write File), which is a File in a tablespace, the space size is 2MB by default (those skilled in the art can adjust the size of the Dirty page double write File as needed), and the Dirty page double write File is used for storing data written by the double write Buffer.
The process of writing out dirty pages to disk includes:
and copying the dirty pages in the dirty page data buffer queue to a dirty page double-writing buffer area in the memory.
When the dirty page double-writing buffer area is exhausted or triggered by other conditions (timed time arrives or other processes are awakened), writing the data in the dirty page double-writing buffer area into a dirty page double-writing file in the tablespace;
and if the dirty page double-writing file is successfully written, writing the data into the data file of the database from the page double-writing buffer area.
A obsolete page double write Buffer (LRU double write Buffer), which is another area in the memory, the space size defaults to 2MB (the size of the space can be adjusted by those skilled in the art according to the needs), and during the database boot process, the OS is applied for the dirty page data written from the LRU queue during the database boot process.
The double write File (LRU double write File) of the obsolete page, whose one File space size on the table space is defaulted to 2MB (the size of which can be adjusted by those skilled in the art as needed), is used for storing the data written by the LRU double write buffer.
The process of writing the eliminated pages out to the disk comprises the following steps:
and copying the eliminated pages in the eliminated page buffer queue to an eliminated page double-write buffer area in the memory.
And when the eliminated page double-write buffer is used up or triggered by other conditions (timed out or awakened by other processes), writing the data in the eliminated page double-write buffer into an eliminated page double-write file in the table space.
And if the double-write file of the eliminated page is successfully written, writing the data into the data file of the database.
The following three situations may occur when data of dirty pages and obsolete pages are flushed:
case 1, write double write file is successful, write data file is successful. Indicating successful smudging.
Case 2, write double write file fails. The page is not written into the data file, the data file is not damaged, the database considers that the disk refreshing operation is invalid, and data redo can be realized by combining the check point and the redo log.
Case 3, write double write file was successful, but write data file failed. In this case, a copy of the written page blocks is stored in the double-write file and can be used for data recovery. When the database is recovered, firstly, a copy of the page is obtained from the double-write file of the disk, and is loaded into the data buffer pool, and then the purpose of data recovery is realized by applying the redo log.
The data scrubbing method of the database of the embodiment is described below with reference to data flow. Fig. 2 is a data flow diagram of a data disk refreshing method of a database according to the prior art, fig. 3 is a data flow diagram of a data disk refreshing method of a database successfully completing disk refreshing according to an embodiment of the present invention, and fig. 4 is a schematic diagram of data recovery by the data disk refreshing method of the database according to an embodiment of the present invention.
As shown in fig. 2, in the prior art, the buffer pool 210 directly writes the sorted dirty pages page1, page2, page3, and page4 into the data file 221 of the disk 220, and if the size of the page1, page2, page3, and page4 of the buffer pool 210 is 16KB and the page size of the operating system is 4KB, 4 operations are required to complete the operation of writing one page, and then page fragmentation situations that the previous writing succeeds and the later writing does not succeed may occur. The Full _ Page _ Write technique is to store all the first modified Page blocks into the redo log file 222 after each checkpoint, and to recover the entire data by using the redo log file 222 and the redo log buffer 211 after a failure occurs.
In the data flushing method for the database of this embodiment, the dirty page queue 212, the cache eviction page 213, the dirty page double-write buffer 214, and the eviction page double-write buffer 215 are introduced into the buffer pool 210, and the dirty page double-write file 223 and the eviction page double-write file 224 are introduced into the disk 220. As shown in FIG. 3, upon successful writing of data file 221, dirty pages are copied from dirty page queue 212 to dirty page double write buffer 214, and data in dirty page double write buffer 214 is written to first write dirty page double write file 223, and then data is written from dirty page double write buffer 214 to database data file 221. Obsolete pages are copied from cache obsolete pages 213 to dirty page double-write buffer 215, data in obsolete page double-write buffer 215 is written to first write obsolete page double-write file 224, and then data is written from obsolete page double-write buffer 215 to data file 221 of the database.
When the data is restored, as shown in fig. 4, firstly, a copy of the page is obtained from the dirty page double-write file 223 or the obsolete page double-write file 224, and is reloaded into the data buffer pool, and then, data is restored by applying a redo log. Therefore, the problem of Page fracture when a dirty Page or an obsolete Page is written in the database is solved through a double-writing mechanism in the process, and the problem of expansion of the WAL log file caused by Full _ Page _ Write is also solved.
The dirty page processing is described below in conjunction with the dirty page queue processing, and those skilled in the art can correspondingly derive the obsolete page processing. The dirty page queue is a queue added for managing and recording the dirty page information in the scheme of the embodiment. The dirty page queue may be an array used cyclically in producer/consumer mode, with the head pointer (head of queue pointer) recording the position of the head of the queue and the tail pointer (tail of queue pointer) pointing to the position of the tail of the queue. Each element in the queue has a boolean variable Used that indicates that the corresponding queue position has been Used if the variable is True and that the queue position is unused if the variable is False. Each queue coordinate location may store a dirty page information.
The dirty page information may include an identification number of the dirty page (dirty page id), a log sequence number of a transaction corresponding to the dirty page (LSN of the transaction corresponding to the dirty page), state information of the dirty page (Flush State), and other related information. The condition that the dirty page id is set to 0 may be defined as that the corresponding queue element has no longer pointed to the dirty page in the buffer; the Flush State is set to False and defined as the State that the corresponding dirty page does not store the disk (unwashed State), and the Flush State is True and defined as the State that the corresponding dirty page stores the disk (flushed State). By the head pointer, the tail pointer, the variable Used, the dirty page id, the dirty page LSN and the Flush State, the condition of the dirty page of the transaction can be determined definitely, and a traversal condition is provided for subsequent disk refreshing processing.
The management process of the dirty page queue can process the dirty page queue through the following steps: starting a management process of the dirty page queue; acquiring an event triggering checkpoint processing, for example, a timed trigger or a manually triggered event may be adopted to trigger checkpoint processing; traversing the buffer pool, determining Dirty pages appearing after the last checkpoint, namely marking modified pages (pages) after the last checkpoint as Dirty pages (Dirty); adding the page information marked as the dirty pages into elements behind the tail of a dirty page queue item by item; moving a queue tail pointer of the dirty page queue backwards to point to the added last element; judging whether the quantity of the dirty pages in the dirty page queue is greater than or equal to a set threshold value C2 or not; if the judgment result exceeds C2, waking up a disk brushing process (PageWriter process) to execute a dirty brushing operation; and the management process of the dirty page queue enters sleep and waits for the next start.
The disk refreshing process can perform data disk refreshing through the following steps: triggering and starting a disk flushing process (PageWriter process), for example, triggering and starting the PageWriter process when a management process wake-up event of a dirty page queue occurs or a timing time is up; judging whether the quantity of dirty pages which are not flushed in a pre-configured dirty page queue is larger than or equal to a set threshold value C1, wherein C1 and C2 can be set to be equal; when the number of the dirty pages is judged to be larger than or equal to C1, traversing a set number (set as N) of the dirty pages from a head pointer of a dirty page queue, and sequencing the N dirty pages so as to reduce a brushing range and reduce random I/O (input/output), wherein N is the number of the dirty pages which are flushed each time and can be set to be a value smaller than or equal to C1; copying the sorted N Dirty pages to a Dirty page double write Buffer (Dirty double write Buffer); writing data in a Dirty page double-writing Buffer (Dirty double write Buffer) into a Dirty page double-writing file of a disk; after the Dirty page double-write file is successfully written, writing data in a Dirty page double-write Buffer (Dirty double write Buffer); after the data file is successfully written, setting the dirty page State information (Flush State) of the flushed dirty pages to true, and setting the Buffer Id to 0, namely resetting the State information of the Buffer pool, the double-write file and the double-write Buffer. Setting a variable Used of elements corresponding to the dirty pages as False, and recovering an unused state of the queue position for cyclic reuse; moving a head pointer (head pointer) backwards by N elements to point to the next dirty page information waiting to be brushed; updating a control file LSN; and the disk brushing process enters sleep and waits for the next starting.
The application also provides a machine-readable storage medium and a computer device. FIG. 5 is a schematic diagram of a machine-readable storage medium 50 according to one embodiment of the invention. FIG. 6 is a schematic diagram of a computer device 60 according to one embodiment of the present invention.
The machine-readable storage medium 50 has stored thereon a machine-executable program 51, and when executed by the processor, the machine-executable program 51 implements the data storage method of the database of any of the above embodiments.
The computer device 60 may comprise a memory 620, a processor 610 and a machine executable program 51 stored on the memory 620 and running on the processor 610, and the processor 610 when executing the machine executable program 51 implements the data storage method of the database of any of the embodiments described above.
It should be noted that the logic and/or steps shown in the flowcharts or otherwise described herein, such as an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any machine-readable storage medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
For the purposes of this description, a machine-readable storage medium 50 can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the machine-readable storage medium 50 include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the machine-readable storage medium 50 may even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via, for instance, optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present invention may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, the various steps or methods may be implemented in software or firmware stored in memory and executed by a suitable instruction execution system.
The computer device 60 may be, for example, a server, a desktop computer, a notebook computer, a tablet computer, or a smartphone. In some examples, computer device 60 may be a cloud computing node. Computer device 60 may be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. Computer device 60 may be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.
The computer device 60 may include a processor 610 adapted to execute stored instructions, a memory 620 that provides temporary storage for the operation of the instructions during operation. Processor 610 may be a single core processor, a multi-core processor, a computing cluster, or any number of other configurations. Memory 620 may include Random Access Memory (RAM), read only memory, flash memory, or any other suitable storage system.
The processor 610 may be connected via a system interconnect (e.g., PCI-Express, etc.) to an I/O interface (input/output interface) suitable for connecting the computer device 60 to one or more I/O devices (input/output devices). The I/O devices may include, for example, a keyboard and a pointing device, wherein the pointing device may include a touchpad or a touchscreen, among others. The I/O devices may be built-in components of the computing device 60 or may be devices that are externally connected to the computing device.
The processor 610 may also be linked through a system interconnect to a display interface adapted to connect the computer device 60 to a display device. The display device may include a display screen as a built-in component of the computer device 60. The display device may also include a computer monitor, television, or projector, etc. externally connected to the computer device 60. In addition, a Network Interface Controller (NIC) may be adapted to connect computer device 60 to a network via a system interconnect. In some embodiments, the NIC may use any suitable interface or protocol (such as an internet small computer system interface, etc.) to transfer data. The network may be a cellular network, a radio network, a Wide Area Network (WAN)), a Local Area Network (LAN), or the internet, among others. The remote device may be connected to the computing device through a network.
The flowcharts provided in this example are not intended to indicate that the operations of the method are to be performed in any particular order, or that all of the operations of the method are to be included in each case. Further, the method may include additional operations. Additional variations on the above-described method are possible within the scope of the technical ideas provided by the method of this embodiment.
Claims (10)
1. A method for scrubbing data of a database comprises the following steps:
copying a page to be flushed into a disk in the buffer pool into a pre-configured double-write buffer area in a memory;
acquiring a trigger event for starting data brushing;
writing the data of the double-write buffer area into a double-write file pre-configured in a table space of the disk;
judging whether the process of writing the data into the double-write file is successfully completed or not;
and if so, writing the data in the double writing buffer areas into the data file of the disk.
2. The data scrubbing method for a database according to claim 1,
the page to be brushed into the disk comprises a dirty page and a cache eliminated page;
the double-writing buffer area comprises a dirty page buffer area and a obsolete page buffer area; and is
The dual-write files include dirty page dual-write files and obsolete page dual-write files.
3. The data scrubbing method for a database according to claim 2,
the dirty page buffer and the obsolete page buffer are applied by the database system to an operating system, and
the size of the dirty page double-writing file is configured to be consistent with the size of the dirty page buffer area, and the size of the obsolete page double-writing file is configured to be consistent with the size of the obsolete page buffer area.
4. The database data flashing method according to claim 2, wherein the acquiring of the trigger event for starting data flashing comprises:
detecting the quantity of dirty pages which are not flushed in a pre-configured dirty page queue;
and acquiring a disk brushing event that the quantity of the dirty pages exceeds a set threshold value.
5. The database data brushing method according to claim 2, wherein the acquiring a trigger event for starting data brushing comprises:
and obtaining a buffer page replacement event of the database, and determining the cache elimination page.
6. The data flash method of the database according to claim 1, wherein in case that the process of writing the data into the double-write file fails, further comprising:
determining that the data write operation is invalid;
and writing the data of the double-writing buffer area into the double-writing file again according to the log check point and the redo log.
7. The data flushing method for the database according to claim 1, wherein after the step of writing the data of the double write buffer into the data file of the disk, further comprising:
judging whether the process of writing the data into the data file is successfully completed or not;
if not, performing data recovery according to the data of the double-write file and the redo log.
8. The method of scrubbing data of a database according to claim 7,
under the condition that the process of writing the data into the data file is successfully completed, judging that the data is successfully written;
and updating the buffer pool, the double-write file and the state information of the double-write buffer area.
9. A machine readable storage medium having stored thereon a machine executable program which when executed by a processor implements a data flushing method for a 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 run on the processor, and the processor when executing the machine executable program implements a data flushing method for a database according to any one of claims 1 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211327411.2A CN115599756A (en) | 2022-10-27 | 2022-10-27 | Data writing method, storage medium and device for database |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211327411.2A CN115599756A (en) | 2022-10-27 | 2022-10-27 | Data writing method, storage medium and device for database |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115599756A true CN115599756A (en) | 2023-01-13 |
Family
ID=84850262
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211327411.2A Pending CN115599756A (en) | 2022-10-27 | 2022-10-27 | Data writing method, storage medium and device for database |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115599756A (en) |
-
2022
- 2022-10-27 CN CN202211327411.2A patent/CN115599756A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4839091B2 (en) | Database recovery method and computer system | |
US8127174B1 (en) | Method and apparatus for performing transparent in-memory checkpointing | |
US7000229B2 (en) | Method and system for live operating environment upgrades | |
KR100204027B1 (en) | Database recovery apparatus and method using nonvolatile memory | |
US20060200500A1 (en) | Method of efficiently recovering database | |
JP4385215B2 (en) | Disk array device having snapshot simulation function | |
CN109997118B (en) | Method for storing large amount of data consistently at super high speed in permanent memory system | |
JP2006268139A (en) | Data reproduction device, method and program and storing system | |
JP2007249573A (en) | Storage system for issuing optimum i/o command to automatically expandable volume and its control method | |
CN103150267B (en) | Cache synchronization method among multiple controllers | |
CN102025758B (en) | Method, device and system for recovering data copy in distributed system | |
CN115481127A (en) | Data storage method, storage medium and equipment of database | |
CN115705152A (en) | Metadata management in non-volatile memory devices using in-memory logs | |
US20210232466A1 (en) | Storage system and restore control method | |
CN110928890B (en) | Data storage method and device, electronic equipment and computer readable storage medium | |
CN115599756A (en) | Data writing method, storage medium and device for database | |
US11074003B2 (en) | Storage system and restoration method | |
CN115705153A (en) | Conditional update and deferred lookup | |
JPH0981464A (en) | Memory fault recovering method of computer system and recovering system | |
US10656867B2 (en) | Computer system, data management method, and data management program | |
JPH0816881B2 (en) | Database update method | |
JP4204060B2 (en) | Data recovery method for information processing system and disk subsystem | |
US7934067B2 (en) | Data update history storage apparatus and data update history storage method | |
JP6627541B2 (en) | Volume management device, volume management method, and volume management program | |
JPH03265951A (en) | Trouble recovery type computer |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |