While reading article from google about chubby, I didn't really understand the purpose of sequencers
Assume we have 4 entities :
- Chubby cell
- Client 1
- Client 2
- Service we want to use and where we will send the requests (for which we need the lock)
As far as I understood the steps are:
Client 1 send
lock_request()
to Chubby cell, Chubby responses withSequencer
(assumeSequenceNumber = 1
)Client 1 send request
modify_data()
with Sequencer (SequenceNumber = 1) to Service- Service asks Chubby cell if SequenceNumber is valid (=1)
- Chubby acknowledges it, set
LeasePeriod
(period of lock expiration to (assume) 60 seconds) ! during this time no one is able to acquire the lock - After acknowledge, Service cache the data about Client 1 (SequenceNumber = 1) for (assume) 40 seconds
Now: if Client 2 tries to acquire lock during these 60 seconds we set, it will be rejected by Chubby cell
that means it is impossible that Client 2 will acquire the lock with the next SequenceNumber = 2 and send anything to the Service
As far as I understand all purpose of SequenceNumber is just for situation when 2 requests come to Service and Service can just compare 2 SequenceNumbers and reject the lower, without need to ask Chubby cell
but how this situation will ever happen if we have caches and impossibility to get the lock by Client 2 while Client 1 is holding this lock?