@@ -41,14 +41,17 @@ func (s storageCallAssertError) Error() string {
41
41
}
42
42
43
43
type StorageCallVShardError struct {
44
- BucketID uint64 `msgpack:"bucket_id" mapstructure:"bucket_id"`
45
- Reason string `msgpack:"reason"`
46
- Code int `msgpack:"code"`
47
- Type string `msgpack:"type"`
48
- Message string `msgpack:"message"`
49
- Name string `msgpack:"name"`
50
- MasterUUID * string `msgpack:"master_uuid" mapstructure:"master_uuid"` // mapstructure cant decode to source uuid type
51
- ReplicasetUUID * string `msgpack:"replicaset_uuid" mapstructure:"replicaset_uuid"` // mapstructure cant decode to source uuid type
44
+ BucketID uint64 `msgpack:"bucket_id" mapstructure:"bucket_id"`
45
+ Reason string `msgpack:"reason"`
46
+ Code int `msgpack:"code"`
47
+ Type string `msgpack:"type"`
48
+ Message string `msgpack:"message"`
49
+ Name string `msgpack:"name"`
50
+ // These 3 fields below are send as string by vshard storage, so we decode them into string, not uuid.UUID type
51
+ // Example: 00000000-0000-0002-0002-000000000000
52
+ MasterUUID string `msgpack:"master" mapstructure:"master"`
53
+ ReplicasetUUID string `msgpack:"replicaset" mapstructure:"replicaset"`
54
+ ReplicaUUID string `msgpack:"replica" mapstructure:"replica"`
52
55
}
53
56
54
57
func (s StorageCallVShardError ) Error () string {
@@ -165,7 +168,7 @@ func (r *Router) RouterCallImpl(ctx context.Context,
165
168
}
166
169
167
170
switch vshardError .Name {
168
- case "WRONG_BUCKET" , "BUCKET_IS_LOCKED" :
171
+ case VShardErrNameWrongBucket , VShardErrNameBucketIsLocked :
169
172
r .BucketReset (bucketID )
170
173
171
174
// TODO we should inspect here err.destination like lua vshard router does,
@@ -179,15 +182,17 @@ func (r *Router) RouterCallImpl(ctx context.Context,
179
182
// this vshardError will be returned to a caller in case of timeout
180
183
err = & vshardError
181
184
continue
182
- case "TRANSFER_IS_IN_PROGRESS" :
185
+ case VShardErrNameTransferIsInProgress :
183
186
// Since lua vshard router doesn't retry here, we don't retry too.
184
187
// There is a comment why lua vshard router doesn't retry:
185
188
// https://github.com/tarantool/vshard/blob/b6fdbe950a2e4557f05b83bd8b846b126ec3724e/vshard/router/init.lua#L697
186
189
r .BucketReset (bucketID )
187
190
return nil , nil , & vshardError
188
- case "NON_MASTER" :
189
- // We don't know how to handle this case yet, so just return it for now.
190
- // Here is issue for it: https://github.com/KaymeKaydex/go-vshard-router/issues/88
191
+ case VShardErrNameNonMaster :
192
+ // vshard.storage has returned NON_MASTER error, lua vshard router updates info about master in this case:
193
+ // See: https://github.com/tarantool/vshard/blob/b6fdbe950a2e4557f05b83bd8b846b126ec3724e/vshard/router/init.lua#L704.
194
+ // Since we use go-tarantool library, and go-tarantool library doesn't provide API to update info about current master,
195
+ // we just return this error as is.
191
196
return nil , nil , & vshardError
192
197
default :
193
198
return nil , nil , & vshardError
0 commit comments