Skip to content
This repository was archived by the owner on Mar 9, 2025. It is now read-only.

Commit ff91782

Browse files
resolve issue #93
* Add a pause between bucketsDiscovery requests (default is 10 ms)
1 parent 88df99a commit ff91782

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

discovery.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ func (r *Router) DiscoveryAllBuckets(ctx context.Context) error {
261261
}
262262

263263
bucketsDiscoveryPaginationFrom = resp.NextFrom
264+
265+
// Don't spam many requests at once. Give storages time to handle them and other requests.
266+
// https://github.com/tarantool/vshard/blob/b6fdbe950a2e4557f05b83bd8b846b126ec3724e/vshard/router/init.lua#L308
267+
time.Sleep(r.cfg.DiscoveryWorkStep)
264268
}
265269
})
266270
}

vshard.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ type Config struct {
9393

9494
// Discovery
9595
// DiscoveryTimeout is timeout between cron discovery job; by default there is no timeout.
96-
DiscoveryTimeout time.Duration
97-
DiscoveryMode DiscoveryMode
96+
DiscoveryTimeout time.Duration
97+
DiscoveryWorkStep time.Duration
98+
DiscoveryMode DiscoveryMode
9899

99100
// BucketsSearchMode defines policy for BucketDiscovery method.
100101
// Default value is BucketsSearchLegacy.
@@ -234,6 +235,7 @@ func (r *Router) RouteMapClean() {
234235

235236
func prepareCfg(cfg Config) (Config, error) {
236237
const discoveryTimeoutDefault = 1 * time.Minute
238+
const discoveryWorkStepDefault = 10 * time.Millisecond
237239

238240
err := validateCfg(cfg)
239241
if err != nil {
@@ -244,6 +246,10 @@ func prepareCfg(cfg Config) (Config, error) {
244246
cfg.DiscoveryTimeout = discoveryTimeoutDefault
245247
}
246248

249+
if cfg.DiscoveryWorkStep == 0 {
250+
cfg.DiscoveryWorkStep = discoveryWorkStepDefault
251+
}
252+
247253
if cfg.Loggerf == nil {
248254
cfg.Loggerf = emptyLogfProvider
249255
}

0 commit comments

Comments
 (0)