Skip to content

Conversation

@abelanger5
Copy link
Contributor

Description

Two small optimizations on the scheduler:

  • Increments the snapshot counter properly so that we only snapshot every 20 iterations (currently we snapshot every time)
  • Adds a wrapping context to the replenish method so we get errors if database reads are too slow

Type of change

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

@vercel
Copy link

vercel bot commented Oct 16, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
hatchet-docs Ready Ready Preview Comment Oct 16, 2025 5:55pm
hatchet-v0-docs Ready Ready Preview Comment Oct 16, 2025 5:55pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces two scheduler improvements: it wraps replenish calls with a timeout to surface slow DB reads, and it corrects snapshot counter behavior to avoid snapshotting on every iteration.

  • Wrap replenish with a 2s context timeout inside the ticker loop.
  • Increment the snapshot counter to control snapshot frequency.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +383 to +389
innerCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
err := s.replenish(innerCtx, true)

if err != nil {
s.l.Error().Err(err).Msg("error replenishing slots")
}
cancel()
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

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

The 2-second timeout is a magic number. Consider extracting it into a named constant or configuration (e.g., replenishTimeout) to make it easier to tune and document intent.

Copilot uses AI. Check for mistakes.

s.exts.ReportSnapshot(sqlchelpers.UUIDToStr(s.tenantId), in)

count++
Copy link
Contributor

Choose a reason for hiding this comment

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

😅

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.

3 participants