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

Kill mount process and dump its stack when mount point is not ready in time #5171

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions cmd/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import (
"github.com/juicedata/juicefs/pkg/vfs"
)

var mountPid int

func showThreadStack(agentAddr string) {
if agentAddr == "" {
return
Expand Down Expand Up @@ -224,10 +226,15 @@ func checkMountpoint(name, mp, logPath string, background bool) {
_ = os.Stdout.Sync()
}
_, _ = os.Stdout.WriteString("\n")
mountDesc := "mount process is not started yet"
if mountPid != 0 {
mountDesc = fmt.Sprintf("tried to kill mount process %d", mountPid)
_ = syscall.Kill(mountPid, syscall.SIGABRT) // Kill and show stack trace
}
if background {
logger.Fatalf("The mount point is not ready in %d seconds, please check the log (%s) or re-mount in foreground", mountTimeOut, logPath)
logger.Fatalf("The mount point is not ready in %d seconds (%s), please check the log (%s) or re-mount in foreground", mountTimeOut, mountDesc, logPath)
} else {
logger.Fatalf("The mount point is not ready in %d seconds, exit it", mountTimeOut)
logger.Fatalf("The mount point is not ready in %d seconds (%s), exit it", mountTimeOut, mountDesc)
}
}

Expand Down Expand Up @@ -759,6 +766,7 @@ func launchMount(mp string, conf *vfs.Config) error {
}
}

mountPid = 0
cmd := exec.Command(path, os.Args[1:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
Expand All @@ -770,6 +778,7 @@ func launchMount(mp string, conf *vfs.Config) error {
continue
}
os.Unsetenv("_FUSE_STATE_PATH")
mountPid = cmd.Process.Pid

ctx, cancel := context.WithCancel(context.TODO())
go watchdog(ctx, mp)
Expand All @@ -790,6 +799,7 @@ func launchMount(mp string, conf *vfs.Config) error {
logger.Info("transfer FUSE session to others")
return nil
}
logger.Errorf("mount process %d: %s, will restart in 1 second", mountPid, err)
time.Sleep(time.Second)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/chunk/disk_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (cache *cacheStore) createDir(dir string) {
cache.createDir(filepath.Dir(dir))
}
_ = os.Mkdir(dir, mode)
// umask may remove some permisssions
// umask may remove some permissions
return os.Chmod(dir, mode)
} else if strings.HasPrefix(dir, cache.dir) && err == nil && st.Mode() != mode {
changeMode(dir, st, mode)
Expand Down
Loading