113 Commits

Author SHA1 Message Date
Marek Siarkowicz
7c8f7166e7 server: Move bootstraping backend from snapshot to bootstrapBackend 2021-09-20 12:17:33 +02:00
Marek Siarkowicz
c97ab8f5e0 server: Move cluster up the bootstrap hierarchy 2021-09-20 12:07:41 +02:00
Marek Siarkowicz
6a4ea70aef server: Move clusterID and nodeID up the bootstrap hierarchy 2021-09-20 12:06:18 +02:00
Marek Siarkowicz
db06a4ab28 server: Move wal bootstrap up the hierarchy 2021-09-20 12:04:44 +02:00
Marek Siarkowicz
aa0c050003 etcdserver: Add more hierarchy bootstap introducing a separate storage bootstrap step 2021-09-20 12:01:45 +02:00
Marek Siarkowicz
66d05e5496 Try updating storage version immidietly after cluster version is set 2021-09-10 10:16:48 +02:00
Marek Siarkowicz
ff3729c4d5 server: Implement storage schema migration to follow cluster version change and panic if unknown storage version is found
Storage version should follow cluster version. During upgrades this
should be immidiate as storage version can be always upgraded as storage
is backward compatible. During downgrades it will be delayed and will
require time for incompatible changes to be snapshotted.

As storage version change can happen long after cluster is running, we
need to add a step during bootstrap to validate if loaded data can be
understood by migrator.
2021-09-10 10:16:48 +02:00
Marek Siarkowicz
9d81dde082 server: Extract notifier struct 2021-09-10 10:16:48 +02:00
Eduardo Patrocinio
87f1dc7e40 Fix a few typos 2021-09-03 16:09:09 -04:00
Marek Siarkowicz
83a325ac46 server: Move all functions needed for storage bootstrap to storage package
This is prerequestite to move storage bootstrap, splitted to separate PR
to make it easier to review.
2021-08-03 13:09:15 +02:00
Marek Siarkowicz
a0554a6bd3 etcdserver: Create AuthBackend interface 2021-07-20 18:09:53 +02:00
Marek Siarkowicz
6cd3633543 etcdserver: Rename membershipStore to membershipBackend 2021-07-20 17:56:52 +02:00
Marek Siarkowicz
2f31cc3fbc etcdserver: Create AlarmBackend interface 2021-07-20 17:53:44 +02:00
Marek Siarkowicz
f6534f1e92 server: Move setting storage version to schema 2021-07-12 15:37:21 +02:00
Marek Siarkowicz
5b6f4579fb server: Rename buckets to schema 2021-07-12 15:37:21 +02:00
Marek Siarkowicz
5e40a8b00c server: Create storage package and move mvcc files to it 2021-07-12 15:37:21 +02:00
Marek Siarkowicz
ef6c276fae etcdserver: Move server bootstraping to one file 2021-07-12 15:37:21 +02:00
Marek Siarkowicz
9824cc96ed etcdserver: Fix typos in bootstrap 2021-07-08 13:37:19 +02:00
Marek Siarkowicz
a72d4462fe etcdserver: Create boostrap wal functions 2021-07-07 23:36:35 +02:00
Marek Siarkowicz
e75dfde4cb etcdserver: Move raft node start to just before newRaftNode 2021-07-07 23:26:37 +02:00
Marek Siarkowicz
08935247a8 etcdserver: Create raftnode based on boostrapRaft struct 2021-07-07 17:38:56 +02:00
Marek Siarkowicz
554777bba4 etcdserver: Extract boostrapRaft struct 2021-07-07 17:30:27 +02:00
Marek Siarkowicz
7d39c3c655 etcdserver: Extract boostrapSnapshotter function 2021-07-07 16:14:33 +02:00
Marek Siarkowicz
af0439490c etcdserver: Extract cluster boostrap functions 2021-07-07 16:04:52 +02:00
Marek Siarkowicz
16b2a8b420 etcdserver: Prepare boostrap to split cluster setup 2021-07-07 15:56:43 +02:00
Marek Siarkowicz
4dd9424d11 etcdserver: Extract boostrapBackend function 2021-07-07 15:46:38 +02:00
Marek Siarkowicz
120cd5abe2 etcdserver: Extract etcdserver boostrap function 2021-07-07 15:40:54 +02:00
Marek Siarkowicz
2db193fda1 etcdserver: Fix snapshot always nil 2021-07-07 13:29:45 +02:00
Marek Siarkowicz
bf3e7033e9 etcdserver: Move Read/Update methods on Meta bucket to one place
There are still some left like compact keys, but they will require more
work to avoid circular dependency.
2021-07-05 13:23:53 +02:00
Marek Siarkowicz
50507d5f3c etcdserver: Membership uses MembershipStorage interface instead of directly accessing Backend 2021-06-29 16:14:06 +02:00
Marek Siarkowicz
e2740b4afa server,etcdutl: Preserve etcd version in backend allowing etcdutl to read it from snapshot 2021-06-25 14:06:56 +02:00
Marek Siarkowicz
823f85dfc9 etcdserver: Move version monitor logic to separate module 2021-06-23 19:27:29 +02:00
AlexStocks
184b0e5d49 add sleep interval 2021-05-24 16:22:00 +08:00
Piotr Tabor
0a972a3f05 applyV2 should reapply on backend only once
During review of:  https://github.com/etcd-io/etcd/pull/12988 spotted
that PUT is actially writing to v3-backend.
If we are replaying WAL log, it might happened that backend's
applied_index is > than the WAL's log entry. In such situation we should
skip applying on backend V3.
I think both the methods (setVersion, setMembersAttributes) are in
practice idempotent so its not that 'serious' problem, but for
formal correctness adding the proper checks.
2021-05-18 20:55:05 +02:00
Chao Chen
783c5ad2d2 use v2 api to update cluster version 2021-05-17 11:45:54 -07:00
Piotr Tabor
ab586cd463 Persists Term in the (bbolt) Backend.
Additional layer of protection, that allows to validate whether we
start replaying log not only from the proper 'index', but also of the
right 'term'.
2021-05-13 21:29:01 +02:00
Piotr Tabor
865df75714 Save raftpb.ConfState in the backend.
This makes (bbolt) backend a full feature snapshot in term of WAL/raft,
i.e. carries:
  - commit : (applied_index)
  - confState

Benefits:
  - Backend will be a sufficient point in time definition sufficient to
start replaying WAL. We have applied_index & confState in consistent
state.
  - In case of emergency a backend state can be used for recovery
2021-05-13 14:29:36 +02:00
Piotr Tabor
ead81df948 Disallow -v2-deprecation>'not-yet' combined with --enable-v2 2021-05-12 18:09:34 +02:00
Marek Siarkowicz
efc8505739 etcdserver: Implement running defrag if freeable space will exceed privided threshold 2021-05-11 14:00:29 +02:00
Piotr Tabor
2fb6f0a74b Simplify lease management after cindex update is moved to 'hooks'. 2021-05-04 18:21:23 +02:00
Piotr Tabor
2dbecea5b2 Simplify KVStore interaction with cindex thanks to hooks. 2021-05-04 18:21:23 +02:00
Piotr Tabor
fe3254aee3 Remove explicit authStore->ConsistencyIndex updates, as they are taken care by hook. 2021-05-04 15:38:23 +02:00
Piotr Tabor
50051675f9 Integrate backend::hooks with consistent_index.
Every transaction committed to backend is writing most recent consistent_index.
Makes sure that even automatically trigger commits of batch-transactions
stays "really" consistent a.d. the most recent WAL log index applied.
2021-05-04 15:38:23 +02:00
Piotr Tabor
cedbea6c81
Merge pull request #12904 from wpedrak/limit_mlocked_memory
server: replace mlockall with `Mlock` in `--experimental-memory-mlock`
2021-04-29 18:21:24 +02:00
wpedrak
927b3a3152 server: replace mlockall with Mlock in --experimental-memory-mlock
Implementation of `--experimental-memory-mlock` backed by `mlockall` syscall is replaced by `Mlock` flag (backed by mlock syscall) of bboltDB.
2021-04-29 12:08:20 +02:00
Piotr Tabor
f53b70facb Embed: In case KVStoreHash verification fails, close the backend.
In case of failed verification, the server used to keep opened backend
(so the file was locked on OS level).
2021-04-29 11:51:25 +02:00
Piotr Tabor
911204cd76 Fix ETCDCTL_API=2 etcdctl backup --with-v3 consistent index consistency
Prior to this CL, `ETCDCTL_API=2 etcdctl backup --with-v3` was readacting WAL log
(by removal of some entries), but was NOT updating consistent_index in the backend.
Also the WAL editing logic was buggy, as it didn't took in consideration the fact
that when TERM changes, there can be entries with duplicated indexes in
the log. So its NOT sufficient to subtract number of removed entries to
get accurate log indexes.

The PR replaces removing and shifting of WAL entries with replacing them with an no-op entries.
Thanks to this consistent-index references are staying up to date.

The PR also:
  - updates 'verification' logic to check whether consistent_index does not lag befor last snapshot
  - env-gated execution of verification framework in `etcdctl backup`.

Tested with:
```
(./build.sh && cd tests && EXPECT_DEBUG=TRUE 'env' 'go' 'test' '-timeout=300m' 'go.etcd.io/etcd/tests/v3/e2e' -run=TestCtlV2Backup --count=1000 2>&1 | tee TestCtlV2BackupV3.log)
```
2021-04-29 11:51:24 +02:00
Piotr Tabor
ea287dd9f8
Merge pull request #12854 from ptabor/20210410-shouldApplyV3
(no)StoreV2 (Part 3): Applying consistency fix: ClusterVersionSet (and co) might get not applied on v2store
2021-04-21 09:31:38 +02:00
Piotr Tabor
06ba0fc5a2
Merge pull request #12846 from pyiyun/fix-snaptmpfile-bug
etcdserver: remove temp files in snap dir when etcdserver starting
2021-04-17 12:58:46 +02:00
pyiyun
28a490b09c etcdserver: remove temp files in snap dir when etcdServer starting
When etcd exits abnormally, tmp files will remain in snap dir, so clean up tmp files in snap dir when etcdserver starting.

Fixes #12837
2021-04-16 20:30:04 +08:00