56 Commits

Author SHA1 Message Date
yura
26cce20022 clientv3: concurrency.Mutex.Lock() - preserve invariant
Convenient invariant:
- if werr == nil then lock is supposed to be locked at the moment.

While we could not be confident in stronger invariant ('is exactly locked'),
it were inconvenient that previous code could return `werr == nil` after
Mutex.Unlock.

It could happen when ctx is canceled/timeouted exactly after waitDeletes
successfully returned werr == nil and before `<-ctx.Done()` checked.
While such situation is very rare, it is still possible.

fixes #10111
2018-10-08 16:46:22 -07:00
Gyu-Ho Lee
a8c84ffc93 clientv3: fix client balancer with gRPC v1.7
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
2017-11-16 09:05:06 -08:00
Anthony Romano
2188513161 concurrency: retry snapshot serializable stm if writes since first header rev
Was checking the rset key mod rev, which does not work.
2017-08-22 20:53:47 -07:00
Anthony Romano
24e85b2454 Merge pull request #7852 from heyitsanthony/revert-lease-err-ka
Revert "Merge pull request #7732 from heyitsanthony/lease-err-ka"
2017-05-03 11:03:17 -07:00
Anthony Romano
31d5d610fc concurrency: provide old STM functions as deprecated
semver
2017-05-03 02:07:01 -07:00
Anthony Romano
6dd8fb6f24 Revert "Merge pull request #7732 from heyitsanthony/lease-err-ka"
This reverts commit fbbc4a4979b256125d2238f6325ad86e7f1b58bd, reversing
changes made to f254e383859a2939d5929346f6595549f424f7c5.

Fixes #7851
2017-05-02 09:36:16 -07:00
Anthony Romano
50f29bd661 concurrency: use current revisions for election
Watching from the leader's ModRevision could cause live-locking on
observe retry loops when the ModRevision is less than the compacted
revision. Instead, start watching the leader from at least the store
revision of the linearized read used to detect the current leader.

Fixes #7815
2017-04-25 20:15:50 -07:00
Anthony Romano
f224d74ed7 concurrency: use new lease interface in session 2017-04-24 23:49:44 -07:00
Anthony Romano
c1300c81b3 concurrency: clarify Observe semantics; only fetches subsequence 2017-04-22 11:26:11 -07:00
Anthony Romano
4f9aa276bd *: rename Snapshot STM isolation to SerializableSnapshot
Pure Snapshot isolation would permit read conflicts. Change the name
from Snapshot to SerializableSnapshot to reflect that it will also
reject read conflicts.
2017-04-11 17:17:50 -07:00
Anthony Romano
4b4f5be74a concurrency: don't skip leader updates in Observe()
The Get for the leader key will fetch based on the latest revision
instead of the deletion revision, missing leader updates between
the delete and the Get.

Although it's usually safe to skip these updates since they're
stale, it makes testing more difficult and in some cases the
full leader update history is desirable.
2017-04-07 16:36:38 -07:00
Anthony Romano
80c1b9c13a concurrency: support resuming elections if leadership already held
If a client already knows it holds leadership, let it create an
election object with its leadership information.
2017-04-07 16:36:38 -07:00
Anthony Romano
d1ae4cd5bd concurrency: only delete on election resignation if create revision matches
Addresses a case where two clients share the same lease. A client resigns but
disconnects / crashes and doesn't realize it. Another client reuses the
lease and gets leadership with a new key. The old client comes back and
tries to resign again, revoking the new leadership of the new client.
2017-04-07 16:36:37 -07:00
Anthony Romano
4b5bb7f212 concurrency: return v3.GetResponse for Election.Leader()
The full information about the leader's key is necessary to
safely use elections with transactions. Instead of returning
only the value on Leader(), return the entire GetResposne.
2017-04-07 16:36:37 -07:00
Anthony Romano
a6cab69c88 concurrency: expose leader revision and proclaim headers for election 2017-04-07 16:36:37 -07:00
Anthony Romano
d51c8bb640 concurrency: support returning response header for mutex 2017-03-13 15:23:26 -07:00
Ravi Gadde
c586218ec6 clientv3: start a session with existing lease
This change is needed to handle process restarts with elections. When the
leader process is restarted, it should be able to hang on to the leadership
by using the existing lease.

