Skip to content

Commit

Permalink
fixup! Improved restore/sync logging
Browse files Browse the repository at this point in the history
  • Loading branch information
hifi committed Oct 13, 2023
1 parent d71d7a4 commit f3290fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ func (db *DB) execCheckpoint(mode string) (err error) {
if err := db.db.QueryRow(rawsql).Scan(&row[0], &row[1], &row[2]); err != nil {
return err
}
log.Printf("%s: checkpoint: mode=%v (%d,%d,%d)", db.path, mode, row[0], row[1], row[2])
db.Logger.Printf("%s: checkpoint: mode=%v (%d,%d,%d)", db.path, mode, row[0], row[1], row[2])

// Reacquire the read lock immediately after the checkpoint.
if err := db.acquireReadLock(); err != nil {
Expand Down
10 changes: 5 additions & 5 deletions replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (r *Replica) syncWAL(ctx context.Context) (err error) {
startTime := time.Now()
var bytesWritten int

log.Printf("%s(%s): write wal segment %s/%08x:%08x", r.db.Path(), r.Name(), initialPos.Generation, initialPos.Index, initialPos.Offset)
r.Logger.Printf("%s(%s): write wal segment %s/%08x:%08x", r.db.Path(), r.Name(), initialPos.Generation, initialPos.Index, initialPos.Offset)

// Copy through pipe into client from the starting position.
var g errgroup.Group
Expand Down Expand Up @@ -321,7 +321,7 @@ func (r *Replica) syncWAL(ctx context.Context) (err error) {
replicaWALIndexGaugeVec.WithLabelValues(r.db.Path(), r.Name()).Set(float64(rd.Pos().Index))
replicaWALOffsetGaugeVec.WithLabelValues(r.db.Path(), r.Name()).Set(float64(rd.Pos().Offset))

log.Printf("%s(%s): wal segment written %s/%08x:%08x elapsed=%s sz=%d", r.db.Path(), r.Name(), initialPos.Generation, initialPos.Index, initialPos.Offset, time.Since(startTime).String(), bytesWritten)
r.Logger.Printf("%s(%s): wal segment written %s/%08x:%08x elapsed=%s sz=%d", r.db.Path(), r.Name(), initialPos.Generation, initialPos.Index, initialPos.Offset, time.Since(startTime).String(), bytesWritten)
return nil
}

Expand Down Expand Up @@ -543,7 +543,7 @@ func (r *Replica) Snapshot(ctx context.Context) (info SnapshotInfo, err error) {
return wc.Close()
})

log.Printf("%s(%s): write snapshot %s/%08x", r.db.Path(), r.Name(), pos.Generation, pos.Index)
r.Logger.Printf("%s(%s): write snapshot %s/%08x", r.db.Path(), r.Name(), pos.Generation, pos.Index)
startTime := time.Now()

// Delegate write to client & wait for writer goroutine to finish.
Expand Down Expand Up @@ -742,14 +742,14 @@ func (r *Replica) snapshotter(ctx context.Context) {
nextSnapshot = 0
}

log.Printf("%s(%s): previous snapshot created at %s, next in %s", r.db.Path(), r.Name(), snapshot.CreatedAt.Format(time.RFC3339), nextSnapshot.String())
r.Logger.Printf("%s(%s): previous snapshot created at %s, next in %s", r.db.Path(), r.Name(), snapshot.CreatedAt.Format(time.RFC3339), nextSnapshot.String())

select {
case <-ctx.Done():
return
case <-time.After(nextSnapshot):
if _, err := r.Snapshot(ctx); err != nil && err != ErrNoGeneration {
log.Printf("%s(%s): snapshotter error: %s", r.db.Path(), r.Name(), err)
r.Logger.Printf("%s(%s): snapshotter error: %s", r.db.Path(), r.Name(), err)
}
}
}
Expand Down

0 comments on commit f3290fa

Please sign in to comment.