CN109739836A - The method and system with renewal time stamp is chosen for multi-version database - Google Patents

The method and system with renewal time stamp is chosen for multi-version database Download PDF

Info

Publication number
CN109739836A
CN109739836A CN201811640899.8A CN201811640899A CN109739836A CN 109739836 A CN109739836 A CN 109739836A CN 201811640899 A CN201811640899 A CN 201811640899A CN 109739836 A CN109739836 A CN 109739836A
Authority
CN
China
Prior art keywords
timestamp
time stamp
current time
updated
clock
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.)
Granted
Application number
CN201811640899.8A
Other languages
Chinese (zh)
Other versions
CN109739836B (en
Inventor
陈榕
陈海波
臧斌宇
管海兵
魏星达
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Jiaotong University
Original Assignee
Shanghai Jiaotong University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Shanghai Jiaotong University filed Critical Shanghai Jiaotong University
Priority to CN201811640899.8A priority Critical patent/CN109739836B/en
Publication of CN109739836A publication Critical patent/CN109739836A/en
Application granted granted Critical
Publication of CN109739836B publication Critical patent/CN109739836B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The present invention provides a kind of method and system chosen for multi-version database and renewal time stabs, initialization time stamp: sets the physical clock part of timestamp to the machine clock of current machine, the logical timer part of timestamp is set to 0;Renewal time stamp: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated is less than current time stamp, without update of time stamp;The logical timer part of current time stamp is increased without update of time stamp if timestamp to be updated is equal to current time stamp;Otherwise, then current time stamp is replaced with timestamp to be updated, and the logical timer part of current time stamp is increased.It is compared with traditional timestamp, the physical time relationship in update and acquisition time stamp can be showed, can also show logical relation.During logical timer updates, physical clock will not be had an impact.

Description

The method and system with renewal time stamp is chosen for multi-version database
Technical field
The present invention relates to database technical fields, and in particular, to when one kind is chosen and updated for multi-version database Between the method and system that stabs, be suitable for database data storage and data processing.
Background technique
Modern data library is usually that individual data stores multiple versions, in this way can be multiple to the access of the same data Parallel processing in the data of version, the performance of lifting system.The version number of data and how to access the data of particular version by One timestamp determines that data will receive version of the new timestamp as modification when updating;Data access When the versions of data nearest from this timestamp can be found according to a timestamp.
The acquisition of clock must be obtained with update it is synchronous, not so can to application cause consistency problem.In single computer, The physical clock (Physical time) of computer can be used as the selection of timestamp.The acquisition and update of physical clock It is completed by computer hardware.However, in a distributed system, the synchronizing for clock between different machines can not be guaranteed.Therefore, divide Usually using the timestamp of a machine handing cluster in cloth system.This ensure that the synchronization of clock, however it is all when Clock updates and acquisition requires to communicate with specific clock server, affects the performance of whole system, while limiting system Scalability.
It can solve the inconsistence problems of timestamp under distributed environment using logical timer, logical timer is in application communication When it is synchronous, this ensure that the consistency of timestamp.However, logical timer, which not can guarantee timestamp, obtains and obtains the true of generation Relativeness between in real time.For example, the event B after event A may be obtained when event A obtains a logical timer Take a clock smaller than event A.It will cause the decline of user experience in this way, for example application can not read the latest edition of data This.
The characteristics of mix clock (Hybrid clock) combines physical clock and logical timer, using physical clock come just Beginningization logical timer, so that the size of logical timer substantially embodies the actual time of event generation.However, due to logical timer It can be infrequently updated, these updates influence whether the physical clock of clock, so that the expression of physical clock generates inconsistent, limitation The application of mix clock.
Summary of the invention
For the defects in the prior art, the object of the present invention is to provide one kind chooses and updates for multi-version database The method and system of timestamp.
The method chosen for multi-version database and renewal time stabs provided according to the present invention, comprising:
Initialization time stab step: set the physical clock part of timestamp to the machine clock of current machine, by when Between the logical timer part stabbed be set to 0;
Renewal time stabs step: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated Less than current time stamp, then without update of time stamp;If timestamp to be updated is equal to current time stamp, without timestamp It updates, the logical timer part of current time stamp is increased;Otherwise, then current time stamp is replaced with timestamp to be updated, And the logical timer part of current time stamp is increased.
A kind of system chosen for multi-version database and renewal time stabs provided according to the present invention, comprising:
Initialization time stab module: set the physical clock part of timestamp to the machine clock of current machine, by when Between the logical timer part stabbed be set to 0;
Renewal time stabs module: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated Less than current time stamp, then without update of time stamp;If timestamp to be updated is equal to current time stamp, without timestamp It updates, the logical timer part of current time stamp is increased;Otherwise, then current time stamp is replaced with timestamp to be updated, And the logical timer part of current time stamp is increased.
Preferably, the format of the timestamp is the integer of a 8byte.
Preferably, the machine clock of the current machine is obtained using the function gettimeofday of operating system.
Preferably, the size is compared using timestamp to be updated with current time stamp as integer.
Preferably, it is by the logical timer portion of current time stamp that the logical timer part of the current time stamp, which increase, Divide and increases by 1.
Preferably, the timestamp is made of physical clock part, logical timer part, space part, wherein when physics Clock part accounts for 48, and logical timer part accounts for 8, and space part accounts for 8.
Compared with prior art, the present invention have it is following the utility model has the advantages that
It is stabbed using incorporation time as basic timestamp, timestamp is enabled to indicate the time sequencing on event physical Time sequencing in logic;And timestamp is filled to guarantee that the update to timestamp logical gate will not influence then Between the physical part that stabs.
Detailed description of the invention
Upon reading the detailed description of non-limiting embodiments with reference to the following drawings, other feature of the invention, Objects and advantages will become more apparent upon:
Fig. 1 is the structural relation schematic diagram of timestamp of the invention;
Fig. 2 is initialization time of the invention to stab schematic diagram;
Fig. 3 is renewal time of the invention to stab schematic diagram.
Specific embodiment
The present invention is described in detail combined with specific embodiments below.Following embodiment will be helpful to the technology of this field Personnel further understand the present invention, but the invention is not limited in any way.It should be pointed out that the ordinary skill of this field For personnel, without departing from the inventive concept of the premise, several changes and improvements can also be made.These belong to the present invention Protection scope.
The invention proposes a kind of expression of new mix clock, acquisition and update method.This method ensure that: it is mixing When update of time stamp, the logical gate of timestamp will not influence the physical part of timestamp.In this way, the incorporation time proposed Stamp can simultaneously accurately embody data update (acquisitions) between actual time relationship, while embody data update (acquisition) it Between logical relation.
The method chosen for multi-version database and renewal time stabs provided according to the present invention, comprising:
Initialization time stab step: set the physical clock part of timestamp to the machine clock of current machine, by when Between the logical timer part stabbed be set to 0;
Renewal time stabs step: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated Less than current time stamp, then without update of time stamp;If timestamp to be updated is equal to current time stamp, without timestamp It updates, the logical timer part of current time stamp is increased;Otherwise, then current time stamp is replaced with timestamp to be updated, And the logical timer part of current time stamp is increased.
A kind of system chosen for multi-version database and renewal time stabs provided according to the present invention, comprising:
Initialization time stab module: set the physical clock part of timestamp to the machine clock of current machine, by when Between the logical timer part stabbed be set to 0;
Renewal time stabs module: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated Less than current time stamp, then without update of time stamp;If timestamp to be updated is equal to current time stamp, without timestamp It updates, the logical timer part of current time stamp is increased;Otherwise, then current time stamp is replaced with timestamp to be updated, And the logical timer part of current time stamp is increased.
Specifically, the format of the timestamp is the integer of a 8byte.
Specifically, the machine clock of the current machine is obtained using the function gettimeofday of operating system.
Specifically, the size is compared using timestamp to be updated with current time stamp as integer.
Specifically, it is by the logical timer portion of current time stamp that the logical timer part of the current time stamp, which increase, Divide and increases by 1.
Specifically, the timestamp is made of physical clock part, logical timer part, space part, wherein when physics Clock part accounts for 48, and logical timer part accounts for 8, and space part accounts for 8.
The system with renewal time stamp is chosen provided by the present invention for multi-version database, it can be by being used for multi version Database is chosen and the step process of the method for renewal time stamp is realized.Those skilled in the art can will be used for multi-edition data The method of library selection and renewal time stamp is interpreted as described for the excellent of the system of multi-version database selection and renewal time stamp Select example.
The present invention is the method chosen suitable for multi-version database with renewal time stamp, and this method utilizes incorporation time to stab As basic timestamp, timestamp is enabled to indicate the time sequencing on event physical and time sequencing in logic;And Timestamp is filled to guarantee the physical part for not interfering with timestamp to the update of timestamp logical gate.In the time In the acquisition and renewal process of stamp, the physical time relationship and logic between data update and acquisition can be accurately embodied simultaneously Relationship.The present invention will be further explained below with reference to the attached drawings.
As shown in Figure 1, the specific expression of timestamp of the invention in computer systems consists of three parts, a physics Clock part, a logical timer part and a part of space.Wherein, entire timestamp is by 64 integer representations.Object Reason clock accounts for 48, and space accounts for 8 and logical timer accounts for 8.
As shown in Fig. 2, when initial time stamp, when the physical part of timestamp is initialized as the physics of current computer Clock, and by space and logical gate initialization bit 0.
As shown in figure 3, needing to be updated according to another timestamp when renewal time stabs.In this embodiment, need by T0 is updated according to t1.The present invention compares the size of t0 and t1 first, can since timestamp is indicated by an integer To be directly compared size.Timestamp t0 if necessary to update is bigger, then t0 is directly returned without being updated. If t0 and t1 are equal, the logical gate of t0 is coupled with 1, is then returned to.If t0 ratio t1 is small, t0 is updated to t1, together When t0 logical gate be coupled with 1.
One skilled in the art will appreciate that in addition to realizing system provided by the invention in a manner of pure computer readable program code It, completely can be by the way that method and step be carried out programming in logic come so that provided by the invention other than system, device and its modules System, device and its modules are declined with logic gate, switch, specific integrated circuit, programmable logic controller (PLC) and insertion The form of controller etc. realizes identical program.So system provided by the invention, device and its modules may be considered that It is a kind of hardware component, and the knot that the module for realizing various programs for including in it can also be considered as in hardware component Structure;It can also will be considered as realizing the module of various functions either the software program of implementation method can be Hardware Subdivision again Structure in part.
Specific embodiments of the present invention are described above.It is to be appreciated that the invention is not limited to above-mentioned Particular implementation, those skilled in the art can make a variety of changes or modify within the scope of the claims, this not shadow Ring substantive content of the invention.In the absence of conflict, the feature in embodiments herein and embodiment can any phase Mutually combination.

Claims (10)

1. a kind of method chosen for multi-version database and renewal time stabs characterized by comprising
Initialization time stabs step: the physical clock part of timestamp is set to the machine clock of current machine, by timestamp Logical timer part be set to 0;
Renewal time stabs step: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated is less than Current time stamp, then without update of time stamp;If timestamp to be updated is equal to current time stamp, more without timestamp Newly, the logical timer part of current time stamp is increased;Otherwise, then current time stamp is replaced with timestamp to be updated, and The logical timer part of current time stamp is increased.
2. the method according to claim 1 chosen for multi-version database and renewal time stabs, which is characterized in that institute The format for stating timestamp is the integer of a 8byte.
3. the method according to claim 1 chosen for multi-version database and renewal time stabs, which is characterized in that institute The machine clock for stating current machine is obtained using the function gettimeofday of operating system.
4. the method according to claim 1 chosen for multi-version database and renewal time stabs, which is characterized in that institute Stating size relatively is compared using timestamp to be updated with current time stamp as integer.
5. the method according to claim 1 chosen for multi-version database and renewal time stabs, which is characterized in that institute It is that the logical timer part of current time stamp is increased by 1 that the logical timer part for stating current time stamp, which increase,.
6. the method according to claim 1 chosen for multi-version database and renewal time stabs, which is characterized in that institute It states timestamp to be made of physical clock part, logical timer part, space part, wherein physical clock part accounts for 48, logic Clock part accounts for 8, and space part accounts for 8.
7. a kind of system chosen for multi-version database and renewal time stabs characterized by comprising
Initialization time stabs module: the physical clock part of timestamp is set to the machine clock of current machine, by timestamp Logical timer part be set to 0;
Renewal time stabs module: by timestamp to be updated compared with current time stamp carries out size, if timestamp to be updated is less than Current time stamp, then without update of time stamp;If timestamp to be updated is equal to current time stamp, more without timestamp Newly, the logical timer part of current time stamp is increased;Otherwise, then current time stamp is replaced with timestamp to be updated, and The logical timer part of current time stamp is increased.
8. the system according to claim 7 chosen for multi-version database and renewal time stabs, which is characterized in that institute The format for stating timestamp is the integer of a 8byte;The machine clock of the current machine uses the function of operating system Gettimeofday is obtained.
9. the system according to claim 7 chosen for multi-version database and renewal time stabs, which is characterized in that institute Stating size relatively is compared using timestamp to be updated with current time stamp as integer;When the logic of the current time stamp It is that the logical timer part of current time stamp is increased by 1 that clock part, which increase,.
10. the system according to claim 7 chosen for multi-version database and renewal time stabs, which is characterized in that The timestamp is made of physical clock part, logical timer part, space part, wherein physical clock part accounts for 48, patrols It collects clock part and accounts for 8, space part accounts for 8.
CN201811640899.8A 2018-12-29 2018-12-29 Method and system for multi-version database selection and update of timestamps Active CN109739836B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811640899.8A CN109739836B (en) 2018-12-29 2018-12-29 Method and system for multi-version database selection and update of timestamps

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811640899.8A CN109739836B (en) 2018-12-29 2018-12-29 Method and system for multi-version database selection and update of timestamps

Publications (2)

Publication Number Publication Date
CN109739836A true CN109739836A (en) 2019-05-10
CN109739836B CN109739836B (en) 2020-09-04

Family

ID=66362509

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811640899.8A Active CN109739836B (en) 2018-12-29 2018-12-29 Method and system for multi-version database selection and update of timestamps

Country Status (1)

Country Link
CN (1) CN109739836B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112182005A (en) * 2020-10-10 2021-01-05 中国银联股份有限公司 Serial number generation method and device
CN113238892A (en) * 2021-05-10 2021-08-10 深圳巨杉数据库软件有限公司 Time point recovery method and device for global consistency of distributed system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6078930A (en) * 1997-02-28 2000-06-20 Oracle Corporation Multi-node fault-tolerant timestamp generation
CN102090050A (en) * 2008-07-07 2011-06-08 艾利森电话股份有限公司 Real time correlation of parallel charging events
US20160043999A1 (en) * 2011-03-30 2016-02-11 Open Text S.A. System, method and computer program product for efficient caching of hierarchical items
CN105740259A (en) * 2014-12-09 2016-07-06 阿里巴巴集团控股有限公司 Method and device for processing incremental data
US20180336258A1 (en) * 2017-05-22 2018-11-22 Sap Se Validating Query Results During Asynchronous Database Replication
CN110955672A (en) * 2019-11-25 2020-04-03 上海交通大学 Multi-version support method and system for optimistic concurrency control

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6078930A (en) * 1997-02-28 2000-06-20 Oracle Corporation Multi-node fault-tolerant timestamp generation
CN102090050A (en) * 2008-07-07 2011-06-08 艾利森电话股份有限公司 Real time correlation of parallel charging events
US20160043999A1 (en) * 2011-03-30 2016-02-11 Open Text S.A. System, method and computer program product for efficient caching of hierarchical items
CN105740259A (en) * 2014-12-09 2016-07-06 阿里巴巴集团控股有限公司 Method and device for processing incremental data
US20180336258A1 (en) * 2017-05-22 2018-11-22 Sap Se Validating Query Results During Asynchronous Database Replication
CN110955672A (en) * 2019-11-25 2020-04-03 上海交通大学 Multi-version support method and system for optimistic concurrency control

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112182005A (en) * 2020-10-10 2021-01-05 中国银联股份有限公司 Serial number generation method and device
CN113238892A (en) * 2021-05-10 2021-08-10 深圳巨杉数据库软件有限公司 Time point recovery method and device for global consistency of distributed system

Also Published As

Publication number Publication date
CN109739836B (en) 2020-09-04

Similar Documents

Publication Publication Date Title
CN107688999B (en) Block chain-based parallel transaction execution method
CN104699541A (en) Method, device, data transmission assembly and system for synchronizing data
CN110209728A (en) A kind of Distributed Heterogeneous Database synchronous method, electronic equipment and storage medium
CN108280080A (en) A kind of method of data synchronization, device and electronic equipment
CN105701159B (en) A kind of data synchronization unit and method
CN107659624A (en) A kind of isomery cloud management system and method suitable for cloud computing
Moniz et al. Blotter: Low latency transactions for geo-replicated storage
CN109739836A (en) The method and system with renewal time stamp is chosen for multi-version database
CN106339387B (en) Increase the method for data synchronization and device of server in a kind of data-base cluster newly
CN102946410A (en) Method and device for network synchronization
CN104683472A (en) Data transmission method capable of supporting large data volume
CN105677468A (en) Cache and designing method thereof and scheduling method and scheduling device using cache
CN106412697A (en) Method and device for automatically acquiring time zone for smart television
CN102946411A (en) Network synchronization system
CN105227657A (en) A kind of method and apparatus of data syn-chronization
CN110427426A (en) A kind of data synchronizing processing method and device
CN109725964A (en) Skin change method, device, the electronic equipment of mixed type frame
CN116562054B (en) Construction method and device of multi-entity collaborative real-time simulation system
CN109063135B (en) Database replication method and system based on multi-activity distributed architecture
WO2023207079A1 (en) Method for block state synchronization in blockchain, and first node
CN113590643B (en) Data synchronization method, device, equipment and storage medium based on dual-track database
CN109783243A (en) It is a kind of based on reserved copy and duplicate switching multi-thread data without lock reading/writing method
CN108509281B (en) Message storage method and device
Goncalves et al. DottedDB: Anti-entropy without merkle trees, deletes without tombstones
CN115189931A (en) Distributed key management method, device, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant