9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@swtch.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] QTCTL?
Date: Thu,  1 Nov 2007 13:03:45 -0400	[thread overview]
Message-ID: <20071101170234.13E9E1E8C55@holo.morphisms.net> (raw)
In-Reply-To: <13426df10711010904r317f9fd6v14a87dc2f024b0b1@mail.gmail.com>

> The fact is we have loose consistency now, we just don't call it that.
> Anytime you are running a file from a server, you have loose
> consistency. It works ok in most cases.

Because all reads and writes go through to the
server, all file system operations on a particular
server are globally ordered, *and* that global ordering
matches the actual sequence of events in the
physical world (because clients wait for R-messages).
That's a pretty strong consistency statement!

Any revocation-based system has to have the server
wait for an acknowledgement from the client.
If there is no wait, then between the time that the server
sends the "oops, stop caching this" and the client
processes it, the client might incorrectly use the
now-invalid data.  That's why a change file doesn't
provide the same consistency guarantees as pushing
all reads/writes to the file server.  To get those, revocations
fundamentally must wait for the client.  

It's also why this doesn't work:

> Tcache	asks whether the server is prepared to cache
> Rcache	makes lease available with parameters, Rerror says no.
> 
> Tlease	says, ok start my lease now (almost immediately follows Rache)
> Rlease	lease expired or lease needs to be given back early
> 
> Tcache	done with old lease (may immediately ask for a new lease)
> etc.

because the Rlease/Tcache sequence is a s->c->s
message.  If a client doesn't respond with the Tcache
to formally give up the lease, the server has no choice
but to wait.

If you are willing to assume that each machine has
a real-time clock that runs approximately at the
same rate (so that different machines agree on 
what 5 seconds means, but not necessarily what
time it is right now), then you can fix the above messages
by saying that the client lease is only good for a fixed
time period (say 5 seconds) from the time that the
client sent the Tlease.  Then the server can overestimate
the lease length as 5 seconds from when it sent the
Rlease, and everything is safe.  And if the server 
sends a Rlease and the client doesn't respond with
a Tcache to officially renounce the lease, the server
can just wait until Tlease + 5 seconds and go on.
But that means the client has to be renewing the
lease every 5 seconds (more frequently, actually).

Also, in the case where the lease is just expiring
but not being revoked, then you have to have some
mechanism for establishing the new lease before
the old one runs out.  If there is a time between
two leases when you don't hold any leases, then 
all your cached data becomes invalid.

The following works:

Tnewlease	asks for a new lease
Rnewlease	grants the lease, for n seconds starting at time of Tnewlease

Trenewlease	asks to renew the lease
Rrenewlease	grants the renewal for n seconds starting at time of Trenewlease

Now if the server needs to revoke the lease, it just 
refuses to renew and waits until the current lease expires.

You can add a pseudo-callback to speed up revocation
with a cooperative client:

Tneeditback	offers to give lease back to server early
Rneeditback	says I accept your offer, please do

Tdroplease	gives lease back
Rdroplease	says okay I got it (not really necessary)

The lease ends when the client sends Tdroplease, 
*not* when the server sends Rneeditback.  It can't end
at Rneeditback for the same reason change files don't work.
And this can *only* be an optimization, because it 
depends on the client sending Tdroplease.  To get 
something that works in the presence of misbehaved
clients you have to be able to fall back on the 
"wait it out" strategy.

