Commit Graph

101 Commits (b7f0f52a16dbf83f18ca1d803f7892d750366a94)

Author SHA1 Message Date
Piotr Tabor 28f2b07623 *: Update references to code moved to the api/ dir.
Follow up to file-moves done in the previous commit.

The commit contains purely mechanical consequences of execution (apart
of scripts/genproto.sh):

  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/etcdserver/api/v3rpc/rpctypes|v3/api/v3rpc/rpctypes|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/version|v3/api/version|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/mvcc/mvccpb|v3/api/mvccpb|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/etcdserver/etcdserverpb|v3/api/etcdserverpb|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/etcdserver/api/membership/membershippb|v3/api/membershippb|g'
  % find ./ -name '*.go'  | xargs sed --follow-symlinks -i 's|v3/auth/authpb|v3/api/authpb|g'

  % find ./ -name '*.proto' -o -name '*.md'  | xargs -L 1 sed --follow-symlinks -i 's|/mvcc/mvccpb/kv.proto|/api/mvccpb/kv.proto|g'
  % find ./ -name '*.proto' -o -name '*.md'  | xargs -L 1 sed --follow-symlinks -i 's|/auth/authpb/auth.proto|/api/authpb/auth.proto|g'
  % find ./ -name '*.proto' -o -name '*.md'  | xargs -L 1 sed --follow-symlinks -i 's|/etcdserver/api/membership/membershippb/membership.proto|/api/membershippb/membership.proto|g'

  I also modified manually paths in scripts/genproto.sh.

  % go fmt ./...
