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

"open file failed" when dump path does not exist #89

Closed
zhangqibupt opened this issue Mar 29, 2022 · 5 comments
Closed

"open file failed" when dump path does not exist #89

zhangqibupt opened this issue Mar 29, 2022 · 5 comments
Assignees

Comments

@zhangqibupt
Copy link

zhangqibupt commented Mar 29, 2022

When using dump path that does not exist, for example

holmes.WithDumpPath("./tmp"),

Expected behavior:
The goroutine should be dumped successfully.

Current behavior:
Will encounter error like

2022-03-29 17:07:06,609 [ERROR] failed to write profile to file(tmp/goroutine..20220329170706.609.log), err: pprof goroutine open file failed : open tmp/goroutine..20220329170706.609.log: no such file or directory

Source Code

package main

import (
	"fmt"
	"runtime"
	"time"

	"mosn.io/holmes"
	mlog "mosn.io/pkg/log"
)

func main() {
	logger := holmes.NewStdLogger()
	logger.SetLogLevel(mlog.INFO)

	h, _ := holmes.New(
		holmes.WithCollectInterval("1s"),

		holmes.WithTextDump(),
		holmes.WithDumpPath("./tmp"),
		// dump will happen when current_goroutine_num > 500 && current_goroutine_num < 1500
		holmes.WithGoroutineDump(500, 0, 500, 1500, 40*time.Second),
		holmes.WithLogger(logger),
	)
	h.EnableGoroutineDump()
	h.Start()

	spawnGoroutine(490)

	for {
		fmt.Println(time.Now(), "Number of goroutines:", runtime.NumGoroutine())
		spawnGoroutine(10)
		time.Sleep(10 * time.Second)
	}
}

func spawnGoroutine(n int64) {
	for i := int64(0); i < n; i++ {
		go func() {
			time.Sleep(500 * time.Minute)
		}()
	}
}

go.mod

module test_holmes

go 1.16

require (
	mosn.io/holmes v1.0.0
	mosn.io/pkg v0.0.0-20211217101631-d914102d1baf
)
@doujiang24
Copy link
Member

Thanks for your report. Could you help to create a PR for it?

Or, do you guys are interested to fix it? @Jun10ng @songzhibin97

@songzhibin97 songzhibin97 self-assigned this Mar 29, 2022
@Jun10ng
Copy link
Contributor

Jun10ng commented Mar 31, 2022

我今天也遇到这个问题了,感觉也有许多用户会遇到。MR签入master后,是否考虑发个小版本呢?
@doujiang24

@Howie59
Copy link

Howie59 commented Mar 31, 2022

也遇到了这个

@doujiang24
Copy link
Member

我今天也遇到这个问题了,感觉也有许多用户会遇到。MR签入master后,是否考虑发个小版本呢? @doujiang24

嗯,可以搞个小版本的

@doujiang24
Copy link
Member

发布了 v1.1.0,包含了这个 bug 的修复,欢迎测试反馈~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants