Commit Graph

135 Commits

Author SHA1 Message Date
Benjamin Wang
de10fd6565 Fix a peformance regression due to uncertain compaction sleep interval
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2025-02-13 09:40:04 +00:00
Benjamin Wang
a747fdebbc
Merge pull request #19344 from jxustc/fix/etcdutl-key-count
etcdutl: use map to count unique user keys in snapshot status
2025-02-07 15:15:18 +00:00
Xiang Ji
2d377000ff etcdutl: use map to count unique user keys in snapshot status
The new implementation:
- Uses map to track unique keys for accurate counting
- Excludes internal built-in keys from total count
- Improves code maintainability

Although this approach uses additional memory for the map, the trade-off
is acceptable since:
- Status() is not in hot path
- Correctness takes priority over performance optimization
- Simpler code is easier to maintain

Fixes #19253

Signed-off-by: Xiang Ji <johnsmith.jix@gmail.com>
2025-02-07 19:56:06 +08:00
adeyemi
db05deaf02 server: fix unexported-return using interfaces
Signed-off-by: adeyemi <adeyemi.aladesawe@gmail.com>
2025-02-06 15:21:20 -08:00
Benjamin Wang
614640f1c2 format all prometheus metrics to ensure nice indent
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2025-01-29 13:42:14 +00:00
Benjamin Wang
83cf7bb4fc
Merge pull request #19188 from fuweid/fix-19179
mvcc: restore tombstone index if it's first revision
2025-01-20 09:18:24 +00:00
Wei Fu
d8b4192574 mvcc: restore tombstone index if it's first revision
The tombstone could be the only one available revision in database.
It happens when all historical revisions have been deleted in previous
compactions. Since tombstone revision is still in database, we should
restore it as valid key index. Otherwise, we lost that event.

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2025-01-19 18:12:25 -05:00
Matthieu MOREL
10d7cea552 chore: enable early-return and superfluous-else from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Iván Valdés Castillo <iv@nvald.es>
2025-01-18 09:44:58 +01:00
Matthieu MOREL
647f1621d6 fix: enable gosimple linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-12-03 07:32:22 +01:00
Marek Siarkowicz
348c0cb2be Reuse events between sync loops
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-02 18:07:25 +01:00
Marek Siarkowicz
1f4439c2eb Extract rangeEvents function
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-02 18:06:59 +01:00
Marek Siarkowicz
3741000161 Use number of revisions instead of batches to configure TestWatchBatchUnsynced
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Marek Siarkowicz
2a415cc62b Add scenario for 1 events per revison TestWatchBatchUnsynced
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Marek Siarkowicz
e88802ac2a Use table tests for TestWatchBatchUnsynced
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Marek Siarkowicz
1e655bf039 Make batching in TestWatchBatchUnsynced explicit
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Marek Siarkowicz
8c5e42d41b Use assert in TestWatchBatchUnsynced
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Marek Siarkowicz
06a5cd6eb3 Simplify TestSyncWatchers to make recepie for more tests
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Marek Siarkowicz
52ea2f83c5 Use constructor in tests
Signed-off-by: Marek Siarkowicz <siarkowicz@google.com>
2024-12-01 21:02:48 +01:00
Matthieu MOREL
69efe31ea0 fix: enable gofumpt instead of gofmt linter in server
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-11-27 07:22:36 +01:00
Benjamin Wang
6883308899
Merge pull request #18800 from mmorel-35/testifylint/require-error
fix: enable require-error rule from testifylint in client, pkg and server packages
2024-10-30 23:03:01 +00:00
Matthieu MOREL
3a3115122e fix: enable require-error rule from testifylint in client, pkg and server packages
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-28 21:02:58 +01:00
Matthieu MOREL
3abdf612b3 fix: enable errorlint in server directory
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-26 08:16:47 +02:00
Thomas Gosteli
ff4a8df3aa fix: enable formatter rule from testifylint
Signed-off-by: Thomas Gosteli <thomas.gosteli@protonmail.ch>
2024-10-17 14:10:35 +02:00
Matthieu MOREL
33d7f2d53e fix: enable gofmt and whitespace linters
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-11 07:03:18 +02:00
Matthieu MOREL
e06fb81713 fix: enable empty and len rules from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-10 11:07:21 +00:00
Matthieu MOREL
b23947b604 fix: enable bool-compare rule from testifylint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2024-10-06 09:47:02 +02:00
redwrasse
0739142ee3 server: errors.Is conversions
Signed-off-by: redwrasse <mail@redwrasse.io>
2024-09-29 05:23:47 -07:00
Jalin Wang
2c53be7c5d
etcdserver: rename defaultCompactionSleepInterval var (#18495)
* etcdserver: rename `minimumBatchInterval`  to `defaultCompactionSleepInterval` and `defaultCompactBatchLimit` to `defaultCompactionBatchLimit`

Signed-off-by: Jalin Wang <JalinWang@outlook.com>
2024-08-27 14:36:06 +01:00
Wei Fu
bbdc94181a *: 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>
2024-08-07 21:56:20 +08:00
Wei Fu
5e178e2288 mvcc/*_test.go: should not use duplicate revision.Main for one key
In commit [[1]], the newTestKeyIndex function creates one key with two
Revision{Main: 14} revisions. However, starting from version [[2]], etcd server
does not allow duplicate keys in a single transaction. This update to
newTestKeyIndex is to avoid confusion and ensure consistency with the
latest etcd server behavior.

REF:

[1]: be80d11948
[2]: https://github.com/etcd-io/etcd/pull/4376

Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-07-14 17:30:47 +08:00
Chun-Hung Tseng
5be397a6a8
Fix a linter issue
golangci-lint reports the following issue:
storage/mvcc/kvstore.go:312:27: (*store).restore - result 0 (error) is always nil (unparam)

It's due to the fact that both Attach() and compactLockfree() within the
function restore() are able to return an error, but we only log them in
the current implementation. Thus, the return value restore() is always
nil, hence the linter warning.

We have agreed to suppress the linter warning for now [1].

Reference:
[1] https://github.com/etcd-io/etcd/pull/18228#issuecomment-2187309957

Signed-off-by: Chun-Hung Tseng <henrybear327@gmail.com>
2024-06-25 11:45:53 +02:00
MR_G
c0076a788e mvcc: fix typo
Signed-off-by: MR_G <2044783677@qq.com>
2024-06-22 00:17:13 +08:00
Cenk Alti
ea46253b42
Improve snapshot status
Signed-off-by: Cenk Alti <cenkalti@gmail.com>
2024-06-15 10:11:34 -04:00
lubronzhan
0b6529c462 mvcc: fix typo
Signed-off-by: lubronzhan <lubronzhan@gmail.com>
2024-06-13 00:15:37 -07:00
Cenk Alti
b107d2437f
cli: Add etcdutl snapshot hashkv command
Signed-off-by: Cenk Alti <cenkalti@gmail.com>

Apply suggestions from code review

Co-authored-by: Benjamin Wang <benjamin.wang@broadcom.com>
2024-06-02 00:07:50 -04:00
Wei Fu
94c83a962b server/storage/mvcc: should update currentRev in revMu
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-04-24 11:08:33 +08:00
Benjamin Wang
dd4e35a585
Merge pull request #17815 from fuweid/repro-17780
[RFC] fix revision loss issue caused by compaction - 17780
2024-04-22 18:15:44 +01:00
Benjamin Wang
29529c505b
Merge pull request #17791 from ahrtr/verify_revision_bootstrap_20240415
Add verification that the revision shouldn't decrease on bootstrap
2024-04-22 10:43:01 +01:00
Wei Fu
9ea234913a server/storage: update currentRev if scheduledCompact > currentRev
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2024-04-21 18:12:38 +08:00
Benjamin Wang
a54098dee3 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-15 14:16:18 +01:00
Benjamin Wang
9ac964d1cc Add verification that the revision shouldn't decrease on bootstrap
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-04-15 13:56:19 +01:00
Chao Chen
405862e807 Fix event loss after compaction
Signed-off-by: Chao Chen <chaochn@amazon.com>
2024-03-15 14:22:37 -07:00
Abhishek Kr Srivastav
fe113026fa Increased timeout to fix HashKV test
Signed-off-by: Abhishek Kr Srivastav <Abhishek.kr.srivastav@ibm.com>
2024-02-23 15:58:57 +05:30
Benjamin Wang
c647614b6a test: fix TestHashKVWhenCompacting: ensure all goroutine finished
Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-01-25 13:30:27 +00:00
Benjamin Wang
82562abc3c Fix test issue in TestScheduleCompaction
It always reuse the same memory space. Each next iteration
will always overwrite previous data

Signed-off-by: Benjamin Wang <benjamin.ahrtr@gmail.com>
2024-01-19 15:29:51 +00:00
Rahul More
21bbc82710 mvcc: Printing etcd backend database related metrics inside
scheduleCompaction function

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: Rahul More <rahulbapumore@gmail.com>
2024-01-15 17:36:38 +05:30
Allen Ray
395376d3ab Refactor common revision code to pkg
Signed-off-by: Allen Ray <alray@redhat.com>
2023-10-09 14:53:16 -04:00
Wei Fu
aa97484166 *: enable goimports in verify-lint
Signed-off-by: Wei Fu <fuweid89@gmail.com>
2023-09-21 21:14:09 +08:00
chenyahui
c0aa3b613b Use any instead of interface{}
Signed-off-by: chenyahui <cyhone@qq.com>
2023-09-17 17:41:58 +08:00
redwrasse
b79cbcc3db mvcc: cleanup comment in HashStorage.Store
Signed-off-by: redwrasse <mail@redwrasse.io>
2023-09-11 21:54:42 -07:00