2020-10-06 11:56:16 +02:00
Jingyi Hu cc564110bd
clientv3: remove excessive watch cancel logging (#12187) 2020-07-29 14:58:53 -07:00
Gyuho Lee a4ada8cb1f
Merge pull request #11922 from tedyu/non-recursive-watch
clientv3: non-recursive Watch()
2020-05-20 20:36:09 -07:00
Ted Yu f976138186 clientv3: non-recursive watch
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
2020-05-20 15:44:41 -07:00
Ted Yu 35d026246c clientv3: use Mutex for watcher lock
Signed-off-by: Ted Yu <yuzhihong@gmail.com>
2020-05-19 19:20:44 -07:00
Jack Kleeman ec13797407
mvcc: avoid negative watcher count metrics (#11882)
The watch count metrics are not robust to duplicate cancellations. These
cause the count to be decremented twice, leading eventually to negative
counts. We are seeing this in production. The duplicate cancellations
themselves are not themselves a big problem (except performance), but
they are caused by the new proactive cancellation logic (#11850) which
cancels proactively even immediately before initiating a Close, thus
nearly guaranteeing a Close-cancel race, as discussed in
watchable_store.go. We can avoid this in most cases by not sending a
cancellation when we are going to Close.
2020-05-12 16:50:53 -07:00
Jack Kleeman 87aa5a9e60 clientv3: cancel watches proactively on client context cancellation
Currently, watch cancel requests are only sent to the server after a
message comes through on a watch where the client has cancelled. This
means that cancelled watches that don't receive any new messages are
never cancelled; they persist for the lifetime of the client stream.
This has negative connotations for locking applications where a watch
may observe a key which might never change again after cancellation,
leading to many accumulating watches on the server.

By cancelling proactively, in most cases we simply move the cancel
request to happen earlier, and additionally we solve the case where the
cancel request would never be sent.

Fixes #9416
Heavy inspiration drawn from the solutions proposed there.
2020-05-07 16:50:26 +01:00
Brandon Philips 96cce208c2 go.mod: use go.etcd.io/etcd/v3 versioning
This change makes the etcd package compatible with the existing Go
ecosystem for module versioning.

Used this tool to update package imports:
  https://github.com/KSubedi/gomove
2020-04-28 00:57:35 +00:00
Jingyi Hu 342c2464ae Documentation: specify starting revision (#11559) 2020-01-27 10:18:27 -08:00
Jingyi Hu 5adad5e224
Merge pull request #11452 from tedyu/watch-grpc-send-err
clientv3: log warning in case of error sending request
2019-12-20 15:31:02 -08:00
Ted Yu cb8bf089f8 clientv3: log warning in case of error sending request 2019-12-20 15:08:33 -08:00
Ted Yu fb7703ab43 clientv3: remove ineffective nil check (#11451) 2019-12-15 21:38:25 -08:00
lzhfromustc 8194aa3f03
Fixed a missing block bug
Description: w.mu is locked at line 385 and unlocked at line 396. Among 5 return statements in this function, 4 are below line 396 but there is 1 return at line 387. 
Fix: Add w.mu.Unlock() before that return at line 387.
2019-06-28 11:27:13 -07:00
Gyuho Lee 34bd797e67 *: revert module import paths
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2019-05-28 15:39:35 -07:00
shivaramr 9150bf52d6 go modules: Fix module path version to include version number 2019-04-26 15:29:50 -07:00
Sahdev P. Zala b25edb62cc clientV3watch: Watch Close should close successfully
Closing of watch by client will cancel the watch grpc stream and
can produce a context canceled error. However, since client
simply wanted to close the watcher the error can create confusion
that something went wrong instead of a successful close. Ensure
that Close do not return error.

Fixed #10340
2019-02-28 20:43:20 -05:00
Shin'ya Ueoka aa4313a55a *: fix github links 2018-11-10 11:14:18 +09:00
Xiang Li ec5ff10436
Merge pull request #10019 from thrawn01/grpc-proxy-watch-errors
Improve watch error reporting when using grpc proxy
2018-09-10 12:54:33 -07:00
Gyuho Lee 2ac04381a2 clientv3: update Go import paths to "go.etcd.io"
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2018-08-28 17:47:55 -07:00
Derrick J. Wippler eb9c8d3c2f clientv3: return reason to user when server cancels watch
This change allows Watch users to retrieve the cancel reason when a
watch is canceled by the server. Additionally WatchResponses with
closeErr set now have Canceled set true which is in line with the
documentation for the Canceled field.
2018-08-16 23:11:02 -05:00
Joe Betz 4b51b6de49
*: Add progress notify request watch request 2018-06-27 16:46:13 -07:00
Gyuho Lee 11ead62b9d clientv3: clarify "WithRequireLeader" for network partition
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2018-06-20 10:28:41 -07:00
Jordan Liggitt d1579c95a2
clientv3: backoff on reestablishing watches when Unavailable errors are encountered 2018-06-13 02:05:04 -04:00
Gyuho Lee d2c8408216 clientv3: support watch events fragmentation
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2018-05-14 13:34:50 -07:00
Gyuho Lee 8a518b01c4 *: revert "internal/mvcc" change
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2018-02-26 17:11:40 -08:00
Gyuho Lee 80d15948bc *: move "mvcc" to "internal/mvcc"
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2018-01-26 11:14:41 -08:00
Gyuho Lee 31c2d4b0a2 clientv3: document possible memory pile-up in Watch
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2018-01-08 10:37:47 -08:00
Gyuho Lee 10522f88f5 clientv3: handle non -1 watch ID on cancellation
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2017-12-31 17:43:28 -08:00
Gyuho Lee f6f3a9ca69 clientv3: document context to "Watch" API
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2017-12-21 12:59:15 -08:00
Gyuho Lee 497412c588 clientv3: call other APIs with default gRPC call options
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
2017-12-20 10:58:05 -08:00
Gyu-Ho Lee 5d98710b2e api/v3rpc: deprecate grpc.Errorf
It's been deprecated as of grpc/grpc-go v1.6.x.

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
2017-11-04 22:08:17 -07:00
Gyu-Ho Lee 1fa60c9882 clientv3: add TODO for watch retry
Later we can do:

```diff
+// RetryWatchClient implements a WatchClient.
+func RetryWatchClient(c *Client) pb.WatchClient {
+	readRetry := c.newRetryWrapper(isReadStopError)
+	wc := pb.NewWatchClient(c.conn)
+	return &retryWatchClient{wc, readRetry}
+}
+
+type retryWatchClient struct {
+	pb.WatchClient
+	readRetry retryRPCFunc
+}
+
+func (rwc *retryWatchClient) Watch(ctx context.Context, opts ...grpc.CallOption) (stream pb.Watch_WatchClient, err error) {
+	err = rwc.readRetry(ctx, func(rctx context.Context) error {
+		stream, err = rwc.WatchClient.Watch(rctx, opts...)
+		return err
+	})
+	return stream, err
+}

-	return NewWatchFromWatchClient(pb.NewWatchClient(c.conn))
+	return NewWatchFromWatchClient(RetryWatchClient(c))
```

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
2017-10-19 16:02:01 -07:00
Gyu-Ho Lee f65aee0759 *: replace 'golang.org/x/net/context' with 'context'
Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
2017-09-07 13:39:42 -07:00
Anthony Romano 2d0eec0b35 clientv3: goword spelling check 2017-09-06 22:11:33 -07:00
Anthony Romano 1c75c383a1 clientv3: use FromOutgoingContext to bucket watches
Watches were bucketed on string(ctx) for historical reasons;
metadata.FromOutgoingContext should be enough to key watches now.

Fixes #8338
2017-08-01 09:26:07 -07:00
Anthony Romano 318caeee7e clientv3: return CompactRevision wresp when set with Canceled 2017-07-25 12:36:01 -07:00
Anthony Romano 13d9438cf9 clientv3: clarify Watch close conditions
The "too slow" comment is rather vague. If the server closes
the watch for being too slow (it doesn't seem to any more), the
watch client should gracefully resume instead of forcing the
user to handle it.

Also removed the 'opts' comment since it wasn't being maintained.
2017-06-15 09:34:00 -07:00
fanmin shi 762b2c625c clientv3: change watchGrpcStream Close() to close()
private struct shouldn't have public method.
2017-06-08 12:11:06 -07:00
Hitoshi Mitake 939912c425 clientv3, etcdserver: support auth in Watch() 2017-05-20 11:34:45 +09:00
Anthony Romano ca4acceb1e clientv3: set current revision to create rev regardless of CreateNotify
Turns out the optimization to ignore setting the init rev for
current revision watches breaks some ordering assumptions. Since
Watch only returns a channel once it gets a response, it should
bind the revision at the time of the first create response.

Was causing TestWatchReconnInit to fail.
2017-04-22 13:04:38 -07:00
Anthony Romano 4ab818a856 clientv3: only update initReq.rev == 0 with creation watch revision
Always updating the initReq.rev on watch create will resume from the wrong
revision if initReq is ever nonzero.
2017-04-21 20:22:51 -07:00
Anthony Romano aab2eda7df clientv3: register waitCancelSubstreams closingc goroutine with waitgroup
Fixes #7598
2017-04-05 16:06:53 -07:00
Anthony Romano a39107a3b8 clientv3: use waitgroup to wait for substream goroutine teardown
When a grpc watch stream is torn down, it will join on its logical substream
goroutines by waiting for each to close a channel. This doesn't guarantee
the substream is fully exited, though, but only about to exit and can be
waiting to resume even after Watch.Close finishes. Instead, use a
waitgroup.Done at the very end of the substream defer.

Fixes #7573
2017-03-22 23:27:26 -07:00
Anthony Romano a087325452 clientv3: close open watch channel if substream is closing on reconnect
If substream is closing but outc is still open while reconnecting, then outc
would only be closed once the watch client would connect or once the watch
client is closed. This was leading to deadlocks in the proxy tests. Instead,
close immediately if the context is canceled.

Fixes #7503
2017-03-14 17:25:18 -07:00
Anthony Romano 1aeeb38459 clientv3: let watchers cancel when reconnecting 2016-11-08 12:02:17 -08:00
Gyu-Ho Lee 0a3d45a307 clientv3: send create event over outc 2016-10-27 11:11:16 -07:00
Anthony Romano c100e40715 clientv3: only receive from closing streams in Watcher close
Was overcounting the number of expected closing messages; the resuming
list may have nil entries. Also the full client wasn't closing the watcher
client, only canceling its context, so client closes weren't joining with
the watcher shutdown.

Fixes #6605
2016-10-20 15:33:11 -07:00
Anthony Romano b980ab0c67 Merge pull request #6582 from heyitsanthony/fix-cancel-close
clientv3: only return closing error to watcher if context is not canceled
2016-10-05 13:37:29 -07:00
Anthony Romano 06d5cf2d52 clientv3: fix race on watch initial revision
The initial revision was being updated in the substream goroutine defer;
this was racing with the resume path fetching the initial revision when
the substream closes during resume. Instead, update the initial revision
whenever the substream processes a new watch response. Since the substream
cannot receive a watch response while it is resuming, the write to the
initial revision is ordered to always happen after the resume read.

Fixes #6586
2016-10-05 09:36:06 -07:00
Anthony Romano e285f599e2 clientv3: only return closing error to watcher if context is not canceled
Fixes #6503
2016-10-04 16:09:50 -07:00