Skip to content

Commit 084a0d8

Browse files
nurzhan-saktaganovKaymeKaydex
authored andcommitted
Router.Call: add pause before rerying r.Route (resolve #66)
1 parent 094a538 commit 084a0d8

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGES:
55
* More strict check of vshard.storage.call response.
66
* Bump go-tarantool from v2.3.0 to v2.3.1.
77
* Get rid of nameToReplicasetMutex, use atomic instead.
8+
* Add configurable pause before retrying r.Route in Router.Call method.
89

910
## v2.0.5
1011

api.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ func (s StorageCallVShardError) Error() string {
185185

186186
type CallOpts struct {
187187
Timeout time.Duration
188+
// RouteRetryPause is a pause before the next attempt of r.Route request
189+
// if the previous one fails. The default is 0, which corresponds
190+
// to the lua router behavior: there is no pause in this case.
191+
RouteRetryPause time.Duration
188192
}
189193

190194
// CallMode is a type to represent call mode for Router.Call method.
@@ -296,9 +300,12 @@ func (r *Router) Call(ctx context.Context, bucketID uint64, mode CallMode,
296300
// this error will be returned to a caller in case of timeout
297301
err = fmt.Errorf("cant resolve bucket %d: %w", bucketID, err)
298302

299-
// TODO: lua vshard router just yields here and retires, no pause is applied.
300-
// https://github.com/tarantool/vshard/blob/b6fdbe950a2e4557f05b83bd8b846b126ec3724e/vshard/router/init.lua#L713
301-
// So we also retry here. But I guess we should add some pause here.
303+
// The lua vshard router just yields here and retires, no pause is applied.
304+
// But without a pause we may have few problems, see: https://github.com/tarantool/go-vshard-router/issues/66.
305+
if opts.RouteRetryPause > 0 {
306+
time.Sleep(opts.RouteRetryPause)
307+
}
308+
302309
continue
303310
}
304311

0 commit comments

Comments
 (0)