ZooKeeper Time Synchronization

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

ZooKeeper Time Synchronization

Amr Alanwar
Hi All

I am new to ZooKeeper..

How does ZooKeeper deal with time?
Are the Znodes/Clients synchronized?

If yes, What are the time synchronization options in the ZooKeeper?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Abraham Fine
Hi Amr-

ZooKeeper gets around time synchronization issues by using "ticks".
Please check out the time section in this doc for more information:
http://zookeeper.apache.org/doc/r3.4.0/zookeeperProgrammers.html

In short, except for adding metadata to znodes zookeeper does not use
real time at all.

Thanks,
Abe

On Wed, Jul 19, 2017, at 23:24, Amr wrote:

> Hi All
>
> I am new to ZooKeeper..
>
> How does ZooKeeper deal with time?
> Are the Znodes/Clients synchronized?
>
> If yes, What are the time synchronization options in the ZooKeeper?
>
>
>
> --
> View this message in context:
> http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Amr Alanwar
Hi Abe,

Thanks a lot for your reply and for the reference. Excuse me, I have a comment and a request for clarification.

 I see in the link you provided

"ZooKeeper doesn't use real time, or clock time, at all except to put timestamps into the stat structure on znode creation and znode modification."

Also, I see that znode state structure has the following
mtime: The time in milliseconds from epoch when this znode was last modified.

what is the usage of this mtime?

Consider Znode z1, I was thinking in this senario:
1- Master kept mtime T1 for changing z1.
2- Master died.
3- A new master will be elected, how will the new master deal with the timestamps attached to the znodes? The new master has no sense of the mtimes values attached to the znode. Does that affect anything, if for example a new modification is proposed?

Thanks again!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Sandeep Singh
Adding the Amr question.
Few things which I want to add is:

Does zookeeper uses System Time for below things
1) Leader election
2) Deciding a slave is available/alive or not.
3) Deciding leader/master is alive or not.
4) Deciding a transaction timeout etc.
5) Ordering the transaction etc.

regards,
Sandeep.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Alexander Shraer-2
As far as I understand:

1) no
2) yes
3) yes
4) yes
5) no, except for the sync command (there is a jira open for that)

Others please correct me if I'm wrong


Thanks
Alex

On Fri, Jul 21, 2017 at 11:52 AM Sandeep Singh <[hidden email]>
wrote:

> Adding the Amr question.
> Few things which I want to add is:
>
> Does zookeeper uses System Time for below things
> 1) Leader election
> 2) Deciding a slave is available/alive or not.
> 3) Deciding leader/master is alive or not.
> 4) Deciding a transaction timeout etc.
> 5) Ordering the transaction etc.
>
> regards,
> Sandeep.
>
>
>
> --
> View this message in context:
> http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583223.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Sandeep Singh
Thanks for reply.

But as per I understand, in leader election, it has to wait for some amount of time for leader proposal and voting using paxos. Which might happen when one of the slave belive that current leader is dead (due to timeout for leader response etc). The voting too will have some timeout etc associated with it, in which case if unsuccessfull, again a leader election is attempted.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

hanm
In reply to this post by Amr Alanwar
mtime etc is exposed to user to provide basic stats info; ZK itself does
not use these times. These times will just be recorded as they are and
carried over and does not impact anything in case leader election etc
happens.

On Fri, Jul 21, 2017 at 11:30 AM, Amr <[hidden email]> wrote:

> Hi Abe,
>
> Thanks a lot for your reply and for the reference. Excuse me, I have a
> comment and a request for clarification.
>
>  I see in the link you provided
>
> "ZooKeeper doesn't use real time, or clock time, at all except to put
> timestamps into the stat structure on znode creation and znode
> modification."
>
> Also, I see that znode state structure has the following
> mtime: The time in milliseconds from epoch when this znode was last
> modified.
>
> what is the usage of this mtime?
>
> Consider Znode z1, I was thinking in this senario:
> 1- Master kept mtime T1 for changing z1.
> 2- Master died.
> 3- A new master will be elected, how will the new master deal with the
> timestamps attached to the znodes? The new master has no sense of the
> mtimes
> values attached to the znode. Does that affect anything, if for example a
> new modification is proposed?
>
> Thanks again!
>
>
>
>
> --
> View this message in context: http://zookeeper-user.578899.n
> 2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583222.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>



--
Cheers
Michael.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

hanm
In reply to this post by Sandeep Singh
One clarification on "System Time" here - ZK uses two type of time/clock

* The wall-clock time, which is recorded as part of zNode stats such as
mtime and is exposed to users.
* The monotonic clock which ZK uses in various uses (e.g. failure
detection) to measure intervals. Note in 3.4 ZK still uses wall-clock for
interval measuring so you may see interesting behavior when your system
time change, but this will be fixed in the coming 3.4.11 release.

On Fri, Jul 21, 2017 at 11:48 AM, Sandeep Singh <[hidden email]>
wrote:

> Adding the Amr question.
> Few things which I want to add is:
>
> Does zookeeper uses System Time for below things
> 1) Leader election
> 2) Deciding a slave is available/alive or not.
> 3) Deciding leader/master is alive or not.
> 4) Deciding a transaction timeout etc.
> 5) Ordering the transaction etc.
>
> regards,
> Sandeep.
>
>
>
> --
> View this message in context: http://zookeeper-user.578899.
> n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583223.html
> Sent from the zookeeper-user mailing list archive at Nabble.com.
>



