diff --git a/cmd/flags.go b/cmd/flags.go index a5ff7f51e6c1..a59fe3070c08 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -82,7 +82,7 @@ func clientFlags() []cli.Flag { }, &cli.IntFlag{ Name: "io-retries", - Value: 30, + Value: 10, Usage: "number of retries after network failure", }, &cli.IntFlag{ diff --git a/cmd/mount.go b/cmd/mount.go index be19b83bf86c..e01e1d4f8e9a 100644 --- a/cmd/mount.go +++ b/cmd/mount.go @@ -255,7 +255,7 @@ func prepareMp(mp string) { func getMetaConf(c *cli.Context, mp string, readOnly bool) *meta.Config { return &meta.Config{ - Retries: 10, + Retries: c.Int("io-retries"), Strict: true, ReadOnly: readOnly, NoBGJob: c.Bool("no-bgjob"), @@ -286,6 +286,7 @@ func getChunkConf(c *cli.Context, format *meta.Format) *chunk.Config { PutTimeout: time.Second * time.Duration(c.Int("put-timeout")), MaxUpload: c.Int("max-uploads"), MaxDeletes: c.Int("max-deletes"), + MaxRetries: c.Int("io-retries"), Writeback: c.Bool("writeback"), Prefetch: c.Int("prefetch"), BufferSize: c.Int("buffer-size") << 20, diff --git a/docs/en/reference/command_reference.md b/docs/en/reference/command_reference.md index 6806ac4b8682..f4476ef4f0d6 100644 --- a/docs/en/reference/command_reference.md +++ b/docs/en/reference/command_reference.md @@ -223,7 +223,7 @@ the max number of seconds to download an object (default: 60) the max number of seconds to upload an object (default: 60) `--io-retries value`
-number of retries after network failure (default: 30) +number of retries after network failure (default: 10) `--max-uploads value`
number of connections to upload (default: 20) @@ -311,7 +311,7 @@ the max number of seconds to download an object (default: 60) the max number of seconds to upload an object (default: 60) `--io-retries value`
-number of retries after network failure (default: 30) +number of retries after network failure (default: 10) `--max-uploads value`
number of connections to upload (default: 20) @@ -410,7 +410,7 @@ the max number of seconds to download an object (default: 60) the max number of seconds to upload an object (default: 60) `--io-retries value`
-number of retries after network failure (default: 30) +number of retries after network failure (default: 10) `--max-uploads value`
number of connections to upload (default: 20) diff --git a/docs/zh_cn/reference/command_reference.md b/docs/zh_cn/reference/command_reference.md index ff9a74dc44bf..110f00706daa 100644 --- a/docs/zh_cn/reference/command_reference.md +++ b/docs/zh_cn/reference/command_reference.md @@ -223,7 +223,7 @@ consul注册中心地址(默认: "127.0.0.1:8500") 上传一个对象的超时时间;单位为秒 (默认: 60) `--io-retries value`
-网络异常时的重试次数 (默认: 30) +网络异常时的重试次数 (默认: 10) `--max-uploads value`
上传对象的连接数 (默认: 20) @@ -311,7 +311,7 @@ juicefs gateway [command options] META-URL ADDRESS 上传一个对象的超时时间;单位为秒 (默认: 60) `--io-retries value`
-网络异常时的重试次数 (默认: 30) +网络异常时的重试次数 (默认: 10) `--max-uploads value`
上传对象的连接数 (默认: 20) @@ -408,7 +408,7 @@ juicefs webdav [command options] META-URL ADDRESS 上传一个对象的超时时间;单位为秒 (默认: 60) `--io-retries value`
-网络异常时的重试次数 (默认: 30) +网络异常时的重试次数 (默认: 10) `--max-uploads value`
上传对象的连接数 (默认: 20) diff --git a/pkg/chunk/cached_store.go b/pkg/chunk/cached_store.go index 28444566aea0..2ff01ccf4cd4 100644 --- a/pkg/chunk/cached_store.go +++ b/pkg/chunk/cached_store.go @@ -448,7 +448,7 @@ func (store *cachedStore) upload(key string, block *Page, c *wChunk) error { try, max := 0, 3 if sync { - max = 10 + max = store.conf.MaxRetries } for ; try < max; try++ { time.Sleep(time.Second * time.Duration(try*try)) @@ -590,6 +590,7 @@ type Config struct { Compress string MaxUpload int MaxDeletes int + MaxRetries int UploadLimit int64 // bytes per second DownloadLimit int64 // bytes per second Writeback bool @@ -698,6 +699,9 @@ func NewCachedStore(storage object.ObjectStorage, config Config, registerer prom if compressor == nil { logger.Fatalf("unknown compress algorithm: %s", config.Compress) } + if config.MaxRetries == 0 { + config.MaxRetries = 10 + } if config.GetTimeout == 0 { config.GetTimeout = time.Second * 60 } diff --git a/pkg/chunk/cached_store_test.go b/pkg/chunk/cached_store_test.go index e46a60ef017d..dd3181b0466e 100644 --- a/pkg/chunk/cached_store_test.go +++ b/pkg/chunk/cached_store_test.go @@ -96,6 +96,7 @@ var defaultConf = Config{ CacheSize: 1, MaxUpload: 1, MaxDeletes: 1, + MaxRetries: 10, PutTimeout: time.Second, GetTimeout: time.Second * 2, AutoCreate: true, diff --git a/pkg/meta/base.go b/pkg/meta/base.go index 663fc43fa91e..2d81b62efd26 100644 --- a/pkg/meta/base.go +++ b/pkg/meta/base.go @@ -97,7 +97,7 @@ type baseMeta struct { func newBaseMeta(conf *Config) baseMeta { if conf.Retries == 0 { - conf.Retries = 30 + conf.Retries = 10 } if conf.Heartbeat == 0 { conf.Heartbeat = 12 * time.Second diff --git a/sdk/java/libjfs/main.go b/sdk/java/libjfs/main.go index 72a6c238a116..7c7436e1e28c 100644 --- a/sdk/java/libjfs/main.go +++ b/sdk/java/libjfs/main.go @@ -249,6 +249,7 @@ type javaConf struct { DownloadLimit int `json:"downloadLimit"` MaxUploads int `json:"maxUploads"` MaxDeletes int `json:"maxDeletes"` + IORetries int `json:"ioRetries"` GetTimeout int `json:"getTimeout"` PutTimeout int `json:"putTimeout"` FastResolve bool `json:"fastResolve"` @@ -396,7 +397,7 @@ func jfs_init(cname, jsonConf, user, group, superuser, supergroup *C.char) uintp } metaConf := &meta.Config{ - Retries: 10, + Retries: jConf.IORetries, Strict: true, ReadOnly: jConf.ReadOnly, NoBGJob: jConf.NoBGJob, @@ -460,6 +461,7 @@ func jfs_init(cname, jsonConf, user, group, superuser, supergroup *C.char) uintp CacheFullBlock: jConf.CacheFullBlock, MaxUpload: jConf.MaxUploads, MaxDeletes: jConf.MaxDeletes, + MaxRetries: jConf.IORetries, UploadLimit: int64(jConf.UploadLimit) * 1e6 / 8, DownloadLimit: int64(jConf.DownloadLimit) * 1e6 / 8, Prefetch: jConf.Prefetch, diff --git a/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java b/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java index 7b89e7708dca..306fd2506872 100644 --- a/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java +++ b/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java @@ -316,6 +316,7 @@ public void initialize(URI uri, Configuration conf) throws IOException { obj.put("maxDeletes", Integer.valueOf(getConf(conf, "max-deletes", "2"))); obj.put("uploadLimit", Integer.valueOf(getConf(conf, "upload-limit", "0"))); obj.put("downloadLimit", Integer.valueOf(getConf(conf, "download-limit", "0"))); + obj.put("ioRetries", Integer.valueOf(getConf(conf, "io-retries", "10"))); obj.put("getTimeout", Integer.valueOf(getConf(conf, "get-timeout", getConf(conf, "object-timeout", "5")))); obj.put("putTimeout", Integer.valueOf(getConf(conf, "put-timeout", getConf(conf, "object-timeout", "60")))); obj.put("memorySize", Integer.valueOf(getConf(conf, "memory-size", "300")));