|
35 | 35 | package error |
36 | 36 |
|
37 | 37 | import ( |
| 38 | + "encoding/hex" |
38 | 39 | "fmt" |
39 | 40 | "time" |
40 | 41 |
|
|
86 | 87 | ErrRegionNotInitialized = errors.New("region not Initialized") |
87 | 88 | // ErrTiKVDiskFull is the error when tikv server disk usage is full. |
88 | 89 | ErrTiKVDiskFull = errors.New("tikv disk full") |
| 90 | + // ErrRegionRecoveryInProgress is the error when region is recovering. |
| 91 | + ErrRegionRecoveryInProgress = errors.New("region is being online unsafe recovered") |
| 92 | + // ErrRegionFlashbackInProgress is the error when a region in the flashback progress receive any other request. |
| 93 | + ErrRegionFlashbackInProgress = errors.New("region is in the flashback progress") |
| 94 | + // ErrRegionFlashbackNotPrepared is the error when a region is not prepared for the flashback first. |
| 95 | + ErrRegionFlashbackNotPrepared = errors.New("region is not prepared for the flashback") |
89 | 96 | // ErrUnknown is the unknow error. |
90 | 97 | ErrUnknown = errors.New("unknow") |
91 | 98 | // ErrResultUndetermined is the error when execution result is unknown. |
@@ -150,13 +157,14 @@ func IsErrWriteConflict(err error) bool { |
150 | 157 | return errors.As(err, &e) |
151 | 158 | } |
152 | 159 |
|
153 | | -//NewErrWriteConfictWithArgs generates an ErrWriteConflict with args. |
154 | | -func NewErrWriteConfictWithArgs(startTs, conflictTs, conflictCommitTs uint64, key []byte) *ErrWriteConflict { |
| 160 | +// NewErrWriteConflictWithArgs generates an ErrWriteConflict with args. |
| 161 | +func NewErrWriteConflictWithArgs(startTs, conflictTs, conflictCommitTs uint64, key []byte, reason kvrpcpb.WriteConflict_Reason) *ErrWriteConflict { |
155 | 162 | conflict := kvrpcpb.WriteConflict{ |
156 | 163 | StartTs: startTs, |
157 | 164 | ConflictTs: conflictTs, |
158 | 165 | Key: key, |
159 | 166 | ConflictCommitTs: conflictCommitTs, |
| 167 | + Reason: reason, |
160 | 168 | } |
161 | 169 | return &ErrWriteConflict{WriteConflict: &conflict} |
162 | 170 | } |
@@ -236,10 +244,36 @@ type ErrAssertionFailed struct { |
236 | 244 | *kvrpcpb.AssertionFailed |
237 | 245 | } |
238 | 246 |
|
| 247 | +// ErrLockOnlyIfExistsNoReturnValue is used when the flag `LockOnlyIfExists` of `LockCtx` is set, but `ReturnValues`` is not. |
| 248 | +type ErrLockOnlyIfExistsNoReturnValue struct { |
| 249 | + StartTS uint64 |
| 250 | + ForUpdateTs uint64 |
| 251 | + LockKey []byte |
| 252 | +} |
| 253 | + |
| 254 | +// ErrLockOnlyIfExistsNoPrimaryKey is used when the flag `LockOnlyIfExists` of `LockCtx` is set, but primary key of current transaction is not. |
| 255 | +type ErrLockOnlyIfExistsNoPrimaryKey struct { |
| 256 | + StartTS uint64 |
| 257 | + ForUpdateTs uint64 |
| 258 | + LockKey []byte |
| 259 | +} |
| 260 | + |
239 | 261 | func (e *ErrAssertionFailed) Error() string { |
240 | 262 | return fmt.Sprintf("assertion failed { %s }", e.AssertionFailed.String()) |
241 | 263 | } |
242 | 264 |
|
| 265 | +func (e *ErrLockOnlyIfExistsNoReturnValue) Error() string { |
| 266 | + return fmt.Sprintf("LockOnlyIfExists is set for Lock Context, but ReturnValues is not set, "+ |
| 267 | + "StartTs is {%d}, ForUpdateTs is {%d}, one of lock keys is {%v}.", |
| 268 | + e.StartTS, e.ForUpdateTs, hex.EncodeToString(e.LockKey)) |
| 269 | +} |
| 270 | + |
| 271 | +func (e *ErrLockOnlyIfExistsNoPrimaryKey) Error() string { |
| 272 | + return fmt.Sprintf("LockOnlyIfExists is set for Lock Context, but primary key of current transaction is not set, "+ |
| 273 | + "StartTs is {%d}, ForUpdateTs is {%d}, one of lock keys is {%s}", |
| 274 | + e.StartTS, e.ForUpdateTs, hex.EncodeToString(e.LockKey)) |
| 275 | +} |
| 276 | + |
243 | 277 | // ExtractKeyErr extracts a KeyError. |
244 | 278 | func ExtractKeyErr(keyErr *kvrpcpb.KeyError) error { |
245 | 279 | if val, err := util.EvalFailpoint("mockRetryableErrorResp"); err == nil { |
|
0 commit comments