Skip to content

Commit

Permalink
Compact snapshot stats: Fix incorrect counting for current snapshot
Browse files Browse the repository at this point in the history
Due to the way the code was written, we would either count the current
snapshot, or emit statistics - but even if we emit statistics we still
need to increment the snapshot count.
  • Loading branch information
lfittl committed Nov 29, 2023
1 parent def6956 commit 8c8adc3
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions output/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,26 +142,27 @@ func submitCompactSnapshot(ctx context.Context, server *state.Server, collection
if server.CompactLogTime.IsZero() {
server.CompactLogTime = time.Now().Truncate(time.Minute)
server.CompactLogStats = make(map[string]uint8)
} else if time.Now().Sub(server.CompactLogTime) > time.Minute {
var keys []string
for k := range server.CompactLogStats {
keys = append(keys, k)
}
sort.Strings(keys)
details := ""
for i, kind := range keys {
details += fmt.Sprintf("%d %s", server.CompactLogStats[kind], kind)
if i < len(keys)-1 {
details += ", "
}
}
if len(details) > 0 {
logger.PrintInfo("Compact snapshots submitted: " + details)
}
server.CompactLogTime = time.Now().Truncate(time.Minute)
server.CompactLogStats = make(map[string]uint8)
} else {
server.CompactLogStats[kind] = server.CompactLogStats[kind] + 1
if time.Since(server.CompactLogTime) > time.Minute {
var keys []string
for k := range server.CompactLogStats {
keys = append(keys, k)
}
sort.Strings(keys)
details := ""
for i, kind := range keys {
details += fmt.Sprintf("%d %s", server.CompactLogStats[kind], kind)
if i < len(keys)-1 {
details += ", "
}
}
if len(details) > 0 {
logger.PrintInfo("Compact snapshots submitted: " + details)
}
server.CompactLogTime = time.Now().Truncate(time.Minute)
server.CompactLogStats = make(map[string]uint8)
}
}
}

Expand Down

0 comments on commit 8c8adc3

Please sign in to comment.