--
Cheers
Michael.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Alexander Shraer-2
The general idea is to use time for availability but not correctness. So a
leader could be suspected as failed which may make the system unavailable
until a new one is elected but consistency is not affected.

Alex
On Fri, Jul 21, 2017 at 1:56 PM Michael Han <[hidden email]> wrote:

> One clarification on "System Time" here - ZK uses two type of time/clock
>
> * The wall-clock time, which is recorded as part of zNode stats such as
> mtime and is exposed to users.
> * The monotonic clock which ZK uses in various uses (e.g. failure
> detection) to measure intervals. Note in 3.4 ZK still uses wall-clock for
> interval measuring so you may see interesting behavior when your system
> time change, but this will be fixed in the coming 3.4.11 release.
>
> On Fri, Jul 21, 2017 at 11:48 AM, Sandeep Singh <[hidden email]>
> wrote:
>
> > Adding the Amr question.
> > Few things which I want to add is:
> >
> > Does zookeeper uses System Time for below things
> > 1) Leader election
> > 2) Deciding a slave is available/alive or not.
> > 3) Deciding leader/master is alive or not.
> > 4) Deciding a transaction timeout etc.
> > 5) Ordering the transaction etc.
> >
> > regards,
> > Sandeep.
> >
> >
> >
> > --
> > View this message in context: http://zookeeper-user.578899.
> > n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583223.html
> > Sent from the zookeeper-user mailing list archive at Nabble.com.
> >
>
>
>
> --
> Cheers
> Michael.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Amr Alanwar
In reply to this post by hanm
Thanks guys for your replies and prompt responses,

1) if mtime is just for user recording, then the user and all the elected masters should be synchronized over the working period. Right?
2) Concenrning the MONOTONIC_CLOCK, excuse me, I have the following confusion
a- Do we need to keep the MONOTONIC_CLOCK consistent from master to another, i.e, when a master goes down and another one takes over?
b- I can summarize that the ZooKeeper job correctness depends only on the MONOTONIC_CLOCK at the clients and the master. No wall time is used at the client side at all. Wall time is used just for recording at the master. Right?

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Amr Alanwar
Any idea Guys on my last post, please?

Thanks!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Abraham Fine
In reply to this post by Alexander Shraer-2
@Amr -Sorry for the delayed response.  I could be wrong but I don't
think mtimes would have any impact on anything.

What do you think could go wrong?

Abe

On Fri, Jul 21, 2017, at 11:56, Alexander Shraer wrote:

> As far as I understand:
>
> 1) no
> 2) yes
> 3) yes
> 4) yes
> 5) no, except for the sync command (there is a jira open for that)
>
> Others please correct me if I'm wrong
>
>
> Thanks
> Alex
>
> On Fri, Jul 21, 2017 at 11:52 AM Sandeep Singh <[hidden email]>
> wrote:
>
> > Adding the Amr question.
> > Few things which I want to add is:
> >
> > Does zookeeper uses System Time for below things
> > 1) Leader election
> > 2) Deciding a slave is available/alive or not.
> > 3) Deciding leader/master is alive or not.
> > 4) Deciding a transaction timeout etc.
> > 5) Ordering the transaction etc.
> >
> > regards,
> > Sandeep.
> >
> >
> >
> > --
> > View this message in context:
> > http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583223.html
> > Sent from the zookeeper-user mailing list archive at Nabble.com.
> >
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Abraham Fine-2
@Amr it looks like I did not see your last email.

1. I think that would certainly be ideal, but it is a really difficult
problem to solve.
2a. Nope
2b. Yup

On Mon, Jul 31, 2017, at 11:40, Abraham Fine wrote:

> @Amr -Sorry for the delayed response.  I could be wrong but I don't
> think mtimes would have any impact on anything.
>
> What do you think could go wrong?
>
> Abe
>
> On Fri, Jul 21, 2017, at 11:56, Alexander Shraer wrote:
> > As far as I understand:
> >
> > 1) no
> > 2) yes
> > 3) yes
> > 4) yes
> > 5) no, except for the sync command (there is a jira open for that)
> >
> > Others please correct me if I'm wrong
> >
> >
> > Thanks
> > Alex
> >
> > On Fri, Jul 21, 2017 at 11:52 AM Sandeep Singh <[hidden email]>
> > wrote:
> >
> > > Adding the Amr question.
> > > Few things which I want to add is:
> > >
> > > Does zookeeper uses System Time for below things
> > > 1) Leader election
> > > 2) Deciding a slave is available/alive or not.
> > > 3) Deciding leader/master is alive or not.
> > > 4) Deciding a transaction timeout etc.
> > > 5) Ordering the transaction etc.
> > >
> > > regards,
> > > Sandeep.
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > > http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583223.html
> > > Sent from the zookeeper-user mailing list archive at Nabble.com.
> > >
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: ZooKeeper Time Synchronization

Amr Alanwar
Hi Abraham,

Thanks a lot for your reply. I really appreciate.

Regards,
Amr
Loading...