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

Problem: no invalid version check in DecreaseValidationIdx #16

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions memdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type (
)

var (
_ storetypes.KVStore = (*MemDB)(nil)
_ storetypes.KVStore = (*MemDB)(nil)
_ storetypes.ObjKVStore = (*ObjMemDB)(nil)
)

Expand Down Expand Up @@ -86,7 +86,7 @@ func (db *GMemDB[V]) Delete(key []byte) {
}

// When used as an overlay (e.g. WriteSet), it stores the `nil` value to represent deleted keys,
// so we return seperate bool value for found status.
// so we return separate bool value for found status.
func (db *GMemDB[V]) OverlayGet(key Key) (V, bool) {
item, ok := db.BTreeG.Get(memdbItem[V]{key: key})
if !ok {
Expand Down
10 changes: 5 additions & 5 deletions mvdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,26 @@ func TestMVData(t *testing.T) {
// read closest version
value, version, estimate := data.Read([]byte("a"), 4)
require.False(t, estimate)
require.Equal(t, []byte([]byte("3")), value)
require.Equal(t, []byte("3"), value)
require.Equal(t, TxnVersion{Index: 3, Incarnation: 1}, version)

// read closest version
value, version, estimate = data.Read([]byte("a"), 3)
require.False(t, estimate)
require.Equal(t, []byte([]byte("2")), value)
require.Equal(t, []byte("2"), value)
require.Equal(t, TxnVersion{Index: 2, Incarnation: 1}, version)

// read closest version
value, version, estimate = data.Read([]byte("b"), 3)
require.False(t, estimate)
require.Equal(t, []byte([]byte("2")), value)
require.Equal(t, []byte("2"), value)
require.Equal(t, TxnVersion{Index: 2, Incarnation: 1}, version)

// new incarnation overrides old
data.Write([]byte("a"), []byte("3-2"), TxnVersion{Index: 3, Incarnation: 2})
value, version, estimate = data.Read([]byte("a"), 4)
require.False(t, estimate)
require.Equal(t, []byte([]byte("3-2")), value)
require.Equal(t, []byte("3-2"), value)
require.Equal(t, TxnVersion{Index: 3, Incarnation: 2}, version)

// read estimate
Expand All @@ -64,7 +64,7 @@ func TestMVData(t *testing.T) {
data.Delete([]byte("a"), 3)
value, version, estimate = data.Read([]byte("a"), 4)
require.False(t, estimate)
require.Equal(t, []byte([]byte("2")), value)
require.Equal(t, []byte("2"), value)
require.Equal(t, TxnVersion{Index: 2, Incarnation: 1}, version)

data.Delete([]byte("b"), 2)
Expand Down
2 changes: 1 addition & 1 deletion mviterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (it *MVIterator[V]) resolveValueInner(tree *BTree[secondaryDataItem[V]]) (*
it.waitFn(v.Index)
continue
}
// in validation mode, it should fail validation immediatelly
// in validation mode, it should fail validation immediately
return nil, false
}

Expand Down
6 changes: 4 additions & 2 deletions scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ func (s *Scheduler) Done() bool {
}

func (s *Scheduler) DecreaseValidationIdx(target TxnIndex) {
StoreMin(&s.validation_idx, uint64(target))
s.decrease_cnt.Add(1)
if target != InvalidTxnVersion.Index {
StoreMin(&s.validation_idx, uint64(target))
s.decrease_cnt.Add(1)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you describe the issue?

}

func (s *Scheduler) CheckDone() {
Expand Down
Loading