Skip to content

Commit

Permalink
Fix changelog path for receiptdb
Browse files Browse the repository at this point in the history
  • Loading branch information
yzang2019 committed Aug 12, 2024
1 parent 6d8660b commit 5885fb5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ss/pebbledb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,17 @@ func New(dataDir string, config config.StateStoreConfig) (*Database, error) {
pendingChanges: make(chan VersionedChangesets, config.AsyncWriteBuffer),
}
if config.DedicatedChangelog {
keepRecent := config.KeepRecent
if config.KeepRecent <= 0 {
keepRecent = 100000
}
streamHandler, _ := changelog.NewStream(
logger.NewNopLogger(),
utils.GetChangelogPath(dataDir),
changelog.Config{
DisableFsync: true,
ZeroCopy: true,
KeepRecent: uint64(config.KeepRecent),
KeepRecent: uint64(keepRecent),
PruneInterval: 300 * time.Second,
},
)
Expand Down
3 changes: 3 additions & 0 deletions ss/rocksdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,6 @@ func cloneAppend(bz []byte, tail []byte) (res []byte) {
copy(res[len(bz):], tail)
return
}
func (db *Database) RawImport(ch <-chan types.RawSnapshotNode) error {
panic("implement me")
}
4 changes: 2 additions & 2 deletions ss/rocksdb_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (

func init() {
initializer := func(dir string, configs config.StateStoreConfig) (types.StateStore, error) {
dbHome := dir
dbHome := utils.GetStateStorePath(dir, configs.Backend)
if configs.DBDirectory != "" {
dbHome = configs.DBDirectory
}
return rocksdb.New(utils.GetStateStorePath(dbHome, configs.Backend), configs)
return rocksdb.New(dbHome, configs)
}
RegisterBackend(RocksDBBackend, initializer)
}
4 changes: 4 additions & 0 deletions ss/sqlite/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,7 @@ func execPragmas(db *sql.DB, pragmas []string) error {
}
return nil
}

func (db *Database) RawImport(ch <-chan types.RawSnapshotNode) error {
panic("implement me")
}
4 changes: 2 additions & 2 deletions ss/sqlite_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (

func init() {
initializer := func(dir string, configs config.StateStoreConfig) (types.StateStore, error) {
dbHome := dir
dbHome := utils.GetStateStorePath(dir, configs.Backend)
if configs.DBDirectory != "" {
dbHome = configs.DBDirectory
}
return sqlite.New(utils.GetStateStorePath(dbHome, configs.Backend), configs)
return sqlite.New(dbHome, configs)
}
RegisterBackend(SQLiteBackend, initializer)
}
4 changes: 4 additions & 0 deletions ss/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func NewStateStore(logger logger.Logger, homeDir string, ssConfig config.StateSt
// Handle auto recovery for DB running with async mode
if ssConfig.DedicatedChangelog {
changelogPath := utils.GetChangelogPath(utils.GetStateStorePath(homeDir, ssConfig.Backend))
if ssConfig.DBDirectory != "" {
changelogPath = utils.GetChangelogPath(ssConfig.DBDirectory)
}
err := RecoverStateStore(logger, changelogPath, stateStore)
if err != nil {
return nil, err
Expand All @@ -61,6 +64,7 @@ func NewStateStore(logger logger.Logger, homeDir string, ssConfig config.StateSt
// RecoverStateStore will be called during initialization to recover the state from rlog
func RecoverStateStore(logger logger.Logger, changelogPath string, stateStore types.StateStore) error {
ssLatestVersion, err := stateStore.GetLatestVersion()
logger.Info(fmt.Sprintf("Recovering from changelog %s at latest SS version %d", changelogPath, ssLatestVersion))
if err != nil {
return err
}
Expand Down

0 comments on commit 5885fb5

Please sign in to comment.