Skip to content

Commit 2c3965e

Browse files
committed
Remove checking confState during schema migration
The field confState was added since etcd v3.5. If an etcd cluster was created since v3.4, then it wouldn't have this field. In 3.5+, the field will only be automatically populated during conf change (i.e. add/remove/update member). So when upgrading from 3.4 to 3.5, and from 3.5 to 3.6, the field will never be populated unless users add or remove or update members. Note if you can't reproduce this issue, it should be because that there is no v2 snapshot, and etcdserver will replay all WAL records (including add member records) on bootstrap. Signed-off-by: Benjamin Wang <[email protected]>
1 parent 05b8563 commit 2c3965e

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

server/storage/schema/schema.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,11 @@ func UnsafeDetectSchemaVersion(lg *zap.Logger, tx backend.UnsafeReader) (v semve
9595
return *vp, nil
9696
}
9797

98-
// TODO: remove the operations of reading the fields `confState`
99-
// and `term` in 3.7. We only need to be back-compatible
100-
// with 3.6 when we are running 3.7, and the `storageVersion`
101-
// already exists in all versions >= 3.6, so we don't need to
102-
// use any other fields to identify the etcd's storage version.
103-
confstate := UnsafeConfStateFromBackend(lg, tx)
104-
if confstate == nil {
105-
return v, fmt.Errorf("missing confstate information")
106-
}
98+
// TODO: remove the operations of reading the field `term`
99+
// in 3.7. We only need to be back-compatible with 3.6 when
100+
// we are running 3.7, and the `storageVersion` already exists
101+
// in all versions >= 3.6, so we don't need to use any other
102+
// fields to identify the etcd's storage version.
107103
_, term := UnsafeReadConsistentIndex(tx)
108104
if term == 0 {
109105
return v, fmt.Errorf("missing term information")

server/storage/schema/schema_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,7 @@ func TestMigrate(t *testing.T) {
115115
expectErrorMsg string
116116
}{
117117
// As storage version field was added in v3.6, for v3.5 we will not set it.
118-
// For storage to be considered v3.5 it have both confstate and term key set.
119-
{
120-
name: `Upgrading v3.5 to v3.6 should be rejected if confstate is not set`,
121-
version: version.V3_5,
122-
overrideKeys: func(tx backend.UnsafeReadWriter) {},
123-
targetVersion: version.V3_6,
124-
expectVersion: nil,
125-
expectError: true,
126-
expectErrorMsg: `cannot detect storage schema version: missing confstate information`,
127-
},
118+
// For storage to be considered v3.5 it has term key set.
128119
{
129120
name: `Upgrading v3.5 to v3.6 should be rejected if term is not set`,
130121
version: version.V3_5,

0 commit comments

Comments
 (0)