asynq
asynq copied to clipboard
[BUG] tasks before 8 AM are being counted towards the previous day
Describe the bug My scheduler program runs in the Asia/Shanghai time zone, and the asynq server also runs in the Asia/Shanghai environment. However, when I start it, I can see that the timestamps in the logs are not in the Asia/Shanghai time zone. I'm not sure if this is causing a problem: the scheduled tasks before 8 AM are being counted towards the previous day, which is not what I want to see.
To Reproduce Steps to reproduce the behavior (Code snippets if applicable):
- To start the scheduler in the Asia/Shanghai time zone
- Start the server
- Run a scheduled task before 8 AM
- View the statistical results on the web UI.
Expected behavior The task statistics after 8 AM are for the current day.
Screenshots If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: Linux
- Version of
asynq
package v0.22.1
Additional context Add any other context about the problem here.
Do you have reproducible code and screenshots?
I have same problem.
@xmwilldo thanks for reporting an issue.
Did you specify your timezone via SchedulerOpts.Location
?
If so, would you mind providing some code snippets to help me investigate further?
@hibiken Yes, I tried but it didn't work.
loc, _ := time.LoadLocation("Asia/Shanghai")
mgr, err := asynq.NewPeriodicTaskManager(
asynq.PeriodicTaskManagerOpts{
PeriodicTaskConfigProvider: &TrainPeriodicTaskProvider{
ctx: l.ctx,
svcCtx: l.svcCtx,
},
RedisConnOpt: asynq.RedisClientOpt{
Addr: l.svcCtx.Config.Redis.Host,
Password: l.svcCtx.Config.Redis.Pass,
DB: 10,
},
SchedulerOpts: &asynq.SchedulerOpts{
Location: loc,
},
SyncInterval: 10 * time.Second,
},
)
if err != nil {
log.Fatalf("could new PeriodicTaskManager: %v", err)
}
I have these scheduled tasks, each task executes at least ten sub-tasks, but the statistical results are as follows:
It's probably related to this one? https://github.com/hibiken/asynqmon/issues/295
UI shows everything in UTC so I think we need to open a FR to support different timezone in the UI.
This doesn't seem to matter, because the ui just shows the data in redis, and the data recorded in redis itself is wrong
like this
I see. We need to update these helpers to be timezone aware (currently always use UTC):
https://github.com/hibiken/asynq/blob/fde294be326a252f6fcb1d942c11c055bebeecfb/internal/base/base.go#L169-L172
https://github.com/hibiken/asynq/blob/fde294be326a252f6fcb1d942c11c055bebeecfb/internal/base/base.go#L174-L177
This may be a good first issue for someone's who's looking to contribute.
I would also like to participate, but this PR#683 already exists. Thanks!
is there any progress ?