Skip to content

Commit

Permalink
fix panic due incorrect usage of plan.PreparedPlanCacheEnabled (pingc…
Browse files Browse the repository at this point in the history
  • Loading branch information
holys authored and huachaohuang committed Apr 25, 2018
1 parent 221e7d9 commit aff81ad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/pingcap/tidb-lightning/lightning"
"github.com/pingcap/tidb-lightning/lightning/config"
"github.com/pingcap/tidb/plan"
)

func onExitSignal() {
Expand All @@ -28,7 +29,15 @@ func onExitSignal() {
log.Infof("Got signal %d to exit.", sig)
}

func setGlobalVars() {
// hardcode it
plan.PreparedPlanCacheEnabled = true
plan.PreparedPlanCacheCapacity = 10
}

func main() {
setGlobalVars()

cfg, err := config.LoadConfig(os.Args[1:])
switch errors.Cause(err) {
case nil:
Expand Down
9 changes: 0 additions & 9 deletions lightning/kv/sql2kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"github.com/juju/errors"
sqltool "github.com/pingcap/tidb-lightning/lightning/sql"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/plan"
kvec "github.com/pingcap/tidb/util/kvencoder"
log "github.com/sirupsen/logrus"
)
Expand All @@ -17,12 +16,6 @@ var (
PrepareStmtMode = false
)

func setGlobalVars() {
// hardcode it
plan.PreparedPlanCacheEnabled = true
plan.PreparedPlanCacheCapacity = 10
}

func InitMembufCap(batchSQLLength int64) {
kv.ImportingTxnMembufCap = int(batchSQLLength) * 4
// TODO : calculate predicted ratio, bwtween sql and kvs' size, base on specified DDL
Expand Down Expand Up @@ -60,8 +53,6 @@ func NewTableKVEncoder(
}
log.Debugf("set sql_mode=%s", sqlMode)

setGlobalVars()

kvcodec := &TableKVEncoder{
db: db,
table: table,
Expand Down

0 comments on commit aff81ad

Please sign in to comment.