[GH-ISSUE #983] [BUG] Description of the bug #2497

Open
opened 2026-03-15 20:42:35 +03:00 by kerem · 0 comments
Owner

Originally created by @fucktx on GitHub (Dec 10, 2024).
Original GitHub issue: https://github.com/hibiken/asynq/issues/983

Originally assigned to: @hibiken, @kamikazechaser on GitHub.

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进来
Originally created by @fucktx on GitHub (Dec 10, 2024). Original GitHub issue: https://github.com/hibiken/asynq/issues/983 Originally assigned to: @hibiken, @kamikazechaser on GitHub. **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进来 ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#2497
No description provided.