error: replace usages of terror.Log (#322)

Signed-off-by: disksing <i@disksing.com>
This commit is contained in:
disksing 2021-10-11 14:08:21 +08:00 committed by GitHub
parent 128ccbde43
commit 97fac134af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 16 deletions

View File

@ -41,6 +41,7 @@ import (
"github.com/pingcap/errors" "github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/kvproto/pkg/pdpb" "github.com/pingcap/kvproto/pkg/pdpb"
"github.com/pingcap/log"
"github.com/pingcap/parser/terror" "github.com/pingcap/parser/terror"
"github.com/tikv/client-go/v2/internal/logutil" "github.com/tikv/client-go/v2/internal/logutil"
"github.com/tikv/client-go/v2/util" "github.com/tikv/client-go/v2/util"
@ -267,3 +268,10 @@ func ExtractKeyErr(keyErr *kvrpcpb.KeyError) error {
func IsErrorUndetermined(err error) bool { func IsErrorUndetermined(err error) bool {
return terror.ErrorEqual(err, terror.ErrResultUndetermined) return terror.ErrorEqual(err, terror.ErrResultUndetermined)
} }
// Log logs the error if it is not nil.
func Log(err error) {
if err != nil {
log.Error("encountered error", zap.Error(err), zap.Stack("stack"))
}
}

View File

@ -53,9 +53,9 @@ import (
"github.com/pingcap/kvproto/pkg/debugpb" "github.com/pingcap/kvproto/pkg/debugpb"
"github.com/pingcap/kvproto/pkg/mpp" "github.com/pingcap/kvproto/pkg/mpp"
"github.com/pingcap/kvproto/pkg/tikvpb" "github.com/pingcap/kvproto/pkg/tikvpb"
"github.com/pingcap/parser/terror"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/tikv/client-go/v2/config" "github.com/tikv/client-go/v2/config"
tikverr "github.com/tikv/client-go/v2/error"
"github.com/tikv/client-go/v2/internal/logutil" "github.com/tikv/client-go/v2/internal/logutil"
"github.com/tikv/client-go/v2/metrics" "github.com/tikv/client-go/v2/metrics"
"github.com/tikv/client-go/v2/tikvrpc" "github.com/tikv/client-go/v2/tikvrpc"
@ -237,7 +237,7 @@ func (a *connArray) Close() {
for i, c := range a.v { for i, c := range a.v {
if c != nil { if c != nil {
err := c.Close() err := c.Close()
terror.Log(errors.Trace(err)) tikverr.Log(errors.Trace(err))
a.v[i] = nil a.v[i] = nil
} }
} }

View File

@ -45,9 +45,9 @@ import (
"github.com/pingcap/errors" "github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/tikvpb" "github.com/pingcap/kvproto/pkg/tikvpb"
"github.com/pingcap/parser/terror"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/tikv/client-go/v2/config" "github.com/tikv/client-go/v2/config"
tikverr "github.com/tikv/client-go/v2/error"
"github.com/tikv/client-go/v2/internal/logutil" "github.com/tikv/client-go/v2/internal/logutil"
"github.com/tikv/client-go/v2/internal/retry" "github.com/tikv/client-go/v2/internal/retry"
"github.com/tikv/client-go/v2/metrics" "github.com/tikv/client-go/v2/metrics"
@ -702,7 +702,7 @@ func (c *batchCommandsClient) recreateStreamingClient(err error, streamClient *b
err2 := b.Backoff(retry.BoTiKVRPC, err1) err2 := b.Backoff(retry.BoTiKVRPC, err1)
// As timeout is set to math.MaxUint32, err2 should always be nil. // As timeout is set to math.MaxUint32, err2 should always be nil.
// This line is added to make the 'make errcheck' pass. // This line is added to make the 'make errcheck' pass.
terror.Log(err2) tikverr.Log(err2)
} }
return false return false
} }

View File

@ -50,8 +50,8 @@ import (
"github.com/opentracing/opentracing-go" "github.com/opentracing/opentracing-go"
"github.com/pingcap/errors" "github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/metapb" "github.com/pingcap/kvproto/pkg/metapb"
"github.com/pingcap/parser/terror"
"github.com/tikv/client-go/v2/config" "github.com/tikv/client-go/v2/config"
tikverr "github.com/tikv/client-go/v2/error"
"github.com/tikv/client-go/v2/internal/client" "github.com/tikv/client-go/v2/internal/client"
"github.com/tikv/client-go/v2/internal/logutil" "github.com/tikv/client-go/v2/internal/logutil"
"github.com/tikv/client-go/v2/internal/retry" "github.com/tikv/client-go/v2/internal/retry"
@ -435,7 +435,7 @@ func (c *RegionCache) checkAndResolve(needCheckStores []*Store, needCheck func(*
for _, store := range needCheckStores { for _, store := range needCheckStores {
_, err := store.reResolve(c) _, err := store.reResolve(c)
terror.Log(err) tikverr.Log(err)
} }
} }
@ -671,7 +671,7 @@ func (c *RegionCache) GetTiFlashRPCContext(bo *retry.Backoffer, id RegionVerID,
} }
if store.getResolveState() == needCheck { if store.getResolveState() == needCheck {
_, err := store.reResolve(c) _, err := store.reResolve(c)
terror.Log(err) tikverr.Log(err)
} }
atomic.StoreInt32(&regionStore.workTiFlashIdx, int32(accessIdx)) atomic.StoreInt32(&regionStore.workTiFlashIdx, int32(accessIdx))
peer := cachedRegion.meta.Peers[storeIdx] peer := cachedRegion.meta.Peers[storeIdx]

View File

@ -47,7 +47,7 @@ import (
"github.com/pingcap/goleveldb/leveldb/storage" "github.com/pingcap/goleveldb/leveldb/storage"
"github.com/pingcap/goleveldb/leveldb/util" "github.com/pingcap/goleveldb/leveldb/util"
"github.com/pingcap/kvproto/pkg/kvrpcpb" "github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/parser/terror" tikverr "github.com/tikv/client-go/v2/error"
"github.com/tikv/client-go/v2/internal/logutil" "github.com/tikv/client-go/v2/internal/logutil"
"github.com/tikv/client-go/v2/internal/mockstore/deadlock" "github.com/tikv/client-go/v2/internal/mockstore/deadlock"
"github.com/tikv/client-go/v2/oracle" "github.com/tikv/client-go/v2/oracle"
@ -420,7 +420,7 @@ func (mvcc *MVCCLevelDB) ReverseScan(startKey, endKey []byte, limit int, startTS
succ := iter.Last() succ := iter.Last()
currKey, _, err := mvccDecode(iter.Key()) currKey, _, err := mvccDecode(iter.Key())
// TODO: return error. // TODO: return error.
terror.Log(errors.Trace(err)) tikverr.Log(err)
helper := reverseScanHelper{ helper := reverseScanHelper{
startTS: startTS, startTS: startTS,
isoLevel: isoLevel, isoLevel: isoLevel,
@ -1532,7 +1532,7 @@ func (mvcc *MVCCLevelDB) RawPut(key, value []byte) {
if value == nil { if value == nil {
value = []byte{} value = []byte{}
} }
terror.Log(mvcc.db.Put(key, value, nil)) tikverr.Log(mvcc.db.Put(key, value, nil))
} }
// RawBatchPut implements the RawKV interface // RawBatchPut implements the RawKV interface
@ -1548,7 +1548,7 @@ func (mvcc *MVCCLevelDB) RawBatchPut(keys, values [][]byte) {
} }
batch.Put(key, value) batch.Put(key, value)
} }
terror.Log(mvcc.db.Write(batch, nil)) tikverr.Log(mvcc.db.Write(batch, nil))
} }
// RawGet implements the RawKV interface. // RawGet implements the RawKV interface.
@ -1557,7 +1557,7 @@ func (mvcc *MVCCLevelDB) RawGet(key []byte) []byte {
defer mvcc.mu.Unlock() defer mvcc.mu.Unlock()
ret, err := mvcc.db.Get(key, nil) ret, err := mvcc.db.Get(key, nil)
terror.Log(err) tikverr.Log(err)
return ret return ret
} }
@ -1569,7 +1569,7 @@ func (mvcc *MVCCLevelDB) RawBatchGet(keys [][]byte) [][]byte {
values := make([][]byte, 0, len(keys)) values := make([][]byte, 0, len(keys))
for _, key := range keys { for _, key := range keys {
value, err := mvcc.db.Get(key, nil) value, err := mvcc.db.Get(key, nil)
terror.Log(err) tikverr.Log(err)
values = append(values, value) values = append(values, value)
} }
return values return values
@ -1580,7 +1580,7 @@ func (mvcc *MVCCLevelDB) RawDelete(key []byte) {
mvcc.mu.Lock() mvcc.mu.Lock()
defer mvcc.mu.Unlock() defer mvcc.mu.Unlock()
terror.Log(mvcc.db.Delete(key, nil)) tikverr.Log(mvcc.db.Delete(key, nil))
} }
// RawBatchDelete implements the RawKV interface. // RawBatchDelete implements the RawKV interface.
@ -1592,7 +1592,7 @@ func (mvcc *MVCCLevelDB) RawBatchDelete(keys [][]byte) {
for _, key := range keys { for _, key := range keys {
batch.Delete(key) batch.Delete(key)
} }
terror.Log(mvcc.db.Write(batch, nil)) tikverr.Log(mvcc.db.Write(batch, nil))
} }
// RawScan implements the RawKV interface. // RawScan implements the RawKV interface.
@ -1654,7 +1654,7 @@ func (mvcc *MVCCLevelDB) RawReverseScan(startKey, endKey []byte, limit int) []Pa
// RawDeleteRange implements the RawKV interface. // RawDeleteRange implements the RawKV interface.
func (mvcc *MVCCLevelDB) RawDeleteRange(startKey, endKey []byte) { func (mvcc *MVCCLevelDB) RawDeleteRange(startKey, endKey []byte) {
terror.Log(mvcc.doRawDeleteRange(startKey, endKey)) tikverr.Log(mvcc.doRawDeleteRange(startKey, endKey))
} }
// doRawDeleteRange deletes all keys in a range and return the error if any. // doRawDeleteRange deletes all keys in a range and return the error if any.