Discussion:
ZooKeeper Time Synchronization
Amr
2017-07-20 06:24:03 UTC
Permalink
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.
Abraham Fine
2017-07-21 18:00:15 UTC
Permalink
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
Post by Amr
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?
--
http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Amr
2017-07-21 18:30:14 UTC
Permalink
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.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583222.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Sandeep Singh
2017-07-21 18:48:25 UTC
Permalink
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.
Alexander Shraer
2017-07-21 18:56:59 UTC
Permalink
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
Post by Sandeep Singh
Adding the Amr question.
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.
--
http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583223.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Sandeep Singh
2017-07-21 20:18:46 UTC
Permalink
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.



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583225.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Amr Alanwar
2017-07-31 21:00:59 UTC
Permalink
Hi Abraham,

Thanks a lot for your reply. I really appreciate.

Regards,
Amr



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583236.html
Sent from the zookeeper-user mailing list archive at Nabble.com.

Michael Han
2017-07-21 20:55:23 UTC
Permalink
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.
Post by Sandeep Singh
Adding the Amr question.
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.
Alexander Shraer
2017-07-21 21:09:53 UTC
Permalink
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
Post by Michael Han
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.
Post by Sandeep Singh
Adding the Amr question.
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.
Michael Han
2017-07-21 20:53:15 UTC
Permalink
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.
Post by Amr
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?
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.
Amr Alanwar
2017-07-21 21:23:38 UTC
Permalink
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!



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583230.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Amr Alanwar
2017-07-23 04:35:41 UTC
Permalink
Any idea Guys on my last post, please?

Thanks!



--
View this message in context: http://zookeeper-user.578899.n2.nabble.com/ZooKeeper-Time-Synchronization-tp7583217p7583232.html
Sent from the zookeeper-user mailing list archive at Nabble.com.
Loading...