github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/kv/kvserver/kvserverpb/lease_status.proto (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 syntax = "proto3"; 12 package cockroach.kv.kvserver.storagepb; 13 option go_package = "kvserverpb"; 14 15 import "roachpb/data.proto"; 16 import "kv/kvserver/kvserverpb/liveness.proto"; 17 import "util/hlc/timestamp.proto"; 18 19 import "gogoproto/gogo.proto"; 20 21 enum LeaseState { 22 // ERROR indicates that the lease can't be used or acquired. 23 ERROR = 0; 24 // VALID indicates that the lease can be used. 25 VALID = 1; 26 // STASIS indicates that the lease has not expired, but can't be 27 // used because it is close to expiration (a stasis period at the 28 // end of each lease is one of the ways we handle clock 29 // uncertainty). A lease in STASIS may become VALID for the same 30 // leaseholder after a successful RequestLease (for expiration-based 31 // leases) or Heartbeat (for epoch-based leases). A lease may not 32 // change hands while it is in stasis; would-be acquirers must wait 33 // for the stasis period to expire. 34 // 35 // The point of the stasis period is to prevent reads on the old leaseholder 36 // (the one whose stasis we're talking about) from missing to see writes 37 // performed under the next lease (held by someone else) when these writes 38 // should fall in the uncertainty window. Even without the stasis, writes 39 // performed by the new leaseholder are guaranteed to have higher timestamps 40 // than any reads served by the old leaseholder. However, a read at timestamp 41 // T needs to observe all writes at timestamps [T, T+maxOffset] and so, 42 // without the stasis, only the new leaseholder might have some of these 43 // writes. In other words, without the stasis, a new leaseholder with a fast 44 // clock could start performing writes ordered in real time before the old 45 // leaseholder considers its lease to have expired. 46 STASIS = 2; 47 // EXPIRED indicates that the lease can't be used. An expired lease 48 // may become VALID for the same leaseholder on RequestLease or 49 // Heartbeat, or it may be replaced by a new leaseholder with a 50 // RequestLease (for expiration-based leases) or 51 // IncrementEpoch+RequestLease (for epoch-based leases). 52 EXPIRED = 3; 53 // PROSCRIBED indicates that the lease's proposed timestamp is 54 // earlier than allowed. This is used to detect node restarts: a 55 // node that has restarted will see its former incarnation's leases 56 // as PROSCRIBED so it will renew them before using them. Note that 57 // the PROSCRIBED state is only visible to the leaseholder; other 58 // nodes will see this as a VALID lease. 59 PROSCRIBED = 4; 60 } 61 62 // LeaseStatus holds the lease state, the timestamp at which the state 63 // is accurate, the lease and optionally the liveness if the lease is 64 // epoch-based. 65 message LeaseStatus { 66 // Lease which this status describes. 67 roachpb.Lease lease = 1 [(gogoproto.nullable) = false]; 68 // Timestamp that the lease was evaluated at. 69 util.hlc.Timestamp timestamp = 2 [(gogoproto.nullable) = false]; 70 // State of the lease at timestamp. 71 LeaseState state = 3; 72 // Liveness if this is an epoch-based lease. 73 Liveness liveness = 4 [(gogoproto.nullable) = false]; 74 }