Skip to content

Commit

Permalink
Add a sleep in the defrag code
Browse files Browse the repository at this point in the history
  • Loading branch information
riendeau committed Jul 15, 2024
1 parent b433760 commit d7cf24e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions server/storage/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io"
"os"
"path/filepath"
"strconv"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -574,6 +575,12 @@ func (b *backend) defrag() error {
}

func defragdb(odb, tmpdb *bolt.DB, limit int) error {
if defragWaitStr := os.Getenv("HACK_DEFRAG_WAIT_SECONDS"); defragWaitStr != "" {
if defragWaitSeconds, err := strconv.Atoi(defragWaitStr); err != nil && defragWaitSeconds > 0 {
time.Sleep(time.Duration(defragWaitSeconds) * time.Second)
}
}

// open a tx on tmpdb for writes
tmptx, err := tmpdb.Begin(true)
if err != nil {
Expand Down

0 comments on commit d7cf24e

Please sign in to comment.