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

创建按日和按月结合的定时任务,cpu会出现使用率占满的情况 #52

Open
Gerrylinux opened this issue Dec 24, 2020 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@Gerrylinux
Copy link

Gerrylinux commented Dec 24, 2020

创建的任务时间。
刚创建成功后,master 服务的cpu会立马占用所有资源
将任务设置停止调度时,cpu会占用在170%左右。
删除该任务,cpu资源立马释放。

image
image
image

@Gerrylinux Gerrylinux added the bug Something isn't working label Dec 24, 2020
@Gerrylinux Gerrylinux changed the title 创建4个任务,服务cpu 占用 170%,4个任务是克隆出来的结果。 创建按日和按月结合的定时任务,cpu会出现使用率占满的情况 Dec 24, 2020
@labulakalia
Copy link
Owner

你上面那个图没选日月吗。右边的最近运行时间全是相同的

@Gerrylinux
Copy link
Author

选了日和月,6月和12月的15日运行,没选周,年是每年。

@labulakalia
Copy link
Owner

@Gerrylinux 能发下最后生成的完整cronexpr表达式吗?在选择日期的右边是最近运行的时间,我看你那个图最近运行的时间都是相同的,可能某些地方有bug。你先发给我看下吧

@Gerrylinux
Copy link
Author

image
这个可以看出来嘛?
目前master服务 只要启动后,就会出现cpu 异常,所以没有启动服务。

@labulakalia
Copy link
Owner

日志里有error吗

@Gerrylinux
Copy link
Author

这是启动后的error 日志。
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:564 t.islock failed {"error": "redis: connection pool timeout"}
2020-12-30T12:02:33.312+0800 error schedule/schedule2.go:517 redis.SetNX failed {"error": "redis: connection pool timeout"}
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:517 redis.SetNX failed {"error": "redis: connection pool timeout"}
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:548 redis.Exists failed {"key": "running:348519839943364608", "error": "redis: connection pool timeout"}
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:581 t.getlock failed {"error": "redis: connection pool timeout"}
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:581 t.getlock failed {"error": "redis: connection pool timeout"}
2020-12-30T12:02:33.312+0800 error schedule/schedule2.go:548 redis.Exists failed {"key": "running:348519839943364608", "error": "redis: connection pool timeout"}
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:564 t.islock failed {"error": "redis: connection pool timeout"}
2020-12-30T12:02:33.313+0800 error schedule/schedule2.go:564 t.islock failed {"error": "redis: connection pool timeout"}

@Gerrylinux
Copy link
Author

redis 测试后可连接的,这块导致 把服务器 cpu资源全部占用

@labulakalia
Copy link
Owner

如果redis正常不会产生timeout,你用 telnet 127.0.0.1 6379 后输入ping 看下是不是有返回Pong

@Gerrylinux
Copy link
Author

这个redis的日志错误和cpu 资源耗尽,是新部署后的大约四五天的时间,晚上12点整,突然暴增,
我继续排查相关服务的问题。目前是将master服务通过二进制的方式在服务器部署启动,redis 使用的是 本地 服务,脱离的docker。

@Gerrylinux
Copy link
Author

之前采用容器化部署后产生的问题,这次更换成二进制后,运行了2天,暂时没有发现问题。

@rinyshen
Copy link

请问是否在生产环境使用

@Nuoky
Copy link

Nuoky commented Dec 19, 2022

00 22 18 19 12 ? 2022-2022
只要设置的计划时间是已过期貌似就会疯狂推任务,这种情况一般都是年份固定的情况

@Nuoky
Copy link

Nuoky commented Dec 19, 2022

调试了下,发现以下问题;不过不太熟Golang... 不知道作者还维护么

# schedule2.go

	for {
		next = expr.Next(last)
		select {
		case <-task.close:
			log.Info("close task Schedule", zap.String("taskid", taskid), zap.Any("name", task.name))
			return
		case <-time.After(next.Sub(last)):
			// 这里会无限循环, next 时间是 0,被赋值到了 last 导致时间为 0
			last = next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants