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

[BUG] Description of the bug #983

Open
fucktx opened this issue Dec 10, 2024 · 0 comments
Open

[BUG] Description of the bug #983

fucktx opened this issue Dec 10, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@fucktx
Copy link

fucktx commented Dec 10, 2024

Describe the bug
A clear and concise description of what the bug is.

Environment (please complete the following information):

  • OS: Window
  • asynq package version v0.25.0
  • Redis/Valkey version
func NewSchedulerFromRedisClient(c redis.UniversalClient, opts *SchedulerOpts) *Scheduler {
	if opts == nil {
		opts = &SchedulerOpts{}
	}

	logger := log.NewLogger(opts.Logger)
	loglevel := opts.LogLevel
	if loglevel == level_unspecified {
		loglevel = InfoLevel
	}
	logger.SetLevel(toInternalLogLevel(loglevel))

	loc := opts.Location
	if loc == nil {
		loc = time.UTC
	}

	return &Scheduler{
		id:              generateSchedulerID(),
		state:           &serverState{value: srvStateNew},
		logger:          logger,
		client:          NewClientFromRedisClient(c),
		rdb:             rdb.NewRDB(c),
		cron:            cron.New(cron.WithLocation(loc)),
		location:        loc,
		done:            make(chan struct{}),
		preEnqueueFunc:  opts.PreEnqueueFunc,
		postEnqueueFunc: opts.PostEnqueueFunc,
		errHandler:      opts.EnqueueErrorHandler,
		idmap:           make(map[string]cron.EntryID),
	}
}


启动程序每次都生成一个新的id,

[
  {
    "value": "asynq:schedulers:{xiaohan-pc:19320:dbf10ff6-b012-4ef4-87f7-e0ef7633c555}",
    "score": 1733838003
  },
  {
    "value": "asynq:schedulers:{xiaohan-pc:14716:3aa2ad57-c155-4170-8e24-a4f4e80b614f}",
    "score": 1733838337
  },
  {
    "value": "asynq:schedulers:{xiaohan-pc:17504:8eec0b10-68cc-439a-8733-4a5070da102a}",
    "score": 1733838348
  }
]

重启异常关闭,但是这个任务不会删除,长期重新部署任务的时候,这个key可能会越来越多,因为,是不是在NewScheduler 的时候是否可以考虑传递一个id进来
@fucktx fucktx added the bug Something isn't working label Dec 10, 2024
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

3 participants