Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

Commit

Permalink
restore, kv: detect if SwitchMode exists instead of check version
Browse files Browse the repository at this point in the history
TiKV and PD's versions are exposed before 2.1, so we can't rely on their
APIs to verify for 2.0.4+. Since the only reason we need 2.0.4+ is the
SwitchMode gRPC interface, we instead inspect if SwitchMode is
unimplemented and display a user-friendly message on stderr.
  • Loading branch information
kennytm committed Sep 5, 2018
1 parent c06d8f8 commit 25cfd1a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lightning/kv/kv-deliver.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package kv

import (
"fmt"
"math"
"os"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -639,6 +642,9 @@ func (c *KVDeliverClient) Switch(mode sstpb.SwitchMode) error {
}
_, err := c.cli.SwitchMode(c.ctx, req)
if err != nil {
if strings.Contains(err.Error(), "status: Unimplemented") {
fmt.Fprintln(os.Stderr, "Error: The TiKV instance does not support mode switching. Please make sure the TiKV version is 2.0.4 or above.")
}
return errors.Trace(err)
}
common.AppLogger.Infof("switch to tikv %s mode takes %v", mode, time.Since(timer))
Expand Down
7 changes: 5 additions & 2 deletions lightning/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,14 @@ func (rc *RestoreController) checkRequirements(_ context.Context) error {
if err := rc.checkTiDBVersion(client); err != nil {
return errors.Trace(err)
}
// TODO: Reenable the PD/TiKV version check after we upgrade the dependency to 2.1.
if err := rc.checkPDVersion(client); err != nil {
return errors.Trace(err)
// return errors.Trace(err)
common.AppLog.Infof("PD version check failed: %v", err)
}
if err := rc.checkTiKVVersion(client); err != nil {
return errors.Trace(err)
// return errors.Trace(err)
common.AppLog.Infof("TiKV version check failed: %v", err)
}

return nil
Expand Down

0 comments on commit 25cfd1a

Please sign in to comment.