chore: update flatfs

And remove retry logic. This was flatfs specific and we've moved the logic down
into flatfs itself.

This update:

* Retries in more cases when we run out of file descriptors.
* Ensures we don't leak temporary files on batch put.
This commit is contained in:
Steven Allen 2020-04-10 16:41:12 -07:00
parent 0c619effc1
commit 8679954f9b
3 changed files with 4 additions and 24 deletions

View File

@ -1,12 +1,7 @@
package node
import (
"os"
"syscall"
"time"
"github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/retrystore"
blockstore "github.com/ipfs/go-ipfs-blockstore"
config "github.com/ipfs/go-ipfs-config"
"go.uber.org/fx"
@ -18,15 +13,6 @@ import (
"github.com/ipfs/go-ipfs/thirdparty/verifbs"
)
func isTooManyFDError(err error) bool {
perr, ok := err.(*os.PathError)
if ok && perr.Err == syscall.EMFILE {
return true
}
return false
}
// RepoConfig loads configuration from the repo
func RepoConfig(repo repo.Repo) (*config.Config, error) {
return repo.Config()
@ -43,14 +29,8 @@ type BaseBlocks blockstore.Blockstore
// BaseBlockstoreCtor creates cached blockstore backed by the provided datastore
func BaseBlockstoreCtor(cacheOpts blockstore.CacheOpts, nilRepo bool, hashOnRead bool) func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) {
return func(mctx helpers.MetricsCtx, repo repo.Repo, lc fx.Lifecycle) (bs BaseBlocks, err error) {
rds := &retrystore.Datastore{
Batching: repo.Datastore(),
Delay: time.Millisecond * 200,
Retries: 6,
TempErrFunc: isTooManyFDError,
}
// hash security
bs = blockstore.NewBlockstore(rds)
bs = blockstore.NewBlockstore(repo.Datastore())
bs = &verifbs.VerifBS{Blockstore: bs}
if !nilRepo {

2
go.mod
View File

@ -22,7 +22,7 @@ require (
github.com/ipfs/go-datastore v0.4.4
github.com/ipfs/go-detect-race v0.0.1
github.com/ipfs/go-ds-badger v0.2.4
github.com/ipfs/go-ds-flatfs v0.4.2
github.com/ipfs/go-ds-flatfs v0.4.3
github.com/ipfs/go-ds-leveldb v0.4.2
github.com/ipfs/go-ds-measure v0.1.0
github.com/ipfs/go-filestore v0.0.3

4
go.sum
View File

@ -263,8 +263,8 @@ github.com/ipfs/go-ds-badger v0.2.3 h1:J27YvAcpuA5IvZUbeBxOcQgqnYHUPxoygc6Qxxkod
github.com/ipfs/go-ds-badger v0.2.3/go.mod h1:pEYw0rgg3FIrywKKnL+Snr+w/LjJZVMTBRn4FS6UHUk=
github.com/ipfs/go-ds-badger v0.2.4 h1:UPGB0y7luFHk+mY/tUZrif/272M8o+hFsW+avLUeWrM=
github.com/ipfs/go-ds-badger v0.2.4/go.mod h1:pEYw0rgg3FIrywKKnL+Snr+w/LjJZVMTBRn4FS6UHUk=
github.com/ipfs/go-ds-flatfs v0.4.2 h1:v8VwVkmO+XN7YlrDgpuHl/0bGgu3qD44MKhIlbcfcFY=
github.com/ipfs/go-ds-flatfs v0.4.2/go.mod h1:KiZoBq31WFUR5LmDKPUHhsc0XZgjho+R/AzEPQpaN4U=
github.com/ipfs/go-ds-flatfs v0.4.3 h1:7M8/xpLkJhFJYaLumo2RRgt/cOehetutGW5zigTa5qY=
github.com/ipfs/go-ds-flatfs v0.4.3/go.mod h1:e4TesLyZoA8k1gV/yCuBTnt2PJtypn4XUlB5n8KQMZY=
github.com/ipfs/go-ds-leveldb v0.0.1/go.mod h1:feO8V3kubwsEF22n0YRQCffeb79OOYIykR4L04tMOYc=
github.com/ipfs/go-ds-leveldb v0.1.0 h1:OsCuIIh1LMTk4WIQ1UJH7e3j01qlOP+KWVhNS6lBDZY=
github.com/ipfs/go-ds-leveldb v0.1.0/go.mod h1:hqAW8y4bwX5LWcCtku2rFNX3vjDZCy5LZCg+cSZvYb8=