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

fix: hard sticky strategy with no desired worker id #1186

Merged
merged 1 commit into from
Jan 14, 2025

Conversation

abelanger5
Copy link
Contributor

Description

In the case of stickyStrategy=HARD and no desired worker id set, step runs can't be scheduled. This PR modifies the behavior to assign to any available worker in this case.

We weren't seeing this behavior in most tests, because the workflows we were testing with stickyStrategy=HARD were child workflows spawned with sticky=True, where there's guaranteed to be a desired worker id.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Copy link

vercel bot commented Jan 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hatchet-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 14, 2025 4:13pm

Comment on lines 192 to +194
if qi.DesiredWorkerId.Valid && workerId == sqlchelpers.UUIDToStr(qi.DesiredWorkerId) {
validSlots.addSlot(slot, 0)
} else if !qi.DesiredWorkerId.Valid {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit (not blocking): can we use an or in the original condition? e.g.:

Suggested change
if qi.DesiredWorkerId.Valid && workerId == sqlchelpers.UUIDToStr(qi.DesiredWorkerId) {
validSlots.addSlot(slot, 0)
} else if !qi.DesiredWorkerId.Valid {
if (qi.DesiredWorkerId.Valid && workerId == sqlchelpers.UUIDToStr(qi.DesiredWorkerId)) || !qi.DesiredWorkerId.Valid {
validSlots.addSlot(slot, 0)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's better, though I think it makes it more difficult to reason about -- probably something like this would work best?

matchesDesired := qi.DesiredWorkerId.Valid && workerId == sqlchelpers.UUIDToStr(qi.DesiredWorkerId)
desiredNotSet := !qi.DesiredWorkerId.Valid

if matchesDesired || desiredNotSet {
  validSlots.addSlot(slot, 0)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that looks good to me 👍

@abelanger5 abelanger5 merged commit 75657a1 into main Jan 14, 2025
30 checks passed
@abelanger5 abelanger5 deleted the belanger/hard-sticky-strat branch January 14, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants