Add client/v3/internal/pb/clone.go as a temporary gogo clone helper,
keep clone boundaries when txn/op code retains compare state, and update
the namespace/leasing/grpcproxy/etcdctl/robustness paths to use the new
representation.
----
It uses `Cmp` to hide the underlying pointer, so any modifications must go
through the exported methods.
There are two major changes:
* Users can no longer construct a `Cmp` value with a composite literal such as
`Cmp{key: value}`.
* The original implementation only performed a shadow copy. The new change
performs a deep copy of `Key []byte` and `RangeEnd []byte`.
The original implementation does not copy `Cmp` in these three functions.
This change performs a deep copy of `Cmp` in all three functions.
* (clientv3.txn).If
* (clientv3.Op).toTxnRequest
* (clientv3).OpTxn
Within Kubernetes, kube-apiserver uses `Cmp` when performing `OptimisticPut`,
`OptimisticDelete`, and updating `compactRevKey`.
Based on the benchmark results, which still use gogo-generated protobuf
structs, simply passing values instead of performing a deep copy does not seem
to have a significant impact. Anyway, Let's use deep copy first.
```
goos: linux
goarch: amd64
pkg: go.etcd.io/etcd/client/v3
cpu: AMD Ryzen 7 5800H with Radeon Graphics
│ /tmp/bench-old.txt │ /tmp/bench-new.txt │ /tmp/bench-new-without-clone.txt │
│ sec/op │ sec/op vs base │ sec/op vs base │
TxnIfSingleCmp-16 160.6n ± ∞ ¹ 1383.0n ± ∞ ¹ ~ (p=1.000 n=1) ² 643.2n ± ∞ ¹ ~ (p=1.000 n=1) ²
KubernetesOptimisticPutTxnBuild-16 953.5n ± ∞ ¹ 2286.0n ± ∞ ¹ ~ (p=1.000 n=1) ² 1494.0n ± ∞ ¹ ~ (p=1.000 n=1) ²
OpTxnSingleCmpToTxnRequest-16 880.1n ± ∞ ¹ 2794.0n ± ∞ ¹ ~ (p=1.000 n=1) ² 1247.0n ± ∞ ¹ ~ (p=1.000 n=1) ²
geomean 512.7n 2.067µ +303.19% 1.062µ +107.17%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
│ /tmp/bench-old.txt │ /tmp/bench-new.txt │ /tmp/bench-new-without-clone.txt │
│ B/op │ B/op vs base │ B/op vs base │
TxnIfSingleCmp-16 304.0 ± ∞ ¹ 600.0 ± ∞ ¹ ~ (p=1.000 n=1) ² 448.0 ± ∞ ¹ ~ (p=1.000 n=1) ²
KubernetesOptimisticPutTxnBuild-16 2.008Ki ± ∞ ¹ 2.297Ki ± ∞ ¹ ~ (p=1.000 n=1) ² 2.148Ki ± ∞ ¹ ~ (p=1.000 n=1) ²
OpTxnSingleCmpToTxnRequest-16 1.867Ki ± ∞ ¹ 1.844Ki ± ∞ ¹ ~ (p=1.000 n=1) ² 1.539Ki ± ∞ ¹ ~ (p=1.000 n=1) ²
geomean 1.036Ki 1.354Ki +30.64% 1.131Ki +9.13%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
│ /tmp/bench-old.txt │ /tmp/bench-new.txt │ /tmp/bench-new-without-clone.txt │
│ allocs/op │ allocs/op vs base │ allocs/op vs base │
TxnIfSingleCmp-16 5.000 ± ∞ ¹ 10.000 ± ∞ ¹ ~ (p=1.000 n=1) ² 7.000 ± ∞ ¹ ~ (p=1.000 n=1) ²
KubernetesOptimisticPutTxnBuild-16 22.00 ± ∞ ¹ 27.00 ± ∞ ¹ ~ (p=1.000 n=1) ² 24.00 ± ∞ ¹ ~ (p=1.000 n=1) ²
OpTxnSingleCmpToTxnRequest-16 21.00 ± ∞ ¹ 28.00 ± ∞ ¹ ~ (p=1.000 n=1) ² 21.00 ± ∞ ¹ ~ (p=1.000 n=1) ³
geomean 13.22 19.63 +48.47% 15.22 +15.16%
¹ need >= 6 samples for confidence interval at level 0.95
² need >= 4 samples to detect a difference at alpha level 0.05
³ all samples are equal
```
Co-authored-by: Jordan Liggitt <liggitt@google.com>
Signed-off-by: Wei Fu <fuweid89@gmail.com>
Wire up the RangeStream handler end to end: the v3rpc layer streams
chunks out, the txn range path honors the pinned revision and
CountOnly semantics, and retry, mock, and the grpcproxy adapter learn
about the new method so clients and proxies route it correctly.
Integration tests cover the chunking behavior and header handling.
Signed-off-by: Jefftree <jeffrey.ying86@live.com>
Replace the groupcache LRU cache dependency with the equivalent
implementation from k8s.io/utils/lru. The APIs are compatible,
requiring only an import path change.
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
enable the linter and just tag each exception with a TODO so we
have identified the existing ones but we can gate to avoid adding
new deprecated functions.
Signed-off-by: Antonio Ojea <aojea@google.com>
Update source code files that were missing or had incorrect license
headers. For those that had the incorrect license, set the date to 2025.
Signed-off-by: Ivan Valdes <ivan@vald.es>
This patch modernizes the for-range-loop code to copy a map with
"maps.Clone" and "maps.Copy", also eliminates "copyFloats" with
"slices.Clone".
Also simplify "aggSort" and "sortMap" with slices and maps functions.
Signed-off-by: Jes Cok <xigua67damn@gmail.com>
Add two separate probes, one for liveness and one for readiness. The liveness probe would check that the local individual node is up and running, or else restart the node, while the readiness probe would check that the cluster is ready to serve traffic. This would make etcd health-check fully Kubernetes API complient.
Signed-off-by: Siyuan Zhang <sizhang@google.com>
Changed TraceKey/StartTimeKey/TokenFieldNameGRPCKey to struct{} to
follow the correct usage of context. Similar patch to #8901.
Signed-off-by: Wei Fu <fuweid89@gmail.com>
If start grpc proxy with --resolver-prefix, memberlist will return all alive proxy nodes, when one grpc proxy node is down, it is expected to not return the down node, but it is still return
Signed-off-by: yellowzf <zzhf3311@163.com>
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>