Skip to content

Commit

Permalink
Merge pull request #19081 from ahrtr/log_migrage_20241218
Browse files Browse the repository at this point in the history
Add more info in the error message in downgrade detection
  • Loading branch information
ahrtr authored Dec 19, 2024
2 parents e4d1da7 + 2830237 commit 9db12c6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion server/storage/schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ func UnsafeMigrate(lg *zap.Logger, tx backend.UnsafeReadWriter, w WALVersion, ta
if target.LessThan(current) {
minVersion := w.MinimalEtcdVersion()
if minVersion != nil && target.LessThan(*minVersion) {
return fmt.Errorf("cannot downgrade storage, WAL contains newer entries")
// Occasionally we may see this error during downgrade test due to ClusterVersionSet,
// which is harmless. Please read https://github.com/etcd-io/etcd/pull/13405#discussion_r1890378185.
return fmt.Errorf("cannot downgrade storage, WAL contains newer entries, as the target version (%s) is lower than the version (%s) detected from WAL logs",
target.String(), minVersion.String())
}
}
return plan.unsafeExecute(lg, tx)
Expand Down
3 changes: 2 additions & 1 deletion server/storage/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package schema

import (
"strings"
"testing"
"time"

Expand Down Expand Up @@ -218,7 +219,7 @@ func TestMigrate(t *testing.T) {
if (err != nil) != tc.expectError {
t.Errorf("Migrate(lg, tx, %q) = %+v, expected error: %v", tc.targetVersion, err, tc.expectError)
}
if err != nil && err.Error() != tc.expectErrorMsg {
if err != nil && !strings.Contains(err.Error(), tc.expectErrorMsg) {
t.Errorf("Migrate(lg, tx, %q) = %q, expected error message: %q", tc.targetVersion, err, tc.expectErrorMsg)
}
v := UnsafeReadStorageVersion(b.BatchTx())
Expand Down

0 comments on commit 9db12c6

Please sign in to comment.