Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gc: fix the issue that objects may be deleted by mistake in large systems #5068

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cmd/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ func gc(ctx *cli.Context) error {
if (delete || compact) && threads <= 0 {
logger.Fatal("threads should be greater than 0 to delete or compact objects")
}
maxMtime := time.Now().Add(time.Hour * -1)
strDuration := os.Getenv("JFS_GC_SKIPPEDTIME")
if strDuration != "" {
iDuration, err := strconv.Atoi(strDuration)
if err == nil {
maxMtime = time.Now().Add(time.Second * -1 * time.Duration(iDuration))
} else {
logger.Errorf("parse JFS_GC_SKIPPEDTIME=%s: %s", strDuration, err)
}
}

var wg sync.WaitGroup
var delSpin *utils.Bar
Expand Down Expand Up @@ -262,16 +272,6 @@ func gc(ctx *cli.Context) error {
compacted := progress.AddDoubleSpinnerTwo("Compacted objects", "Compacted data")
leaked := progress.AddDoubleSpinnerTwo("Leaked objects", "Leaked data")
skipped := progress.AddDoubleSpinnerTwo("Skipped objects", "Skipped data")
maxMtime := time.Now().Add(time.Hour * -1)
strDuration := os.Getenv("JFS_GC_SKIPPEDTIME")
if strDuration != "" {
iDuration, err := strconv.Atoi(strDuration)
if err == nil {
maxMtime = time.Now().Add(time.Second * -1 * time.Duration(iDuration))
} else {
logger.Errorf("parse JFS_GC_SKIPPEDTIME=%s: %s", strDuration, err)
}
}

var leakedObj = make(chan string, 10240)
for i := 0; i < threads; i++ {
Expand Down
Loading