Summary of the invention
In view of this, the technical problem to be solved in the present invention is how to reduce the shared disk space of transaction journal.
In order to solve the problems of the technologies described above, first aspect, the invention provides a kind of blog management method, comprising:
When the data page of database occurs to upgrade, check in the transaction journal of described database whether have the full page log recording that described data page is corresponding;
If there is the full page log recording that described data page is corresponding in described transaction journal, in described transaction journal, record the Update log record that described data page is corresponding.
In conjunction with first aspect, in the possible implementation of the first, comprising:
If there is not the full page log recording that described data page is corresponding in described transaction journal, in described transaction journal, record full page log recording corresponding to data page after described data page is upgraded.
In conjunction with the possible embodiment of the first of first aspect or first aspect, in the possible embodiment of the second, in the transaction journal of the described database of described inspection, whether there is the full page log recording that described data page is corresponding, comprising:
According to the sequence number corresponding to described full page log recording of described data page record, search in the transaction journal of described database whether have the full page log recording that described data page is corresponding.
In conjunction with the possible embodiment of the second of first aspect, in the third possible embodiment, according to sequence number corresponding to described full page log recording recording in described data page, search in the transaction journal of described database whether have the full page log recording that described data page is corresponding, comprising:
If sequence number corresponding to described full page log recording recording in described data page is more than or equal to the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and have the full page log recording that described data page is corresponding;
If sequence number corresponding to described full page log recording recording in described data page is less than the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and do not have the full page log recording that described data page is corresponding.
In conjunction with the possible embodiment of the first of first aspect and first aspect to any one in the third possible embodiment, in the 4th kind of possible embodiment, whether there is the full page log recording that described data page is corresponding in the transaction journal that checks described database after, also comprise:
If there is the full page log recording that described data page is corresponding in described transaction journal, and described transaction journal meets the condition that again records full page log recording, in described transaction journal, again record the current full page log recording of described data page, and by described sequence number update, be the sequence number of the current full page log recording of described data page in described data page;
Wherein, the described condition that again records full page log recording comprise following any one:
From full page log recording corresponding to described data page, start to be more than or equal to the data volume threshold value of setting to the daily record data amount between log recording corresponding to the current data page upgrading;
From full page log recording corresponding to described data page, start to be more than or equal to the daily record number threshold value of setting to the daily record number between log recording corresponding to the current data page upgrading;
From full page log recording corresponding to described data page start between log recording corresponding to the current data page upgrading interval greater than or equal the duration threshold value set.
In conjunction with any one in the possible four kinds of possible embodiments of embodiment to the of the first of first aspect and first aspect, in the 5th kind of possible embodiment, also comprise:
When described data page is recovered, in described transaction journal, search the recovery starting point of described data page, described recovery starting point is the last checkpoint of recording in described transaction journal;
If adopt the Update log record of described transaction journal after described recovery starting point to occur mistake to the recovery of described data page, search sequence number corresponding to the last full page log recording of described data page the Update log record that the described data page after described recovery starting point is corresponding;
According to the sequence number finding, in described transaction journal, search the full page log recording that described data page is corresponding;
The full page log recording corresponding according to described data page, recovers described data page.
In conjunction with any one in the possible five kinds of possible embodiments of embodiment to the of the first of first aspect and first aspect, in the 6th kind of possible embodiment, described transaction journal is online daily record, and described method also comprises:
Add up the dirty page not flushing in described database in hard disk;
From all dirty pages that do not flush to hard disk, in the sequence number of the full page log recording of record, determine minmal sequence number;
In described online daily record, delete log recording sequence number than described minmal sequence number little log recording.
In order to solve the problems of the technologies described above, second aspect, the invention provides a kind of log management apparatus, comprising:
Checking module, while occurring to upgrade for data page at database, checks in the transaction journal of described database whether have the full page log recording that described data page is corresponding;
Update module, communicates with described checking module, if there is for described transaction journal the full page log recording that described data page is corresponding, in described transaction journal, records the Update log record that described data page is corresponding.
In conjunction with second aspect, in the possible implementation of the first, if described update module does not also exist for described transaction journal the full page log recording that described data page is corresponding, in described transaction journal, record full page log recording corresponding to data page after described data page is upgraded.
In conjunction with the possible embodiment of the first of second aspect or second aspect, in the possible embodiment of the second, described checking module is also for according to the sequence number corresponding to described full page log recording of described data page record, searches in the transaction journal of described database whether have the full page log recording that described data page is corresponding.
In conjunction with the possible embodiment of the second of second aspect, in the third possible embodiment, if sequence number corresponding to described full page log recording that described checking module also records for described data page is more than or equal to the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and have the full page log recording that described data page is corresponding;
If sequence number corresponding to described full page log recording that described checking module also records for described data page is less than the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and do not have the full page log recording that described data page is corresponding.
In conjunction with the possible embodiment of the first of second aspect and second aspect to any one in the third possible embodiment, in the 4th kind of possible embodiment, if also there is for described transaction journal the full page log recording that described data page is corresponding in described update module, and described transaction journal meets the condition that again records full page log recording, in described transaction journal, again record the current full page log recording of described data page, and in described data page, by described sequence number update, be the sequence number of the current full page log recording of described data page,
Described update module also starts whether to be more than or equal to the data volume threshold value of setting to the daily record data amount between log recording corresponding to the current data page upgrading for judging from full page log recording corresponding to described data page; Or
Described update module also starts whether to be more than or equal to the daily record number threshold value of setting to the daily record number between log recording corresponding to the current data page upgrading for judging from full page log recording corresponding to described data page; Or
Described update module also starts whether to be more than or equal to the duration threshold value of setting to the time interval between log recording corresponding to the current data page upgrading for judging from full page log recording corresponding to described data page.
In conjunction with any one in the possible four kinds of possible embodiments of embodiment to the of the first of second aspect and second aspect, in the 5th kind of possible embodiment, also comprise:
Recover module, communicate with described checking module and described update module, for when described data page is recovered, in described transaction journal, search the recovery starting point of described data page, described recovery starting point is the last checkpoint of recording in described transaction journal;
If described recovery module also, for adopting the Update log record of described transaction journal after described recovery starting point to occur mistake to the recovery of described data page, is searched sequence number corresponding to the last full page log recording of described data page the Update log record that the described data page after described recovery starting point is corresponding;
Described recovery module also, for according to the sequence number finding, is searched the full page log recording that described data page is corresponding in described transaction journal;
Described recovery module also, for the full page log recording corresponding according to described data page, is recovered described data page.
In conjunction with any one in the possible five kinds of possible embodiments of embodiment to the of the first of second aspect and second aspect, in the 6th kind of possible embodiment, also comprise:
Removing module, communicates with described checking module and described update module, for adding up described database, does not flush to the dirty page in hard disk;
Described removing module also in the sequence number for the full page log recording of record from all dirty pages that do not flush to hard disk, is determined minmal sequence number;
Described removing module is also for deleting log recording sequence number than described minmal sequence number little log recording in described online daily record.
The blog management method of the present embodiment; if there is the full page log recording in data page in transaction journal; can only record the Update log record of this data page; when the full page log recording by transaction journal guarantees the normal recovery of data; can reduce the quantity of full page log recording in transaction journal, reduce the shared disk space of transaction journal.
According to below with reference to accompanying drawing to detailed description of illustrative embodiments, it is clear that further feature of the present invention and aspect will become.
Embodiment
Below with reference to accompanying drawing, describe various exemplary embodiments of the present invention, feature and aspect in detail.The identical same or analogous element of Reference numeral presentation function in accompanying drawing.Although the various aspects of embodiment shown in the drawings, unless otherwise indicated, needn't draw accompanying drawing in proportion.
Here special-purpose word " exemplary " means " as example, embodiment or illustrative ".Here as " exemplary " illustrated any embodiment, needn't be interpreted as being better than or being better than other embodiment.
In addition, for better explanation the present invention, in embodiment below, provided numerous details.It will be appreciated by those skilled in the art that and there is no some detail, the present invention can implement equally.In some instances, the method for knowing for those skilled in the art, means, element and circuit are not described in detail, so that highlight purport of the present invention.
embodiment 1
Fig. 1 a, 1b are the process flow diagram of the blog management method of the embodiment of the present invention one.As shown in Figure 1a, this blog management method mainly comprises:
Step S110, when the data page of database occurs to upgrade, check in the transaction journal of described database whether have the full page log recording that described data page is corresponding.
If there is the full page log recording that described data page is corresponding in the described transaction journal of step S120, in described transaction journal, record the Update log record that described data page is corresponding.
Particularly, after step S110, can also comprise, if there is not the full page log recording that described data page is corresponding in described transaction journal, in described transaction journal, record full page log recording corresponding to data page after described data page is upgraded.
The data structure of database can be comprised of transaction journal, transaction table, dirty page table and data page structure four parts.Wherein, transaction journal both can be oneself and had submitted reforming (redo) and not submitting to cancel (undo) of affairs that information source is provided of affairs to, also for medium recovery provides approach.Database will can recover the operation that data object changes to may causing of any affairs and do transaction journal, and the WAL agreement of writing afterwards is first remembered in employing, the data structure of transaction journal can comprise following data field: sequence number (log sequence number, LSN), data page identifier (Page ID): the page for sign " renewal " with the renewal effect of " compensation " record, is comprised of object identifier and page page sequence number two parts in object conventionally.Data (Data): the redo/undo data of the renewal of implementing in order to record.
Transaction table is mainly used in the state of the track record active transaction while recovering of restarting after thrashing, thereby provides foundation for cancelling of will carrying out of this process.Each data item in dirty page table comprises page identifiers (Page ID) and recovers two data fields of sequence number (Recovery LSN).The former is for identifying corresponding dirty page, and the latter is for indicating the starting position in daily record that is updated in of may not deposit stable storage of relevant this page.
In each data page of database, can open up some spaces as page sequence number (PageLSN) territory, in order to be described in the nearest renewal done on this page or the LSN of the corresponding log recording of compensating operation, this log recording can be full page daily record or Update log.The sequence number of the Update log that this data page is corresponding can be recorded in described page sequence number territory.
Database Systems can also record the sequence number of its corresponding full page log recording in data page, the full page log recording that this sequence number is corresponding can recover a complete data page, records the sequence number of the full page daily record of this data page in the Update log of the data page occurring for the first time that Database Systems can also be after each check point.
Particularly, Database Systems need to upgrade the sequence number of the full page log recording that data page is corresponding under some scene, for example:
(1) when data page is assigned with for the first time, now in data page without any data message;
(2) when the renewal operation of data page causes all records in data page all deleted, now the data recording number of data page is 0;
(3), when data page records full page log recording, now can in data page, record the LSN(that full page log recording is corresponding and also can be called initLSN), the follow-up data page that can regain one's integrity by full page log recording corresponding to this initLSN.
Particularly, step S110 can comprise:
According to the sequence number corresponding to described full page log recording of described data page record, search in the transaction journal of described database whether have the full page log recording that described data page is corresponding, specifically can comprise following situation:
If sequence number corresponding to described full page log recording recording in the described data page of situation one is more than or equal to the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and have the full page log recording that described data page is corresponding;
If sequence number corresponding to described full page log recording recording in the described data page of situation two is less than the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and do not have the full page log recording that described data page is corresponding.
Particularly, when Database Systems are carried out renewal operation, cause data page when clean page becomes dirty page, Database Systems can check the sequence number of the full page log recording in this data page, when finding that its corresponding full page log recording exists in transaction journal (as archive log or online daily record), do not record full page log recording, but record Update log record, in this dirty page, record the sequence number of its corresponding full page log recording simultaneously.
Database Systems also can record the sequence number that its full page log recording is corresponding in the Update log that the data page of appearance is corresponding for the first time afterwards of checkpoint.In a kind of possible embodiment, Database Systems can record corresponding sequence number according to the described Update log recording in described data page, search described Update log record; If the sequence number corresponding to described full page log recording of record is more than or equal to the minmal sequence number of described transaction journal in described Update log record, determines in described transaction journal and have the full page log recording that described data page is corresponding; If the sequence number corresponding to described full page log recording of record is less than the minmal sequence number of described transaction journal in described Update log record, determines in described transaction journal and do not have the full page log recording that described data page is corresponding.
Further, in order to reduce release time, even if recorded the full page log recording that a certain data page is corresponding before, also can meet under some condition, again record full page log recording, therefore, as shown in Figure 1 b, after step S110 or step S120, this blog management method can also comprise:
If there is the full page log recording that described data page is corresponding in the described transaction journal of step S130, and described transaction journal meets the condition that again records full page log recording, in described transaction journal, again record the current full page log recording of described data page, and by described sequence number update, be the sequence number of the current full page log recording of described data page in described data page;
Wherein, the described condition that again records full page log recording comprise following any one:
From full page log recording corresponding to described data page, start to be more than or equal to the data volume threshold value of setting to the daily record data amount between log recording corresponding to the current data page upgrading;
From full page log recording corresponding to described data page, start to be more than or equal to the daily record number threshold value of setting to the daily record number between log recording corresponding to the current data page upgrading;
From full page log recording corresponding to described data page start between log recording corresponding to the current data page upgrading interval greater than or equal the duration threshold value set.
For example, Fig. 1 c is the schematic diagram that again records full page log recording of the embodiment of the present invention one.As shown in Fig. 1 c, specific practice can start whether to be greater than the data volume threshold value of setting to the data volume of the transaction journal of current record from full page log recording corresponding to data page for judgement.If the checkpoint of the daily record of current data page correspondence is 101, it is 102 that Database Systems find the checkpoint that last full page log recording is corresponding, when the data volume that Database Systems detect transaction journal between two checkpoints is greater than the data volume threshold value of setting, for example data volume threshold value can be 16M, just record full page log recording one time, and the sequence number of current full page log recording is recorded in the data page of subsequent modification.Like this, when the data page of database occurs to upgrade, check while whether there is full page log recording corresponding to described data page in the transaction journal of database, now, in this transaction journal, exist the full page log recording that data page is corresponding to have a plurality of, when in this transaction journal, the Update log of record data page correspondence records, the sequence number of the full page log recording that record records again in data page.If there is part write error when data page refreshes, when Database Systems are carried out data recovery, can record from the Update log from this data page recent full page log recording and recover.
It should be noted that, although take data volume threshold value, to be example etc. introduced the condition that again records full page log recording, it will be appreciated by those skilled in the art that the present invention should be not limited to this.In fact, user can record according to personal like and/or the flexible setting of practical application scene the condition of full page log recording completely again, as long as the full page log recording of record data page again.
It should be noted that, blog management method of the present invention can also be applicable to employing full dose checkpoint based on WAL daily record or the Database Systems of incremental checkpoint.
The blog management method of the present embodiment; if there is the full page log recording in data page in transaction journal; can only record the Update log record of this data page; when the full page log recording by transaction journal guarantees the normal recovery of data; can reduce the quantity of full page log recording in transaction journal, reduce the shared disk space of transaction journal.
embodiment 2
The transaction journal of database can comprise archive log or online daily record.Wherein, archive log is the daily record of backing up at other disks or other main frames, generally can not delete the log recording in archive log, so the corresponding full page log recording of data page can find conventionally in archive log.And online daily record is left in the journal file of Database Systems this locality, system may delete online daily record when carrying out checkpoint in partial log early record to guarantee that there are enough disk spaces this locality.In order to guarantee to exist in online daily record the full page log recording of a certain data page, when the log recording of online daily record is deleted, need to delete according to certain deletion strategy.
In online daily record, the sequence number of log recording is monotone increasing ordered series of numbers, and the sequence number of online daily record log recording is the earliest minimum log serial number, and the border of online daily record is log recording corresponding to this minimum log serial number.Fig. 2 a and Fig. 2 b search the schematic diagram of full page log recording in online daily record in the blog management method of the embodiment of the present invention two, the log recording showing with the frame table of backslash in Fig. 2 a and Fig. 2 b is full page log recording, and the log recording that blank box represents is Update log record.As shown in Figure 2 a, when data page P1 lights while being modified for the first time from nearest inspection, check whether data page P1 exists full page log recording.If being checked through the sequence number (initLSN) of its full page log recording of preserving in data page P1, Database Systems do not surpass the border of online daily record, when recording online daily record, do not need to record full page log recording, can only record Update log record, in data page P1, record the sequence number (initLSN) of its corresponding full page log recording simultaneously, this initLSN can representative data page P1 the position of the last full page log recording, the full page log recording of this position can recover a complete data page P1.As shown in Figure 2 b, if detecting the sequence number (initLSN) of the full page log recording in data page P1, Database Systems surpassed the border of online daily record, it is the full page log recording that does not have data page P1 in online daily record, therefore the full page log recording that, needs record data page P1 in the current log recording of online daily record.
Before data page is refreshed to disk, if its corresponding full page log recording is deleted in online daily record, if occur partly to write problem when data page refreshes, can cause database to recover.For fear of part, write the problem of the recovery failure bringing, during the log recording of database in deleting online daily record, need to avoid deleting the current full page log recording that does not refresh dirty page.Fig. 2 c deletes the process flow diagram of the log recording of online daily record in the blog management method of the embodiment of the present invention two.As shown in Figure 2 c, in this daily record will management method, the step of deleting the log recording of online daily record mainly can comprise:
Step S210, add up the dirty page not flushing in described database in hard disk;
Step S220, from all dirty pages that do not flush to hard disk, in the sequence number of the full page log recording of record, determine minmal sequence number;
Step S230, in described online daily record, delete log recording sequence number than described minmal sequence number little log recording.
Particularly, in online daily record, the data line style of transaction journal is arranged, and sequence number from front to back increases successively.Fig. 2 d is the schematic diagram of the transaction journal delet method of the embodiment of the present invention two.As shown in Figure 2 d, while deleting in online daily record 201 log recording, need to check the dirty page that does not also flush to disk in databases, if P3 and P2 be not for flushing to the dirty page of disk, add up the sequence number of the full page log recording of this P3 and P2, if the sequence number of the full page log recording of P3 is " 90 ", the sequence number of the full page log recording of P2 is " 95 ", and the sequence number of minimum full page log recording is " 90 ".Database Systems can only be deleted the log recording before the full page log recording that this minimum sequence number " 90 " is corresponding, delete checkpoint 203 all log recordings before.Corresponding full page log recording once data page is deleted, when becoming dirty page next time, data page just need to again record full page log recording, therefore, and when deleting transaction journal, under erasure request on meet, some the online daily records that retain of can trying one's best more.For example, when Database Systems only have the size of online daily record to surpass setting threshold as 1G deletion log recording again.
The blog management method of the present embodiment; if there is the full page log recording in data page in transaction journal; can only record the Update log record of this data page; when the full page log recording by transaction journal guarantees the normal recovery of data; can reduce the quantity of full page log recording in transaction journal, reduce the shared disk space of transaction journal.
embodiment 3
Fig. 3 a is the process flow diagram of the database restoring method of the embodiment of the present invention three, and Fig. 3 b is the schematic diagram of the database restoring method of the embodiment of the present invention three.As shown in Figure 3 a, this database restoring method mainly comprises:
Step S310, when described data page is recovered, in described transaction journal, search the recovery starting point of described data page, described recovery starting point is the last checkpoint of recording in described transaction journal;
If step S320 adopts described transaction journal there is mistake to the recovery of described data page in the Update log record after described recovery starting point, searches sequence number corresponding to the last full page log recording of described data page the Update log record that the described data page after described recovery starting point is corresponding;
The sequence number that step S330, basis find is searched the full page log recording that described data page is corresponding in described transaction journal;
Step S340, the full page log recording corresponding according to described data page, recover described data page.
Particularly, when Database Systems break down or restart after system crash, Database Systems RMAN will be activated, and carry out data recovery by following three phases: analyze (Analysis): differentiate when collapse occurs the dirty page in buffer zone and at that time active affairs still.(Redo) reforms: the everything of reforming and starting from the suitable starting point of daily record (such as, the corresponding transaction journal of dirty page being the earliest modified), database (data base, the DB) state of recovery system when collapsing.Cancel (Undo): cancel all action effects of not submitting affairs to while collapsing last time, make database only reflect the impact of having submitted affairs to.
Yet, if in data recovery procedure, searching for whole daily record and will expend a large amount of time, redo processes will re-execute all affairs, has wasted the plenty of time.In order to reduce above expense, in daily record, increase new record check point record, checkpoint is carried out on system cycle ground, and concrete action is: all transaction journals in current log buffer are write to (journal file is all stored on stable storage) on journal file.All modifications data recording be written in the database of disk.Check point record is written on journal file.Checkpoint in the process of implementation, does not generally allow affairs to carry out any more new element, as writes buffer stopper or write transaction journal, waits for that all affairs all complete to upgrade operation again.When affairs were submitted to before checkpoint, the modification written data storehouse that these affairs are made database, needn't carry out redo operation to these affairs while now recovering again.The recovery technology with checkpoint can increase check point record in journal file, increases to restart file, makes recovery subsystem maintenance log dynamically during login journal file.
As shown in Figure 3 b, when data page is recovered, search the recovery starting point of data page in transaction journal, this recovery starting point is can be the last checkpoint 204 of recording in described transaction journal.When 204 positions start to recover from checkpoint, when returning to the data page P1 of transaction journal 205 correspondences, find that data page P1 makes a mistake.Owing to having recorded the sequence number initLSN of the last full page log recording that data page P1 is corresponding in current log recording, now Database Systems can find the transaction journal 206 that data page P1 is corresponding according to this log serial number, if described this transaction journal 206 is full page log recordings, from this full page log recording 206 reconstruct data page P1 or jump to current location and again recover, then carry out the redo operation of follow-up this page; Otherwise, construct empty data page, carry out the redo operation of subsequent page.
The blog management method of the present embodiment; if there is the full page log recording in data page in transaction journal; can only record the Update log record of this data page; when the full page log recording by transaction journal guarantees the normal recovery of data; can reduce the quantity of full page log recording in transaction journal, reduce the shared disk space of transaction journal.
embodiment 4
Fig. 4 is the structured flowchart of the log management apparatus of the embodiment of the present invention four.As shown in Figure 4, this log management apparatus mainly comprises:
Checking module 410, while occurring to upgrade for data page at database, checks in the transaction journal of described database whether have the full page log recording that described data page is corresponding;
Update module 420, communicates with described checking module 410, if there is for described transaction journal the full page log recording that described data page is corresponding, in described transaction journal, records the Update log record that described data page is corresponding.
If described update module 420 does not also exist for described transaction journal the full page log recording that described data page is corresponding, in described transaction journal, record full page log recording corresponding to data page after described data page is upgraded.
Described checking module 410 is also for according to the sequence number corresponding to described full page log recording of described data page record, searches in the transaction journal of described database whether have the full page log recording that described data page is corresponding.
If sequence number corresponding to described full page log recording that described checking module 410 also records for described data page is more than or equal to the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and have the full page log recording that described data page is corresponding;
If sequence number corresponding to described full page log recording that described checking module 410 also records for described data page is less than the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and do not have the full page log recording that described data page is corresponding.
If also there is for described transaction journal the full page log recording that described data page is corresponding in described update module 420, and described transaction journal meets the condition that again records full page log recording, in described transaction journal, again record the current full page log recording of described data page, and by described sequence number update, be the sequence number of the current full page log recording of described data page in described data page;
Described update module 420 also starts whether to be more than or equal to the data volume threshold value of setting to the daily record data amount between log recording corresponding to the current data page upgrading for judging from full page log recording corresponding to described data page;
Described update module 420 also starts whether to be more than or equal to the daily record number threshold value of setting to the daily record number between log recording corresponding to the current data page upgrading for judging from full page log recording corresponding to described data page;
Described update module 420 also starts whether to be more than or equal to the duration threshold value of setting to the time interval between log recording corresponding to the current data page upgrading for judging from full page log recording corresponding to described data page.
The log management apparatus of the present embodiment; if there is the full page log recording in data page in transaction journal; can only record the Update log record of this data page; when the full page log recording by transaction journal guarantees the normal recovery of data; can reduce the quantity of full page log recording in transaction journal, reduce the shared disk space of transaction journal.
embodiment 5
Fig. 5 is the structured flowchart of the log management apparatus of the embodiment of the present invention five.The assembly that in Fig. 5, label is identical with Fig. 4 has identical function, for simplicity's sake, omits the detailed description to these assemblies.
As shown in Figure 5, shown in the log management apparatus shown in Fig. 5 and Fig. 4, the key distinction of log management apparatus is, also comprises:
Recover module 510, can communicate with described checking module 410 and update module 420, for when described data page is recovered, in described transaction journal, search the recovery starting point of described data page, described recovery starting point is the last checkpoint of recording in described transaction journal;
If described recovery module 510 also, for adopting the Update log record of described transaction journal after described recovery starting point to occur mistake to the recovery of described data page, is searched sequence number corresponding to the last full page log recording of described data page the Update log record that the described data page after described recovery starting point is corresponding;
Described recovery module 510 also, for according to the sequence number finding, is searched the full page log recording that described data page is corresponding in described transaction journal;
Described recovery module 510 also, for the full page log recording corresponding according to described data page, is recovered described data page.
Described log management apparatus also comprises removing module 520, can communicate with described checking module 410 and described update module 420, for adding up described database, does not flush to the dirty page in hard disk;
Described removing module 520 also in the sequence number for the full page log recording of record from all dirty pages that do not flush to hard disk, is determined minmal sequence number;
Described removing module 520 is also for deleting than described minmal sequence number little log recording in described online daily record.
The log management apparatus of the present embodiment; if there is the full page log recording in data page in transaction journal; can only record the Update log record of this data page; when the full page log recording by transaction journal guarantees the normal recovery of data; can reduce the quantity of full page log recording in transaction journal, reduce the shared disk space of transaction journal.
embodiment 6
Fig. 6 is the structured flowchart of the log management apparatus of the embodiment of the present invention six.Described log management apparatus 600 can be host server, personal computer PC or portable portable computer or the terminal etc. that possess computing power.The specific embodiment of the invention does not limit the specific implementation of computing node.
Described log management apparatus 600 comprises processor (processor) 610, communication interface (Communications Interface) 620, storer (memory) 630 and bus 640.Wherein, processor 610, communication interface 620 and storer 630 complete mutual communication by bus 640.
Communication interface 620 is for communicating by letter with the network equipment, and wherein the network equipment comprises such as Virtual Machine Manager center, shares storage etc.
Processor 610 is for executive routine.Processor 610 may be a central processor CPU, or application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or is configured to implement one or more integrated circuit of the embodiment of the present invention.
Storer 630 is for storing documents.Storer 630 may comprise high-speed RAM storer, also may also comprise nonvolatile memory (non-volatile memory), for example at least one magnetic disk memory.Storer 630 can be also memory array.Storer 630 also may be by piecemeal, and described can become virtual volume by certain principle combinations.
In a kind of possible embodiment, said procedure can be the program code that comprises computer-managed instruction.This program specifically can be used for:
When the data page of database occurs to upgrade, check in the transaction journal of described database whether have the full page log recording that described data page is corresponding;
If there is the full page log recording that described data page is corresponding in described transaction journal, in described transaction journal, record the Update log record that described data page is corresponding.
In a kind of possible embodiment, also comprise:
If there is not the full page log recording that described data page is corresponding in described transaction journal, in described transaction journal, record full page log recording corresponding to data page after described data page is upgraded.
In a kind of possible embodiment, in the transaction journal of the described database of described inspection, whether there is the full page log recording that described data page is corresponding, comprising:
According to the sequence number corresponding to described full page log recording of described data page record, search in the transaction journal of described database whether have the full page log recording that described data page is corresponding.
In a kind of possible embodiment, according to sequence number corresponding to described full page log recording recording in described data page, search in the transaction journal of described database whether have the full page log recording that described data page is corresponding, comprising:
If sequence number corresponding to described full page log recording recording in described data page is more than or equal to the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and have the full page log recording that described data page is corresponding;
If sequence number corresponding to described full page log recording recording in described data page is less than the minmal sequence number in all log recording sequence numbers in described transaction journal, determines in described transaction journal and do not have the full page log recording that described data page is corresponding.
In a kind of possible embodiment, whether there is the full page log recording that described data page is corresponding in the transaction journal that checks described database after, also comprise:
If there is the full page log recording that described data page is corresponding in described transaction journal, and described transaction journal meets the condition that again records full page log recording, in described transaction journal, again record the current full page log recording of described data page, and by described sequence number update, be the sequence number of the current full page log recording of described data page in described data page;
Wherein, the described condition that again records full page log recording comprise following any one:
From full page log recording corresponding to described data page, start to be more than or equal to the data volume threshold value of setting to the daily record data amount between log recording corresponding to the current data page upgrading;
From full page log recording corresponding to described data page, start to be more than or equal to the daily record number threshold value of setting to the daily record number between log recording corresponding to the current data page upgrading;
From full page log recording corresponding to described data page start between log recording corresponding to the current data page upgrading interval greater than or equal the duration threshold value set.
In a kind of possible embodiment, also comprise:
When described data page is recovered, in described transaction journal, search the recovery starting point of described data page, described recovery starting point is the last checkpoint of recording in described transaction journal;
If adopt the Update log record of described transaction journal after described recovery starting point to occur mistake to the recovery of described data page, search sequence number corresponding to the last full page log recording of described data page the Update log record that the described data page after described recovery starting point is corresponding;
According to the sequence number finding, in described transaction journal, search the full page log recording that described data page is corresponding;
The full page log recording corresponding according to described data page, recovers described data page.
In a kind of possible embodiment, described transaction journal is online daily record, and described method also comprises:
Add up the dirty page not flushing in described database in hard disk;
From all dirty pages that do not flush to hard disk, in the sequence number of the full page log recording of record, determine minmal sequence number;
In described online daily record, delete log recording sequence number than described minmal sequence number little log recording.
Those of ordinary skills can recognize, each exemplary cell and algorithm steps in embodiment described herein can be realized with the combination of electronic hardware or computer software and electronic hardware.These functions realize with hardware or form of software actually, depend on application-specific and the design constraint of technical scheme.Professional and technical personnel can realize described function for specific application choice diverse ways, but this realization should not thought and exceeds scope of the present invention.
If the form of computer software of usining realizes described function and as production marketing independently or while using, can think to a certain extent that all or part of (part for example prior art being contributed) of technical scheme of the present invention is with the form embodiment of computer software product.This computer software product is stored in the non-volatile memory medium of embodied on computer readable conventionally, comprises that some instructions are used so that computer equipment (can be personal computer, server or the network equipment etc.) is carried out all or part of step of various embodiments of the present invention method.And aforesaid storage medium comprises the various media that can be program code stored such as USB flash disk, portable hard drive, ROM (read-only memory) (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CD.
The above; be only the specific embodiment of the present invention, but protection scope of the present invention is not limited to this, is anyly familiar with those skilled in the art in the technical scope that the present invention discloses; can expect easily changing or replacing, within all should being encompassed in protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of described claim.