Skip to content

Commit

Permalink
Fix (third time!) how session modified_on is checked for session wait…
Browse files Browse the repository at this point in the history
… expirations and timeouts
  • Loading branch information
rowanseymour committed Jan 29, 2025
1 parent 9941120 commit 27b9a32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/tasks/handler/ctasks/wait_expiration.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (t *WaitExpirationTask) Perform(ctx context.Context, rt *runtime.Runtime, o
log.Debug("skipping as waiting session has changed")
return nil
}
if !equalToMillis(session.ModifiedOn(), t.ModifiedOn) {
if !equalTime(session.ModifiedOn(), t.ModifiedOn) {
log.Debug("skipping as session has been modified since", "session_modified_on", session.ModifiedOn(), "task_modified_on", t.ModifiedOn)
return nil
}
Expand All @@ -72,6 +72,6 @@ func (t *WaitExpirationTask) Perform(ctx context.Context, rt *runtime.Runtime, o
}

// helper to compare two times with millisecond precision - used to compare times that have been in and out of the database
func equalToMillis(t1, t2 time.Time) bool {
return t1.Round(time.Millisecond).Equal(t2.Round(time.Millisecond))
func equalTime(t1, t2 time.Time) bool {
return t1.UnixMilli() == t2.UnixMilli()
}
2 changes: 1 addition & 1 deletion core/tasks/handler/ctasks/wait_timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (t *WaitTimeoutTask) Perform(ctx context.Context, rt *runtime.Runtime, oa *
log.Debug("skipping as waiting session has changed")
return nil
}
if !equalToMillis(session.ModifiedOn(), t.ModifiedOn) {
if !equalTime(session.ModifiedOn(), t.ModifiedOn) {
log.Debug("skipping as session has been modified since", "session_modified_on", session.ModifiedOn(), "task_modified_on", t.ModifiedOn)
return nil
}
Expand Down

0 comments on commit 27b9a32

Please sign in to comment.