One could, of course, use a different protocol with 
a 9P front end.  That's okay for clients, but you'd still
have to teach the back-end server (i.e. fossil) to speak
the other protocol directly in order to get any guarantees.
(If 9P doesn't cut it then anything that's just in front of
(not in place of) a 9P server can't solve the problem.)

Russ


  parent reply	other threads:[~2007-11-01 17:03 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-31 18:40 Francisco J Ballesteros
2007-10-31 18:56 ` Eric Van Hensbergen
2007-10-31 19:13   ` Charles Forsyth
2007-10-31 19:33     ` Eric Van Hensbergen
2007-10-31 19:39       ` erik quanstrom
2007-10-31 20:43     ` geoff
2007-10-31 21:32       ` Charles Forsyth
2007-10-31 22:48       ` roger peppe
2007-10-31 23:35         ` erik quanstrom
2007-11-01  9:29           ` roger peppe
2007-11-01 11:03             ` Eric Van Hensbergen
2007-11-01 11:19               ` Charles Forsyth
2007-11-01 12:11             ` erik quanstrom
2007-10-31 19:42 ` erik quanstrom
2007-10-31 19:49   ` Eric Van Hensbergen
2007-10-31 20:03     ` erik quanstrom
2007-10-31 20:10       ` Latchesar Ionkov
2007-10-31 20:12       ` Eric Van Hensbergen
2007-10-31 20:17       ` Russ Cox
2007-10-31 20:29         ` Francisco J Ballesteros
2007-10-31 20:48           ` Charles Forsyth
2007-10-31 21:23             ` Francisco J Ballesteros
2007-10-31 21:40               ` Russ Cox
2007-10-31 22:11                 ` Charles Forsyth
2007-10-31 22:26                 ` Francisco J Ballesteros
2007-10-31 22:37                   ` Charles Forsyth
2007-10-31 22:43                     ` Francisco J Ballesteros
2007-10-31 23:32                     ` Eric Van Hensbergen
2007-10-31 23:41                       ` [V9fs-developer] " Charles Forsyth
     [not found]                       ` <606b6f003ae9f0ed3e8c3c5f90ddc720@terzarima.net>
2007-11-01  1:13                         ` Eric Van Hensbergen
2007-10-31 23:54                   ` erik quanstrom
2007-11-01  0:03                     ` Charles Forsyth
2007-11-01  1:25                     ` Eric Van Hensbergen
2007-11-01  1:44                       ` erik quanstrom
2007-11-01  2:15                         ` Eric Van Hensbergen
2007-11-01  7:34                       ` Skip Tavakkolian
2007-11-01  6:21                 ` Bakul Shah
2007-11-01 14:28                   ` Russ Cox
2007-11-01 14:38                     ` erik quanstrom
2007-11-01 14:41                     ` Charles Forsyth
2007-11-01 15:26                     ` Sape Mullender
2007-11-01 15:51                       ` Latchesar Ionkov
2007-11-01 16:04                         ` ron minnich
2007-11-01 16:16                           ` Latchesar Ionkov
2007-11-01 16:21                           ` Sape Mullender
2007-11-01 16:58                             ` Francisco J Ballesteros
2007-11-01 17:11                               ` Charles Forsyth
2007-11-01 17:11                                 ` Francisco J Ballesteros
2007-11-01 17:13                               ` Sape Mullender
2007-11-01 17:38                               ` ron minnich
2007-11-01 17:56                                 ` Francisco J Ballesteros
2007-11-01 18:01                                   ` Francisco J Ballesteros
2007-11-01 18:52                                   ` Eric Van Hensbergen
2007-11-01 19:29                                     ` Francisco J Ballesteros
2007-11-01 23:24                                   ` ron minnich
2007-11-01 17:03                           ` Russ Cox [this message]
2007-11-01 17:12                             ` Sape Mullender
2007-11-01 17:35                               ` erik quanstrom
2007-11-01 18:36                                 ` erik quanstrom
2007-11-01 17:13                             ` Charles Forsyth
2007-11-01 17:16                               ` Charles Forsyth
2007-11-01 17:20                                 ` Charles Forsyth
2007-11-01 17:52                             ` Eric Van Hensbergen
2007-11-01 18:00                             ` Latchesar Ionkov
2007-11-01 18:03                               ` Francisco J Ballesteros
2007-11-01 18:08                                 ` Latchesar Ionkov
2007-11-01 18:16                                   ` erik quanstrom
2007-11-01 18:19                                   ` Francisco J Ballesteros
2007-11-01 18:35                                     ` Sape Mullender
2007-11-01 19:09                                       ` Charles Forsyth
2007-11-01 19:07                                         ` erik quanstrom
2007-11-01 17:14                           ` Bakul Shah
2007-11-01 16:17                         ` Sape Mullender
2007-11-01 16:27                           ` Sape Mullender
2007-11-01 16:58                         ` Sape Mullender
2007-11-01 16:59                     ` Bakul Shah
2007-11-01  4:21 Brian L. Stuart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071101170234.13E9E1E8C55@holo.morphisms.net \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).