Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove mutex in prefixdb #239

Merged
merged 41 commits into from
Jul 29, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5c9bfe8
fix: remove mutex in prefixdb
kjessec Mar 4, 2022
a0ff309
fmt
faddat Apr 25, 2022
636377b
fmt
faddat Apr 25, 2022
0155808
Delete .gitpod.yml
faddat Apr 25, 2022
973a74a
remove mutex entirely instead of commenting out
faddat Apr 25, 2022
34ca0e7
fmt
faddat Apr 25, 2022
d81b67b
remove .gitpod.yml
faddat Apr 25, 2022
4c9b066
update changelog
faddat Apr 25, 2022
0566540
Merge branch 'master' into remove-mutex
faddat Apr 25, 2022
f531a3f
prefixdb test
faddat May 6, 2022
cc11706
all test passed in prefixdb_test.go
vuong177 May 6, 2022
417a583
Merge branch 'master' into remove-mutex
catShaark May 6, 2022
3214560
simple taskKey in prefixdb_test.go
vuong177 May 6, 2022
fd0bb3d
Update prefixdb.go
faddat May 6, 2022
31c47b6
Merge branch 'master' into remove-mutex
faddat May 6, 2022
835d8fd
fmt db test so pr passes linter
faddat May 7, 2022
cb000ee
refactor func Run
vuong177 May 7, 2022
c6d827f
check nil err before create PrefixDB in TestWithGolevelDB
vuong177 May 7, 2022
b78aed6
add other db tests
catShaark May 8, 2022
e2c3c4e
Update prefixdb_test.go
faddat May 9, 2022
d56e038
Merge branch 'master' into remove-mutex
faddat May 9, 2022
84a67af
update prefixdb_test.go
catShaark May 10, 2022
72c47a4
minor defer
vuong177 May 11, 2022
0931c90
Merge branch 'master' into remove-mutex
faddat May 19, 2022
5c81bf8
fixup with build tags
faddat May 19, 2022
11fa71a
Create .gitpod.yml
faddat May 19, 2022
d57bb1f
fix linting
faddat May 19, 2022
8e4e401
itr.isInvalid would be unconditionally set anyhow, which is why the i…
faddat May 19, 2022
602ef89
Merge branch 'master' into remove-mutex
faddat May 20, 2022
d4bb034
Update cleveldb_test.go
faddat May 23, 2022
2640477
Update prefixdb_test.go
faddat May 23, 2022
d75f0c0
Update prefixdb_test.go
faddat May 23, 2022
4355c2a
Merge branch 'master' into remove-mutex
faddat Jun 4, 2022
f330226
Firing this into CI, let's see.
faddat Jun 4, 2022
230b7cc
add filepath lib to tests
faddat Jun 4, 2022
cdc2374
fix filepath in goleveldb
faddat Jun 4, 2022
e74373d
gofumpt formatting
faddat Jun 4, 2022
1ab7644
Merge branch 'master' into remove-mutex
faddat Jun 15, 2022
ea504e8
Merge branch 'master' into remove-mutex
faddat Jun 20, 2022
7d4b2c7
Merge branch 'master' into remove-mutex
faddat Jun 28, 2022
f39f7bb
Merge branch 'master' into remove-mutex
faddat Jul 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Unreleased

- remove mutex from prefixdb

## 0.6.7

**2022-2-21**
Expand Down
1 change: 1 addition & 0 deletions boltdb.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build boltdb
// +build boltdb

package db
Expand Down
1 change: 1 addition & 0 deletions boltdb_batch.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build boltdb
// +build boltdb

package db
Expand Down
1 change: 1 addition & 0 deletions boltdb_iterator.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build boltdb
// +build boltdb

package db
Expand Down
1 change: 1 addition & 0 deletions boltdb_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build boltdb
// +build boltdb

package db
Expand Down
1 change: 1 addition & 0 deletions cleveldb.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cleveldb
// +build cleveldb

package db
Expand Down
1 change: 1 addition & 0 deletions cleveldb_batch.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cleveldb
// +build cleveldb

package db
Expand Down
1 change: 1 addition & 0 deletions cleveldb_iterator.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cleveldb
// +build cleveldb

package db
Expand Down
1 change: 1 addition & 0 deletions cleveldb_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build cleveldb
// +build cleveldb

package db
Expand Down
20 changes: 2 additions & 18 deletions prefixdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func (pdb *PrefixDB) Get(key []byte) ([]byte, error) {
if len(key) == 0 {
return nil, errKeyEmpty
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()
// pdb.mtx.Lock()
// defer pdb.mtx.Unlock()
faddat marked this conversation as resolved.
Show resolved Hide resolved

pkey := pdb.prefixed(key)
value, err := pdb.db.Get(pkey)
Expand All @@ -43,8 +43,6 @@ func (pdb *PrefixDB) Has(key []byte) (bool, error) {
if len(key) == 0 {
return false, errKeyEmpty
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

ok, err := pdb.db.Has(pdb.prefixed(key))
if err != nil {
Expand All @@ -62,8 +60,6 @@ func (pdb *PrefixDB) Set(key []byte, value []byte) error {
if value == nil {
return errValueNil
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

pkey := pdb.prefixed(key)
if err := pdb.db.Set(pkey, value); err != nil {
Expand All @@ -80,8 +76,6 @@ func (pdb *PrefixDB) SetSync(key []byte, value []byte) error {
if value == nil {
return errValueNil
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

return pdb.db.SetSync(pdb.prefixed(key), value)
}
Expand All @@ -91,8 +85,6 @@ func (pdb *PrefixDB) Delete(key []byte) error {
if len(key) == 0 {
return errKeyEmpty
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

return pdb.db.Delete(pdb.prefixed(key))
}
Expand All @@ -102,8 +94,6 @@ func (pdb *PrefixDB) DeleteSync(key []byte) error {
if len(key) == 0 {
return errKeyEmpty
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

return pdb.db.DeleteSync(pdb.prefixed(key))
}
Expand All @@ -113,8 +103,6 @@ func (pdb *PrefixDB) Iterator(start, end []byte) (Iterator, error) {
if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) {
return nil, errKeyEmpty
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

var pstart, pend []byte
pstart = append(cp(pdb.prefix), start...)
Expand All @@ -136,8 +124,6 @@ func (pdb *PrefixDB) ReverseIterator(start, end []byte) (Iterator, error) {
if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) {
return nil, errKeyEmpty
}
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

var pstart, pend []byte
pstart = append(cp(pdb.prefix), start...)
Expand All @@ -156,8 +142,6 @@ func (pdb *PrefixDB) ReverseIterator(start, end []byte) (Iterator, error) {

// NewBatch implements DB.
func (pdb *PrefixDB) NewBatch() Batch {
pdb.mtx.Lock()
defer pdb.mtx.Unlock()

return newPrefixBatch(pdb.prefix, pdb.db.NewBatch())
}
Expand Down
1 change: 1 addition & 0 deletions rocksdb.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build rocksdb
// +build rocksdb

package db
Expand Down
1 change: 1 addition & 0 deletions rocksdb_batch.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build rocksdb
// +build rocksdb

package db
Expand Down
1 change: 1 addition & 0 deletions rocksdb_iterator.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build rocksdb
// +build rocksdb

package db
Expand Down
1 change: 1 addition & 0 deletions rocksdb_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build rocksdb
// +build rocksdb

package db
Expand Down