Background technology
At computer application field,, often require to carry out regular upgrading for the database that the user uses according to the needs of using.For example, along with the continuous appearance of new virus, need the virus base of antivirus software configuration be carried out.In the technical field of killing the virus, the seamless upgrade of virus base is a problem that receives much concern at present, realizes that seamless upgrade but and be not easy but want perfect.So-called " seamless upgrade " is meant, this a series of actions is upgraded, more becomes, revised to the data of virus base, yet more new element is taking place in a bit imperceptible data of the user of data, and still continuation is as usual used it and without any obstruction.
Many problems appear in existing database upgrade technology.
At first, when data of database is upgraded, generally all can cause the interim time-out of whole service on the local computer.
Virus base is the set of the complex data structures used simultaneously of many clients.When the virus base of antivirus software is frequently upgraded, killing toxic effect rate also will face the danger of remarkable decline.Also have other a lot of databases when upgrading, also to face similar problem.
Secondly, on local computer, if different processes or thread are considered as different users, so, if user A uses legacy data for a long time, renewal has taken place in data between the operating period; And at this moment, user B has got access to up-to-date data, and these two data just might clash so; If the user is C, D, E use the different time data updated again respectively, the probability that the data of these five different editions clash in use is just bigger.
Certainly, when Data Update, interrupt all users' work by force, new data more upgrades the work that recovers all users after finishing again then, is a solution.But this can reduce the data service efficiency.And user's meeting is because upgrade, and the access strategy of change data, even need Suspension of Operations.
The 3rd, the escalation process of prior art is not enough to user transparentization.Whether transparence is meant the user when service end is obtained data, does not worry whether data are old excessively, need queuing to obtain, and whether needs to give back data, and whether data in use can be changed by other user.As user during to the service end request msg, the data that he gets must be up-to-date, that get access at once, that can give back at any time, multi-user's safety.Ideal situation is, the user need not to know for these, and the just request msg and obtain data simply that he will do can be finished the upgrading of database.
The 4th problem of prior art is can not obtain correct data under multithreading, multi-process.If data of database was upgraded when a user asked to upgrade, another user need wait for after Data Update finishes and could visit so, otherwise, just the data that another user can obtain is half new, half is old.
Summary of the invention
The objective of the invention is problem, a kind of upgrade method of improved database is provided, can satisfy the demand of database seamless upgrade at the prior art existence.
According to the present invention, a kind of upgrade method of database is provided, may further comprise the steps: the request upgrade data; Obtain the database latest edition; Inquire about the index detailed catalogue of the data of this database latest edition, satisfy the new data that upgrading requires to find out, wherein the index detailed catalogue of the data of this database latest edition is stored in the latest data tabulation of overall shared region; All are satisfied the new data merging that upgrading requires, obtain the upgrading data packet of latest edition; And the more new data packets of this latest edition offered the database of request upgrading to finish upgrading.
According to embodiments of the invention, wherein, the described database latest edition of obtaining comprises:
Query Database latest edition in overall shared region; This database latest edition is compared with local data base, to determine whether local data base is this database latest edition; When definite local data base is not latest edition, upgrade the data item tabulation in the current use, the data item list storage in the wherein said current use is in the up-to-date tabulation of internal memory; And the data that obtain the database latest edition.
According to embodiments of the invention, wherein, obtain the step of database latest edition the term of execution, refuse any other and obtain the request of database latest edition, before the data of described acquisition database latest edition described.
According to embodiments of the invention, wherein, when described database latest edition is upgraded once more, correspondingly upgrade described latest data tabulation.
According to embodiments of the invention, the upgrade method of database also is included as each renewal data resource a counter is set, and wherein, when new data is created, its counter is added 1; When new data becomes legacy data, corresponding counter is subtracted 1; When client gets access to data, corresponding counter is added 1; And when client discharges data on it, corresponding counter is subtracted 1; When the counting of this counter becomes 0, the corresponding data resource that upgrades of deletion.The counting that can guarantee the data on the client like this is forever greater than 0, and the counting of new data is forever greater than 0; And unmanned data that use, old, counting equals 0.
According to embodiments of the invention, wherein, described database is a virus base.
The present invention can fulfillment database seamless upgrade, make the upgrading of database be similar to the plug-in type database, but have higher dirigibility, extremely low resources occupation rate and good portability, the upgrading of database can not cause the time-out of whole service, can realize new legacy data coexistence, numerous types of data coexistence, multithreading multi-process coexistence, the many service ends of single supplier and multi-client coexistence, escalation process is complete transparence to the client, and support multi-user and multi-platform, thereby overcome the various defectives that exist in the prior art.
The present invention is particularly useful for the upgrading of the virus base of antivirus software, but be not limited to the upgrading of virus base, but go for the upgrading of various databases, particularly be applicable to the database or the miniature database of storage multi-user, striding course, frequent variations, or the set of the complex data structures used simultaneously of other many clients.
Further specify embodiments of the invention below in conjunction with accompanying drawing.
Embodiment
In a preferred embodiment of the invention, as shown in Figure 1, the software systems that are used to realize the method for database upgrade of the present invention comprise four parts: data merge module 1104, data prestrain module 1105, data load module 1106 and data external interface 1107.
Be the example that upgrades in this embodiment with virus base.
For realizing the data upgrading, overall shared region 1100 is set in the memory storage of local computer, all users can both directly have access to data wherein.As shown in 1 figure, overall shared region will be stored latest data tabulation 1101, the up-to-date tabulation 1102 of internal memory and user's shared data 1103.Wherein, latest data tabulation 1101 comprises the tabulation of virus base index detailed catalogue, i.e. the index detailed catalogue of the data of latest edition virus base; The up-to-date tabulation 1102 of internal memory comprises the data item tabulation in the current use, i.e. the index detailed catalogue of the data of the virus base of the current use of user; User's shared data 1103 comprises the set of the data that all users are using.
Data merge module 1104 and are used for by upgrade file, the database specific data is upgraded.During this module work, other all-access to virus base will be under an embargo.
Data prestrain module 1105 can be abstracted into virus base the form of " index+data ".It stashes the positional information of data, visits up-to-date data and pass through " index ".In Fig. 1, the upper strata of data prestrain module is the data load module, and lower floor is a disk original data.
Data load module 1106 is from the nearest object layer of user, and the data distribution strategy is realized at this one deck.The required data that it provides for all users, and guarantee data continuously effective during the visit.
Data external interface 1107 is interfaces that the user can see.This interface converts data directory to a latest data.
The course of work of following descriptive data base upgrading:
The first half of Fig. 1 has been described the loading/upgrading process, and wherein initialization/tabulation of renewal latest data and up-to-date tabulation of internal memory [1009,1004,1005] is respectively the work that data prestrain module and data load module will be finished in loading and escalation process.These two tabulations will be indicated all states of current database.
When the database upgrade of service end, additionally need external program that the service packs of data is downloaded to this locality, upgrade latest data tabulation 1101 simultaneously.
The Lower Half of Fig. 1 has been described the data access process.Specify as follows:
External interface request msg [1001]; The data load module accepts request, and inquires about current latest data version [1006] to data prestrain module; Data prestrain module is accepted inquiry [1012], obtains disk original data simultaneously, and merges module integrated data by data, is visit speed-raising [1015] next time; The data load module obtains required version [1013], and it is compared, and attempts to reuse local data [1007]; If reusable, then successful inquiring obtains more new data [1002]; Otherwise, obtain the pairing data of this version [1014] to data prestrain module once more.
From data external interface 1107, only need pass through request msg [1001], obtain data [1002] and [1003] and can realize that just as for all changes inside the data, the user can't see the visit of data.The benefit of this access module is to upgrade to user's abundant transparence by fulfillment database, comprise: the modification of virus base action during transparence has been upgraded, transparence has used up the release movement of virus base, there is not the generation action of virus base in transparence, and the positional information of transparence virus base.The just request msg that the user is required to be done is to obtain data then, and does not need to consider or any other problem that concern of data qurush level may cause, does not also need to be concerned about the content of data and the ins and outs relevant with upgrading.
From echo plex mode [1002] and [1003] of upgrade data, data have been to upgrade through [1015] step (new data that all meet the demands on the disk is merged) in returning the way, are latest datas.Because data have been the latest data of upgrading through [1015] step in returning the way, and the user is when obtaining data, and the data combining step of [1015] must take place, and data must be upgraded.This has guaranteed that virus base use and escalation process carry out simultaneously, i.e. the upgrading of database can not influence the normal use of virus base or require professional time-out.
When normal load/upgrading, only can upgrade latest data tabulation (step 1011), so load and updating operation is fastish.So just can realize carrying out frequent renewal arbitrarily at the arbitrary portion data of database, and these Data Update actions are to the influence of local computer work efficiency, can be shared by the time and come, As time goes on the demand of new data, customer group can progressively obtain all up-to-date data, and disperses to bear the cost that new data loads.When obtaining data, once only can obtain, upgrade satisfactory that part of data (step 1015), other data can not be changed, the intensity of when so just having shared the data upgrading data having been upgraded.So just having guaranteed that Data Update action is shared by the time the influence of local computer work efficiency comes.Present embodiment is shared formula upgrading, the seamless upgrade of fulfillment database by above-described this data.
For example one to have 10000 data all be legacy data in database.When client 1 was obtained data 1, service end changed data 1 into new data 1, and offered client 1.When client 2 was obtained data 2, service end changed data 2 into new data 2, and offered client 2.Service end need not be spent the time in a week, upgrades 10000 data, and then data 1 and 2 are offered client 1 and 2.When obtaining, the more new element of data has been shared.Please note that " client and service end " described here all is meant thread or process.Such as, process A is a service end, and thread B is a client 1, and thread C is a client 2.
Fig. 2 describes the process of the step 1006 of fetching data among Fig. 1 in detail, and this process is finished by data load module 1106.
The up-to-date tabulation 2101 of internal memory among Fig. 2 is identical with the definition of the up-to-date tabulation 1102 of user's shared data 2102 and above-described internal memory and user's shared data 1103.This locality tabulation 2103 among Fig. 2 comprises the buffering tabulation that the data load inside modules is safeguarded.The overall situation may have a plurality of data load modules and work at the same time, has write down the cache information of all data availables that the data load module managed in the local tabulation, is used for data read and quickens.
The renewal data distribution that following data of description load-on module is carried out or the course of work of loading:
Call related function and get upgrade data [2001]; Fetch data Monitoring Data latest edition under all must cooperating in the outside that data prestrain module 1105 provides at every turn.This data load module [2002] of global lock, be that other all clients, service end operation so far all will stop, any request that other obtains the database latest edition all will be rejected, and up to asking more before the client of new data obtains more new data, lock is just untied.Under the cooperation of data prestrain module, inquire about overall latest data version [2003]; If the latest data version is arranged, then at this locality version reusable [2004] whether; If reusable is not then discarded local version, discharge local data [2007]; Open the shared drive district, attempt in user's shared data, to seek latest edition [2009]; If still can not find the latest data version, judgement is that upgrade status is read the storehouse first or the overall situation is upgraded for the first time, then reading of data and create shared data [2008]; If find the latest data version, this moment, there be (different process transfer) in the shared drive data, and this version that finds [2006] is returned in the then up-to-date tabulation of updating memory [2010]; Before all latest edition data are returned, release data load module [2005].
In renewal data distribution process shown in Figure 2, each upgrades data resource and all is provided with the counter of oneself, when counter becomes 0, can cause this resource deleted.
Obtain more new data in step [2006].In step [2008], when not having overall latest edition data, ask for the latest edition data and create shared drive.In step 2006 and 2008, the counter that upgrades data resource adds 1 respectively, comes to 2.The user use up data upgrade after [2006], counter can subtract 1; When new data occurs [2007], counter can deduct 1 again.Like this, and if only if, and the user uses up data, and new data is when occurring, and counter just can become 0, and legacy data just can be deleted.If customer end A is being used old data, customer end B is being used new data, and the counter of legacy data will be 1 so, and keeps existence.Until customer end A uses up old data, counter is carried out when subtracting 1 operation, and the counter of legacy data just can become 0, causes legacy data deleted.This has just realized can using simultaneously in the method for the invention the virus base of different editions of the same race.