|
|
@@ -18,6 +18,7 @@ import (
|
|
|
"context"
|
|
|
"encoding/binary"
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"hash/crc32"
|
|
|
"math"
|
|
|
"sync"
|
|
|
@@ -330,7 +331,17 @@ func (s *store) restore() error {
|
|
|
_, finishedCompactBytes := tx.UnsafeRange(metaBucketName, finishedCompactKeyName, nil, 0)
|
|
|
if len(finishedCompactBytes) != 0 {
|
|
|
s.compactMainRev = bytesToRev(finishedCompactBytes[0]).main
|
|
|
- plog.Printf("restore compact to %d", s.compactMainRev)
|
|
|
+
|
|
|
+ if s.lg != nil {
|
|
|
+ s.lg.Info(
|
|
|
+ "restored last compact revision",
|
|
|
+ zap.String("meta-bucket-name", string(metaBucketName)),
|
|
|
+ zap.String("meta-bucket-name-key", string(finishedCompactKeyName)),
|
|
|
+ zap.Int64("restored-compact-revision", s.compactMainRev),
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ plog.Printf("restore compact to %d", s.compactMainRev)
|
|
|
+ }
|
|
|
}
|
|
|
_, scheduledCompactBytes := tx.UnsafeRange(metaBucketName, scheduledCompactKeyName, nil, 0)
|
|
|
scheduledCompact := int64(0)
|
|
|
@@ -377,7 +388,15 @@ func (s *store) restore() error {
|
|
|
}
|
|
|
err := s.le.Attach(lid, []lease.LeaseItem{{Key: key}})
|
|
|
if err != nil {
|
|
|
- plog.Errorf("unexpected Attach error: %v", err)
|
|
|
+ if s.lg != nil {
|
|
|
+ s.lg.Warn(
|
|
|
+ "failed to attach a lease",
|
|
|
+ zap.String("lease-id", fmt.Sprintf("%016x", lid)),
|
|
|
+ zap.Error(err),
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ plog.Errorf("unexpected Attach error: %v", err)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -385,7 +404,17 @@ func (s *store) restore() error {
|
|
|
|
|
|
if scheduledCompact != 0 {
|
|
|
s.Compact(scheduledCompact)
|
|
|
- plog.Printf("resume scheduled compaction at %d", scheduledCompact)
|
|
|
+
|
|
|
+ if s.lg != nil {
|
|
|
+ s.lg.Info(
|
|
|
+ "resume scheduled compaction",
|
|
|
+ zap.String("meta-bucket-name", string(metaBucketName)),
|
|
|
+ zap.String("meta-bucket-name-key", string(scheduledCompactKeyName)),
|
|
|
+ zap.Int64("scheduled-compact-revision", scheduledCompact),
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ plog.Printf("resume scheduled compaction at %d", scheduledCompact)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return nil
|