Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Dec 22, 2023
1 parent 3217b74 commit 20e0872
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions store/pruning/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,13 @@ func (m *Manager) GetFlushAndResetPruningHeights() ([]int64, error) {
// previousHeight must be greater than 0 for the handling to take effect since valid heights start at 1 and 0 represents
// the latest height. The latest height cannot be pruned. As a result, if previousHeight is less than or equal to 0, 0 is returned.
func (m *Manager) HandleHeight(previousHeight int64) int64 {
fmt.Println("HandleHeight, previous height: ", previousHeight)
if m.opts.GetPruningStrategy() == types.PruningNothing || previousHeight <= 0 {
return 0
}

defer func() {
fmt.Println("running defer in handleHeight")
m.pruneHeightsMx.Lock()
defer m.pruneHeightsMx.Unlock()

Expand All @@ -116,6 +118,7 @@ func (m *Manager) HandleHeight(previousHeight int64) int64 {
var next *list.Element
for e := m.pruneSnapshotHeights.Front(); e != nil; e = next {
snHeight := e.Value.(int64)
fmt.Println("snHeight", snHeight)
if snHeight < previousHeight-int64(m.opts.KeepRecent) {
m.pruneHeights = append(m.pruneHeights, snHeight)

Expand All @@ -128,19 +131,23 @@ func (m *Manager) HandleHeight(previousHeight int64) int64 {
}

// flush the updates to disk so that they are not lost if crash happens.
fmt.Println("SetSync")
if err := m.db.SetSync(pruneHeightsKey, int64SliceToBytes(m.pruneHeights)); err != nil {
panic(err)
}
}()

fmt.Println("int64(m.opts.KeepRecent)", int64(m.opts.KeepRecent))
if int64(m.opts.KeepRecent) < previousHeight {
pruneHeight := previousHeight - int64(m.opts.KeepRecent)
fmt.Println("previousHeight - int64(m.opts.KeepRecent)", pruneHeight)
// We consider this height to be pruned iff:
//
// - snapshotInterval is zero as that means that all heights should be pruned.
// - snapshotInterval % (height - KeepRecent) != 0 as that means the height is not
// a 'snapshot' height.
if m.snapshotInterval == 0 || pruneHeight%int64(m.snapshotInterval) != 0 {
fmt.Println("m.snapshotInterval == 0 || pruneHeight%int64(m.snapshotInterval) != 0")
m.pruneHeightsMx.Lock()
defer m.pruneHeightsMx.Unlock()

Expand Down
3 changes: 2 additions & 1 deletion store/rootmulti/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,9 @@ func (rs *Store) GetKVStore(key types.StoreKey) types.KVStore {
}

func (rs *Store) handlePruning(version int64) error {
fmt.Println("calling handle pruning")
fmt.Println("calling handle pruning, version: ", version)
rs.pruningManager.HandleHeight(version - 1) // we should never prune the current version.
fmt.Println("ShouldPruneAtHeight: ", !rs.pruningManager.ShouldPruneAtHeight(version))
if !rs.pruningManager.ShouldPruneAtHeight(version) {
return nil
}
Expand Down

0 comments on commit 20e0872

Please sign in to comment.