-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add pruning and WAL capability for SS store #66
Merged
Merged
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
220d9d5
Add pruning and WAL capability for SS store
yzang2019 7eedc76
Add WAL pruning logic
yzang2019 ddd967b
Fix config
yzang2019 11fa022
Fix edge case
yzang2019 1c4ddd0
Add comment
yzang2019 7e3f2f5
Fix error handling
yzang2019 40cd25b
Add comment
yzang2019 013b484
Add wait group to fix race condition
yzang2019 a3be48c
Fix lint
yzang2019 9959509
Fix lint
yzang2019 8dc4818
Add debug log
yzang2019 7b5d29d
Remove debug log
yzang2019 479ae25
Merge branch 'main' into yzang/SEI-7639
yzang2019 aaf6f86
Fix rocksdb and sqlite
yzang2019 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package ss | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cosmos/iavl" | ||
"github.com/sei-protocol/sei-db/common/logger" | ||
"github.com/sei-protocol/sei-db/config" | ||
"github.com/sei-protocol/sei-db/proto" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNewStateStore(t *testing.T) { | ||
tempDir := os.TempDir() | ||
ssConfig := config.StateStoreConfig{ | ||
DedicatedChangelog: true, | ||
Backend: string(PebbleDBBackend), | ||
AsyncWriteBuffer: 10, | ||
KeepRecent: 100, | ||
} | ||
stateStore, err := NewStateStore(logger.NewNopLogger(), tempDir, ssConfig) | ||
require.NoError(t, err) | ||
for i := 1; i < 10; i++ { | ||
var changesets []*proto.NamedChangeSet | ||
kvPair := &iavl.KVPair{ | ||
Delete: false, | ||
Key: []byte(fmt.Sprintf("key%d", i)), | ||
Value: []byte(fmt.Sprintf("value%d", i)), | ||
} | ||
var pairs []*iavl.KVPair | ||
pairs = append(pairs, kvPair) | ||
cs := iavl.ChangeSet{Pairs: pairs} | ||
ncs := &proto.NamedChangeSet{ | ||
Name: "storeA", | ||
Changeset: cs, | ||
} | ||
changesets = append(changesets, ncs) | ||
err := stateStore.ApplyChangesetAsync(int64(i), changesets) | ||
require.NoError(t, err) | ||
} | ||
// Closing the state store without waiting for data to be fully flushed | ||
err = stateStore.Close() | ||
require.NoError(t, err) | ||
|
||
// Reopen a new state store | ||
stateStore, err = NewStateStore(logger.NewNopLogger(), tempDir, ssConfig) | ||
require.NoError(t, err) | ||
|
||
// Make sure key and values can be found | ||
for i := 1; i < 10; i++ { | ||
value, err := stateStore.Get("storeA", int64(i), []byte(fmt.Sprintf("key%d", i))) | ||
require.NoError(t, err) | ||
require.Equal(t, fmt.Sprintf("value%d", i), string(value)) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Spawning a Go routine Note