241 Commits

Author SHA1 Message Date
Wei Fu
2828a12ad6 *: keep tombstone if revision == compactAtRev
Before this patch, the tombstone can be deleted if its revision is equal
compacted revision. It causes that the watch subscriber won't get this
DELETE event. Based on Compact API[1], we should keep tombstone revision
if it's not less than the compaction revision.

> CompactionRequest compacts the key-value store up to a given revision.
> All superseded keys with a revision less than the compaction revision
> will be removed.

[1]: https://etcd.io/docs/latest/dev-guide/api_reference_v3/

Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit bbdc94181a6d67904b575ad936c20d1be10e220c)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-08-20 22:16:18 +08:00
Wei Fu
c88871f8a3 mvcc/*_test.go: should not use duplicate revision.Main for one key
Backport of #18321

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-08-17 12:22:32 +08:00
Wei Fu
4cb197e0fa mvcc: should update currentRev in revMu
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-04-24 11:16:19 +08:00
Wei Fu
41eb03a55e mvcc: update currentRev if scheduledCompact > currentRev
Signed-off-by: Wei Fu <fuweid89@gmail.com>
(cherry picked from commit 9ea234913a99670d18b66aa23915781f89713177)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-04-24 11:16:13 +08:00
Wei Fu
dcda47dc29 mvcc: introduce compactBeforeSetFinishedCompact failpoint
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-04-24 10:30:36 +08:00
Benjamin Wang
f8f186490b Update the compaction log when bootstrap and update compact's signature
Actually the compact() never return an error, so remove the second return
parameter.

Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-04-21 13:24:10 +01:00
Chao Chen
e2b29c4cf4 backport fix watch event loss after compaction #17555
Signed-off-by: Chao Chen <chaochn@amazon.com>
2024-03-18 17:38:56 -07:00
Siyuan Zhang
c65c1ea559 Add function to migrate 3.5 data online.
Signed-off-by: Siyuan Zhang <sizhang@google.com>
2024-02-20 08:55:55 -08:00
James Blair
e5bc8b00ae
mvcc: Printing etcd backend database related metrics inside scheduleCompaction function
Backporting commit 21bbc82 to etcd 3.4
To improve traceability of backend database usage, Added below parameter
related to backend database usage metrics inside scheduledCompaction
function.
current-db-size-bytes
current-db-size
current-db-size-in-use-bytes
current-db-size-in-use

Signed-off-by: James Blair <mail@jamesblair.net>
2024-02-16 21:08:20 +13:00
Benjamin Wang
6b774527c3 test: fix TestHashKVWhenCompacting: ensure all goroutine finished
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-01-25 13:33:22 +00:00
Siyuan Zhang
b70684b93d commit bbolt transaction if there is any pending deleting operations
Signed-off-by: Siyuan Zhang <sizhang@google.com>
2024-01-12 09:23:14 -08:00
Siyuan Zhang
c3af9427ed add tests to test tx delete consistency.
Signed-off-by: Siyuan Zhang <sizhang@google.com>
2024-01-12 09:22:55 -08:00
Siyuan Zhang
c43530c402 [3.4] backport health check e2e tests.
Signed-off-by: Siyuan Zhang <sizhang@google.com>
2023-12-21 09:33:11 -08:00
Wenjia Zhang
1130bf7f84 Adding optional revision bump and mark compacted to snapshot restore
Signed-off-by: Wenjia Zhang <wenjiazhang@google.com>
2023-07-06 23:08:38 -07:00
kkkkun
bce0d0b799 etcdserver: fix corruption check when server has just been compacted
Signed-off-by: kkkkun <scuzk373x@gmail.com>
2023-06-11 22:01:36 +08:00
Benjamin Wang
90e4d04c8e etcdserver: guarantee order of requested progress notification
Progress notifications requested using ProgressRequest were sent
directly using the ctrlStream, which means that they could race
against watch responses in the watchStream.

This would especially happen when the stream was not synced - e.g. if
you requested a progress notification on a freshly created unsynced
watcher, the notification would typically arrive indicating a revision
for which not all watch responses had been sent.

This changes the behaviour so that v3rpc always goes through the watch
stream, using a new RequestProgressAll function that closely matches
the behaviour of the v3rpc code - i.e.

1. Generate a message with WatchId -1, indicating the revision for
   *all* watchers in the stream

2. Guarantee that a response is (eventually) sent

The latter might require us to defer the response until all watchers
are synced, which is likely as it should be. Note that we do *not*
guarantee that the number of progress notifications matches the number
of requests, only that eventually at least one gets sent.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2023-04-11 12:47:09 +08:00
Marek Siarkowicz
29ecfc0185 server: Test watch restore
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2023-03-20 16:06:10 +01:00
Bogdan Kanivets
8160d9aea5 mvcc: update minRev when watcher stays synced
Problem: during restore in watchableStore.Restore, synced watchers are moved to unsynced.
minRev will be behind since it's not updated when watcher stays synced.

Solution: update minRev

fixes: https://github.com/etcd-io/etcd/issues/15271
Signed-off-by: Bogdan Kanivets <bkanivets@apple.com>
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2023-03-20 16:04:49 +01:00
James Blair
a91bacf567
Formatted source code for go 1.19.6.
Signed-off-by: James Blair <mail@jamesblair.net>
2023-02-20 12:44:14 +13:00
Wilson Wang
2f8158650f server: set multiple concurrentReadTx instances share one txReadBuffer.
(cherry picked from commit 9c82e8c72b96eec1e7667a0e139a07b944c33b75)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-30 11:43:19 +08:00
Wei Fu
931cf9a814 mvcc: update ut for Revisions/CountRevisions
It is kind of backport from etcd-io#14124.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-18 10:18:57 +08:00
Marek Siarkowicz
1246c52d04 etcdserver: Fix invalid count returned on Range with Limit
(cherry picked from commit 182aef6e6b28d2f62cd7281f38c12899d8006a15)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-18 10:02:10 +08:00
tangcong
d48f7ad7c1 mvcc: push down RangeOptions.limit argv into index tree
(cherry picked from commit 26c930f27d46776da5fedae69267ba0b69c31185)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-18 10:01:20 +08:00
Wei Fu
10c080dc5e mvcc: Add ut for Revisions/CountRevisions
It is kind of backport from #14124.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-16 15:15:34 +08:00
tangcong
00a005c300 mvcc: reduce count-only range overhead
(cherry picked from commit 730f3f1d783fc1159a4c2e258713e5b1fe3ec5b4)
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-01-13 16:32:35 +08:00
Benjamin Wang
5413ce46dc bump go version to 1.17.3
Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-12-19 18:34:04 +08:00
Cenk Alti
7a4a3ad8db
server: add more context to panic message
Signed-off-by: Cenk Alti <cenkalti@gmail.com>
2022-11-01 18:59:17 -04:00
Kafuu Chino
ed10ca13f4 *: avoid closing a watch with ID 0 incorrectly
Signed-off-by: Kafuu Chino <KafuuChinoQ@gmail.com>

add test

1

1

1
2022-10-10 19:54:58 +08:00
SimFG
04e5e5516e [3.4] clientv3/mvcc: fixed DATA RACE between mvcc.(*store).setupMetricsReporter and mvcc.(*store).restore
Signed-off-by: SimFG <1142838399@qq.com>
2022-07-26 21:38:23 +08:00
Benjamin Wang
1abf085cfb fix all the pipeline failues for release 3.4
Items resolved:
1. fix the vet error: possible misuse of reflect.SliceHeader;
2. fix the vet error: call to (*T).Fatal from a non-test goroutine;
3. bump package golang.org/x/crypto, net and sys;
4. bump boltdb from 1.3.3 to 1.3.6;
5. remove the vendor directory;
6. remove go 1.12.17 and 1.15.15, add go 1.16.15 into pipeline;
7. bump go version to 1.16 in go.mod;
8. fix the issue: compile: version go1.16.15 does not match go tool version go1.17.11,
   refer to https://github.com/actions/setup-go/issues/107;
9. fix data race on compactMainRev and watcherGauge;
10. fix test failure for TestLeasingTxnOwnerGet in cluster_proxy mode.

Signed-off-by: Benjamin Wang <wachao@vmware.com>
2022-06-22 05:28:45 +08:00
Bogdan Kanivets
d30a4fbf0c mvcc/backend: restore original bolt db options after defrag
Problem: Defrag was implemented before custom bolt options were added.
Currently defrag doesn't restore backend options.
For example BackendFreelistType will be unset after defrag.

Solution: save bolt db options and use them in defrag.
2022-02-17 15:33:05 -08:00
Geeta Gharpure
85abf6e46d storage/backend: Add a gauge to indicate if defrag is active (backport from 3.6) 2021-10-06 11:04:47 -07:00
makdon
963d3b9369 etcdserver/mvcc: update trace.Step condition
backport PR #12894 to release-3.4
2021-04-28 11:35:49 +08:00
cfc4n
7b99863e02 mvcc: chanLen 1024 is to biger,and it used more memory. 128 seems to be enough. Sometimes the consumption speed is more than the production speed.
See https://github.com/etcd-io/etcd/issues/11906 for more detail.
2020-06-25 19:53:13 +08:00
David Crawshaw
78f67988aa
etcdserver, et al: add --unsafe-no-fsync flag
This makes it possible to run an etcd node for testing and development
without placing lots of load on the file system.

Fixes #11930.

Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
2020-06-04 20:19:28 -07:00
tangcong
aa75e90ac8 mvcc: fix deadlock bug 2020-05-08 09:56:23 +08:00
tangcong
347c8dac3b *: fix auth revision corruption bug 2020-04-09 09:33:36 +08:00
shenjiangc
89b10cf967 mvcc/kvstore:when the number key-value is greater than one million, compact take too long and blocks other requests 2020-03-30 08:21:38 -07:00
jingyih
94673a6ba4 mvcc/backend: check for nil boltOpenOptions
Check if boltOpenOptions is nil before use it.
2020-02-15 00:18:26 -08:00
Joe Betz
6d646c442a
mvcc/backend: Delete orphaned db.tmp files before defrag 2020-02-13 12:26:54 -08:00
宇慕
8c10973820 mvcc/kvstore:fixcompactbug 2019-11-27 13:07:47 -08:00
yoyinzyc
f4669c3b62 mvcc: update to "etcd_debugging_mvcc_total_put_size_in_bytes" 2019-11-26 14:03:07 -08:00
yoyinzyc
55c3476abc mvcc: add "etcd_mvcc_put_size_in_bytes" to monitor the throughput of put request. 2019-11-26 14:03:07 -08:00
yoyinzyc
480d5510f9 etcdserver: trace compaction request; add return parameter 'trace' to applierV3.Compaction() mvcc: trace compaction request; add input parameter 'trace' to KV.Compact() 2019-10-09 12:40:12 -07:00
yoyinzyc
daa432cfa7 etcdserver: add put request steps. mvcc: add put request steps; add trace to KV.Write() as input parameter. 2019-10-09 12:40:12 -07:00
yoyinzyc
8717327697 pkg: use zap logger to format the structure log output. 2019-10-09 12:40:12 -07:00
yoyinzyc
4f1bbff888 pkg: add field to record additional detail of trace; add stepThreshold to reduce log volume. 2019-10-09 12:40:12 -07:00
yoyinzyc
28bb8037d9 pkg: create package traceutil for tracing. mvcc: add tracing steps:range from the in-memory index tree; range from boltdb. etcdserver: add tracing steps: agreement among raft nodes before linerized reading; authentication; filter and sort kv pairs; assemble the response. 2019-10-09 12:40:12 -07:00
Jingyi Hu
ccbbb2f8d6 mvcc: add store revision metrics
Add experimental metrics etcd_debugging_mvcc_current_revision and
etcd_debugging_mvcc_compact_revision.
2019-09-06 17:03:21 -07:00
Gyuho Lee
0161e72d8d mvcc: keep 64-bit alignment in "store" struct
Signed-off-by: Gyuho Lee <leegyuho@amazon.com>
2019-08-15 13:31:52 -07:00