Skip to content

Commit 221d1b1

Browse files
authored
Merge pull request #6085 from ipfs/fix/thread-safe-mem-datastore
make in-memory datastore thread-safe
2 parents 65d093c + 3c383bc commit 221d1b1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

repo/fsrepo/datastores.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
ds "github.com/ipfs/go-datastore"
1212
"github.com/ipfs/go-datastore/mount"
13+
dssync "github.com/ipfs/go-datastore/sync"
1314
"github.com/ipfs/go-ds-measure"
1415
)
1516

@@ -174,7 +175,7 @@ func (c *memDatastoreConfig) DiskSpec() DiskSpec {
174175
}
175176

176177
func (c *memDatastoreConfig) Create(string) (repo.Datastore, error) {
177-
return ds.NewMapDatastore(), nil
178+
return dssync.MutexWrap(ds.NewMapDatastore()), nil
178179
}
179180

180181
type logDatastoreConfig struct {

repo/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ type Repo interface {
5959
// Datastore is the interface required from a datastore to be
6060
// acceptable to FSRepo.
6161
type Datastore interface {
62-
ds.Batching // should be threadsafe, just be careful
62+
ds.Batching // must be thread-safe
6363
}

0 commit comments

Comments
 (0)