561fab1650
lease: fix "unconvert" warnings
...
Signed-off-by: Gyuho Lee <gyuhox@gmail.com >
2018-04-30 15:32:16 -07:00
13ed9f3197
lease: Clean-up old TODO around lease map and priority queue
...
This TODO was addressed in #9418 .
2018-04-27 10:08:15 -05:00
9c62d7b2d1
leaes: remove unnecessary O(log N) operation when nothing is expiry
...
Since heap is already sorted, we can just check first element
to see if anything is expiry, rather than popping and pushing
it back. If nothing is expiry, pop operation is unnecessary.
Signed-off-by: Gyuho Lee <gyuhox@gmail.com >
2018-04-02 16:34:34 -07:00
a6984c53de
lease: add "expireExists"
...
Signed-off-by: Gyuho Lee <gyuhox@gmail.com >
2018-04-02 16:34:34 -07:00
51b8d68a7f
lease: godoc "LeaseWithTime", change field name to "id"
...
No need to have "lease" in field name.
Signed-off-by: Gyuho Lee <gyuhox@gmail.com >
2018-04-02 14:58:34 -07:00
6f271d8bf1
lease: Add a heap to optimize lease expiration checks
...
This adds a heap acting as a priority queue to keep track of lease
exiprations. Previously the whole lease map had to be iterated through
each time.
The queue allows us to check only those leases which might be expired.
When the expiration changes, we add an additional entry. If we check an
entry that isn't expired, it means that the lease got extended.
If we find a entry in the heap that doesn't have a corresponding entry in
the map, we know that the lease has already been expired or revoked.
2018-04-02 11:52:55 -07:00
db21941d1d
*: enforce max lease TTL with 9,000,000,000 seconds
...
math.MaxInt64 / time.Second is 9,223,372,036. 9,000,000,000 is easier to
remember/document.
2018-03-08 10:17:12 -08:00
4822116698
lease: Change lease Mutex to RWMutex
2018-01-25 16:19:28 +08:00
0e0d9e492f
lease: use time.Until in 'Remaining'
...
Fix 'gosimple' warnings.
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com >
2017-09-07 18:41:36 -07:00
eb55917ef6
Merge pull request #8507 from lorneli/lease_monotime
...
lease: use monotime in time.Time for Go 1.9
2017-09-07 15:43:24 -07:00
63aa64d240
lease: use monotime in time.Time for Go 1.9
...
The golang/time package tracks monotonic time in each time.Time
returned by time.Now function for Go 1.9.
Use time.Time to measure whether a lease is expired and remove
previous pkg/monotime. Use zero time.Time to mean forever. No
expiration when expiry.IsZero() is true.
2017-09-07 14:18:19 +08:00
7063a5e5cc
lease: add limit in lessor.findExpiredLeases function
...
Function findExpiredLeases finds expired leases in the leaseMap until
reaching expired limit.
2017-09-07 02:34:56 +08:00
77a19cd9d4
lease: fix typos
...
a. fix typo in godoc
b. make receiver of FakeLessor's function identical
2017-09-07 02:34:15 +08:00
099fbde809
lease: add 'Leases' method
...
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com >
2017-08-14 14:18:53 -07:00
c38c00f7c3
lessor: extend leases on promote if expires will be rate limited
...
Instead of unconditionally randomizing, extend leases on promotion
if too many leases expire within the same time span. If the server
has few leases or spread out expires, there will be no extension.
2017-06-22 11:25:34 -07:00
5bba05703c
lease: randomize expiry on initial refresh call
...
Randomize the very first expiry on lease recovery
to prevent recovered leases from expiring all at
the same time.
Address https://github.com/coreos/etcd/issues/8096 .
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com >
2017-06-15 12:57:49 -07:00
0011b78bd5
lease: rate limit revoke runLoop
...
Fix https://github.com/coreos/etcd/issues/8097 .
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com >
2017-06-14 14:22:16 -07:00
f0c184b3a2
lease: support mvcc txn
2017-03-08 20:54:15 -08:00
6f0723f23f
lease: guard 'Lease.itemSet' from concurrent writes
...
Fix https://github.com/coreos/etcd/issues/7448 .
Affected if etcd builds with Go 1.8+.
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com >
2017-03-08 11:01:42 -08:00
b5cde6b321
lease: use atomics for accessing lease expiry
...
Demote was racing on expiry when LeaseTimeToLive called Remaining. Replace
with intrinsics since the ordering isn't important, but torn writes are
bad.
2016-12-28 15:44:14 -08:00
e7f4010cca
lease: Use monotonic time in lease
...
lease uses monotimer to calculate its expiration. In this way, changing system time won't affect in lease expiration.
FIX #6700
2016-11-29 12:31:00 -08:00
064e02f4b3
mvcc: Optimize updating key by storing lease in lessor
2016-10-12 09:37:09 +05:00
5adca4a720
lease, leasehttp: add TTL() method
...
Fix https://github.com/coreos/etcd/issues/6595 .
2016-10-06 11:24:09 -07:00
f0469f7f25
Merge pull request #6570 from xiang90/lease_expire
...
Fix lease expire
2016-10-05 15:49:45 -07:00
279c103517
lease: fix lease expire and add a test
2016-10-05 14:41:47 -07:00
4f9be94643
lessor: delete keys in deterministic order on revoke
...
Fixes #6558
2016-09-30 16:45:52 -07:00
4871a4a5f3
lease: remove redundant get method
2016-09-30 10:27:27 -07:00
617d2d5b98
lease/*: add lease handler for 'LeaseTimeToLive'
2016-09-09 08:11:46 +09:00
d69d438289
*: minor cleanup for lease
2016-08-04 20:39:32 -07:00
75c06cacae
lease: do lease delection in the kv txn
2016-08-04 10:06:47 -07:00
4d59b6f52c
lease: delete kvs in a txn
2016-08-04 10:06:46 -07:00
bf71497537
etcdserver, lease: tie lease min ttl to election timeout
2016-08-02 13:06:57 -07:00
ea21b8ee1f
lessor: fix go vet, goword warnings, and unreliable test
2016-06-17 13:37:25 -07:00
ef44f71da9
*: update LICENSE header
2016-05-12 20:51:48 -07:00
b7ac758969
*: rename storage package to mvcc
2016-04-25 15:25:51 -07:00
e9a0a103e5
*: refresh the lease TTL correctly when a leader is elected.
...
The new leader needs to refresh with an extened TTL to gracefully handle
the potential concurrent leader issue. Clients might still send keep alive
to old leader until the old leader itself gives up leadership at most after
an election timeout.
2016-03-15 22:40:03 -07:00
adcba975cb
*: recover lessor when applying snapshot
2016-03-10 17:06:58 -08:00
bfa5e310a9
*: detach keys from leases
...
1. deatch when a key is removed
2. deatch when the key's lease changes
3. potentially deatch when restroing a tombstone key
2016-02-11 15:31:25 -08:00
20461ab11a
*: fix many typos
2016-01-31 21:42:39 -08:00
e925a359a2
lease: fix restore
2016-01-25 10:06:14 +08:00
9572197aee
etcdserver: return error when putting a key with a bad lease id
2016-01-22 20:47:31 -08:00
be7d573366
lease: store server-decided TTL in lease
...
If actual TTL is not stored in lease, the client will receive the correct
TTL and therefore won't be able to keepalive correctly.
2016-01-22 11:44:12 -08:00
9113a27bde
lease: grant consistent lease IDs
...
When raft broadcasts a Grant to all nodes, all nodes must
agree on the same lease ID. Otherwise, attaching a key to
a lease will fail since the lease ID is node-dependent.
2016-01-22 09:43:39 -08:00
835d824965
*: minor typos, kill TODOs
2016-01-20 16:21:39 -08:00
b6077f9d57
*: fix minor typos
2016-01-14 01:28:29 -08:00
6b1d9fb7ce
*: stop lessor when etcdserver is stopped
2016-01-12 10:06:11 -08:00
59bf83c7f4
*: now lease keepAlive works on leader
2016-01-09 22:12:02 -08:00
f01c8188f8
*: rename lease.DeleteableRange to lease.RangeDeleter
2016-01-09 11:01:58 -08:00
f5753f2f51
*: support lease Attach
...
Now we can attach keys to leases. And revoking the lease removes all
the attached keys of that lease.
2016-01-09 11:01:58 -08:00
12912501bd
lease: remove minExpiry and add helper funcs
2016-01-08 14:29:33 -08:00