Skip to content

Commit

Permalink
properly decode varint in *.state2 files during check already process…
Browse files Browse the repository at this point in the history
…ed files to avoid too large numbers in logs

Signed-off-by: Slach <[email protected]>
  • Loading branch information
Slach committed Dec 13, 2024
1 parent 9ca1220 commit 5eb2445
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v2.6.5

BUG FIXES

- properly decode varint in *.state2 files during check already processed files to avoid too large numbers in logs

# v2.6.4

BUG FIXES
Expand Down
12 changes: 9 additions & 3 deletions pkg/resumable/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"encoding/json"
"fmt"
"github.com/Altinity/clickhouse-backup/v2/pkg/common"
"github.com/Altinity/clickhouse-backup/v2/pkg/utils"
"github.com/rs/zerolog/log"
bolt "go.etcd.io/bbolt"
"math/big"
"path"
)

Expand Down Expand Up @@ -169,8 +169,14 @@ func (s *State) IsAlreadyProcessed(path string) (bool, int64) {
buf := b.Get([]byte(path))
if buf != nil {
found = true
size = new(big.Int).SetBytes(buf).Int64()
log.Info().Msgf("%s already processed", path)
n := 0
size, n = binary.Varint(buf)
if n == 0 {
return fmt.Errorf("buffer too small")
} else if n < 0 {
return fmt.Errorf("value larger than 64 bits (overflow)")
}
log.Info().Msgf("%s already processed, size %s", path, utils.FormatBytes(uint64(size)))
}
return nil
})
Expand Down

0 comments on commit 5eb2445

Please sign in to comment.