Fixes #7166
2017-01-30 18:07:22 -08:00
Anthony Romano
8695511153 concurrency: STM snapshot isolation level 2017-01-20 16:22:43 -08:00
Anthony Romano
8604d1863b concurrency: STM WithPrefetch option
Fixes #6923
2017-01-20 16:22:42 -08:00
Anthony Romano
a81234a25b concurrency: extend STM interface to Get from any of a list of keys
Now possible to fetch multiple keys in a single txn.
2017-01-20 16:22:42 -08:00
Anthony Romano
59880a0ab8 concurrency: variadic stm options
Makes txn isolation and the context variadic options.
2017-01-20 16:22:42 -08:00
Derek Chiang
acec15ebc6 clientv3/concurrency: fix rev comparison on concurrent key deletion 2017-01-19 20:51:31 -08:00
Anthony Romano
f38a5d19a8 concurrency: add WithContext option to sessions
Makes it possible to cancel session requests without having to
close the entire client.
2016-10-21 16:26:59 -07:00
Anthony Romano
1e330a90c7 concurrency: terminate session.Close if revoke takes longer than TTL
Fixes #6681
2016-10-21 16:21:01 -07:00
Anthony Romano
9b1fe45853 concurrency: use create max revision for locks and elections 2016-09-14 17:03:33 -07:00
Xiang Li
56084a7cc8 clientv3: return error from response when possible 2016-09-13 11:18:21 +08:00
Jason E. Aten
9497e9678c clientv3/concurrency: allow election on prefixes of keys.
After winning an election or obtaining a lock, we
auto-append a slash after the provided key prefix.
This avoids the previous deadlock due to waiting
on the wrong key.

Fixes #6278
2016-08-29 18:34:14 -07:00
Xiang Li
feaff17259 session: remove session manager and add ttl 2016-08-15 14:12:25 -07:00
Anthony Romano
51551abef5 concurrency, benchmark: read-committed STM isolation policy 2016-05-31 14:35:27 -07:00
Gyu-Ho Lee
fa1e40c120 clientv3/concurrency: preallocate slice in stm 2016-05-19 14:42:19 -07:00
Anthony Romano
120020fa9c clientv3/concurrency: use session id for election keys to avoid deadlock 2016-05-13 10:07:35 -07:00
Anthony Romano
393725fe5f clientv3/concurrency: ctx-ize Leader(), Resign(), and Unlock() 2016-05-13 10:07:35 -07:00
Gyu-Ho Lee
fd9e07a529 clientv3: update LICENSE header 2016-05-12 20:50:58 -07:00
Anthony Romano
22797c7185 clientv3/concurrency: use session lease id for mutex keys
With randomized keys, if the connection goes down, but the session remains,
the client would need complicated recovery logic to avoid deadlock.
Instead, bind the session's lease id to the lock entry; if a session tries
to reacquire the lock it will reassume its old place in the wait list.
2016-04-26 17:37:26 -07:00
Anthony Romano
b7ac758969 *: rename storage package to mvcc 2016-04-25 15:25:51 -07:00
Gyu-Ho Lee
fb85da92e8 *: fix based on gosimple and unused 2016-04-07 23:16:37 -07:00
Anthony Romano
dc17eaace7 *: rename Lease Create to Grant
Creating a lease through the client API interface union looked like
"c.Create(...)"-- the method name wasn't very descriptive.
2016-04-07 12:28:14 -07:00
Anthony Romano
489779d905 clientv3: rename comparison from CreatedRevision to CreateRevision
To match protobuf naming
2016-03-23 09:50:46 -07:00
Xiang Li
88e738fcb6 Merge pull request #4844 from ajityagaty/polish_naming_conventions
clientv3: Renaming SortByCreatedRev to maintain consistency.
2016-03-23 09:27:34 -07:00
Ajit Yagaty
2bb417bfff clientv3: Renaming SortByCreatedRev to maintain consistency.
Renamed SortByCreatedRev to SortByCreateRevision to be consistent
with the naming used for SortByModRevision.
2016-03-22 17:56:24 -07:00
Anthony Romano
bd832e5b0a *: migrate Godeps to vendor/ 2016-03-22 17:10:28 -07:00
Ajit Yagaty
606889a002 clientv3: Fix inconsistent naming convention in v3 client.
In order to have a consistent naming for variable/function names
pertaining to ModifiedRevision, all occurrences have been renamed
to ModRevision.
2016-03-22 14:58:11 -07:00
Gyu-Ho Lee
dae7e009b0 *: godoc clean up 2016-03-19 14:19:23 -07:00
Gyu-Ho Lee
4e4f0ab619 clientv3/concurrency: fix godoc 2016-03-18 16:34:58 -07:00
Anthony Romano
a001651bc1 clientv3: remove dependency on lease package 2016-03-17 11:52:34 -07:00
Anthony Romano
bc37a32062 clientv3/concurrency: software transactional memory
Repeatable read and serialized read STM implementations.
2016-03-16 11:23:06 -07:00
Anthony Romano
360aafec76 clientv3: include a context in Client
Useful for clean up tasks
2016-03-04 09:20:44 -08:00
Anthony Romano
1e16758029 clientv3: add Err() to WatchResponse
Checking for number of events as a failure condition was a kludge.
2016-03-03 15:21:04 -08:00
Anthony Romano
6d3f172c6e clientv3/concurrency: don't poll in mutex lock on early prior key delete
Lock would get the prior key on retry using WithRev(myRev - 1) instead of
using the latest revision; the Watch() would return immediately and Lock
devolves into polling.
2016-03-03 10:04:57 -08:00
Anthony Romano
3327858a54 clientv3/concurrency: move election recipe into clientv3 2016-03-03 00:22:19 -08:00