github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/causetstore/milevadb-server/einsteindb/error.go (about)

     1  // Copyright 2020 WHTCORPS INC, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // See the License for the specific language governing permissions and
    12  // limitations under the License.
    13  
    14  package einsteindb
    15  
    16  import (
    17  	"github.com/whtcorpsinc/BerolinaSQL/terror"
    18  	"github.com/whtcorpsinc/ekvproto/pkg/FIDelpb"
    19  	"github.com/whtcorpsinc/ekvproto/pkg/ekvrpcpb"
    20  	"github.com/whtcorpsinc/errors"
    21  	allegrosql "github.com/whtcorpsinc/milevadb/errno"
    22  )
    23  
    24  var (
    25  	// ErrBodyMissing response body is missing error
    26  	ErrBodyMissing = errors.New("response body is missing")
    27  	// When MilevaDB is closing and send request to einsteindb fail, do not retry, return this error.
    28  	errMilevaDBShuttingDown = errors.New("milevadb server shutting down")
    29  )
    30  
    31  // mismatchClusterID represents the message that the cluster ID of the FIDel client does not match the FIDel.
    32  const mismatchClusterID = "mismatch cluster id"
    33  
    34  // MyALLEGROSQL error instances.
    35  var (
    36  	ErrEinsteinDBServerTimeout         = terror.ClassEinsteinDB.New(allegrosql.ErrEinsteinDBServerTimeout, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrEinsteinDBServerTimeout])
    37  	ErrResolveLockTimeout              = terror.ClassEinsteinDB.New(allegrosql.ErrResolveLockTimeout, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrResolveLockTimeout])
    38  	ErrFIDelServerTimeout              = terror.ClassEinsteinDB.New(allegrosql.ErrFIDelServerTimeout, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrFIDelServerTimeout])
    39  	ErrRegionUnavailable               = terror.ClassEinsteinDB.New(allegrosql.ErrRegionUnavailable, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrRegionUnavailable])
    40  	ErrEinsteinDBServerBusy            = terror.ClassEinsteinDB.New(allegrosql.ErrEinsteinDBServerBusy, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrEinsteinDBServerBusy])
    41  	ErrEinsteinDBStaleCommand          = terror.ClassEinsteinDB.New(allegrosql.ErrEinsteinDBStaleCommand, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrEinsteinDBStaleCommand])
    42  	ErrEinsteinDBMaxTimestampNotSynced = terror.ClassEinsteinDB.New(allegrosql.ErrEinsteinDBMaxTimestampNotSynced, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrEinsteinDBMaxTimestampNotSynced])
    43  	ErrGCTooEarly                      = terror.ClassEinsteinDB.New(allegrosql.ErrGCTooEarly, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrGCTooEarly])
    44  	ErrQueryInterrupted                = terror.ClassEinsteinDB.New(allegrosql.ErrQueryInterrupted, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrQueryInterrupted])
    45  	ErrLockAcquireFailAndNoWaitSet     = terror.ClassEinsteinDB.New(allegrosql.ErrLockAcquireFailAndNoWaitSet, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrLockAcquireFailAndNoWaitSet])
    46  	ErrLockWaitTimeout                 = terror.ClassEinsteinDB.New(allegrosql.ErrLockWaitTimeout, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrLockWaitTimeout])
    47  	ErrTokenLimit                      = terror.ClassEinsteinDB.New(allegrosql.ErrEinsteinDBStoreLimit, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrEinsteinDBStoreLimit])
    48  	ErrLockExpire                      = terror.ClassEinsteinDB.New(allegrosql.ErrLockExpire, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrLockExpire])
    49  	ErrUnknown                         = terror.ClassEinsteinDB.New(allegrosql.ErrUnknown, allegrosql.MyALLEGROSQLErrName[allegrosql.ErrUnknown])
    50  )
    51  
    52  // Registers error returned from EinsteinDB.
    53  var (
    54  	_ = terror.ClassEinsteinDB.NewStd(allegrosql.ErrDataOutOfRange)
    55  	_ = terror.ClassEinsteinDB.NewStd(allegrosql.ErrTruncatedWrongValue)
    56  	_ = terror.ClassEinsteinDB.NewStd(allegrosql.ErrDivisionByZero)
    57  )
    58  
    59  // ErrDeadlock wraps *ekvrpcpb.Deadlock to implement the error interface.
    60  // It also marks if the deadlock is retryable.
    61  type ErrDeadlock struct {
    62  	*ekvrpcpb.Deadlock
    63  	IsRetryable bool
    64  }
    65  
    66  func (d *ErrDeadlock) Error() string {
    67  	return d.Deadlock.String()
    68  }
    69  
    70  // FIDelError wraps *FIDelpb.Error to implement the error interface.
    71  type FIDelError struct {
    72  	Err *FIDelpb.Error
    73  }
    74  
    75  func (d *FIDelError) Error() string {
    76  	return d.Err.String()
    77  }