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

[Scheduled Actions V2] WIP Common/util Package #6903

Closed
wants to merge 9 commits into from

Conversation

lina-temporal
Copy link
Contributor

@lina-temporal lina-temporal commented Nov 27, 2024

Based on #6901

What changed?

  • Added boilerplate dynamic config stuff
    • still incomplete, but I pulled over some of the most common parameters from existing scheduler DC
  • Added a few utility methods for the sched2 package

Why?

  • The utilities are referenced throughout the other PRs I'll be sending, so I'd like to have this available for reference (even though not terribly exciting on its own).

How did you test it?

  • New tests, go test -v

Potential risks

  • none

Documentation

Is hotfix candidate?

@lina-temporal lina-temporal changed the title sched2 common package WIP [Scheduled Actions V2] WIP Common/util Package Nov 27, 2024
@@ -0,0 +1,53 @@
package common
Copy link
Member

Choose a reason for hiding this comment

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

Same as the other PR, I'd put everything in the same package.

return nil
}

// Intended to be called with a substate machine's node. Returns a cloned copy
Copy link
Member

Choose a reason for hiding this comment

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

Use Go conventions for docstrings please.

Suggested change
// Intended to be called with a substate machine's node. Returns a cloned copy
// LoadSchedulerFromParent is intended to be called with a substate machine's node. Returns a cloned copy


// ValidateTask ensures that the given transition is possible with the current
// state machine state.
func ValidateTask[
Copy link
Member

Choose a reason for hiding this comment

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

I think this will generally be applicable but you should consider renaming to something that's more specific. This won't validate any task, just validate that a transition is valid for the given state.

return nil
}

// Generates a deterministic request ID for a buffered action's time. The request
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Generates a deterministic request ID for a buffered action's time. The request
// GenerateRequestID generates a deterministic request ID for a buffered action's time. The request

Also consider not exporting this unless called outside of this package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will fix. Most of these were public access from when I had them in separate packages, I'll give the package a full pass.

// automatically, based on the schedule spec. It must be set for backfills,
// as backfills may generate buffered actions that overlap with both
// automatically-buffered actions, as well as other requested backfills.
func GenerateRequestID(scheduler Scheduler, backfillID string, nominal, actual time.Time) string {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why this needs to be deterministic if you record the intent in the executor's buffer. I would verify that we even support request IDs that aren't UUIDs (we may, I'm just not 100% sure).

One reason that you may want this to be deterministic is to prevent too much diversion during split brain situations.

Copy link
Contributor Author

@lina-temporal lina-temporal Jan 2, 2025

Choose a reason for hiding this comment

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

Not sure why this needs to be deterministic if you record the intent in the executor's buffer.

I'd made this deterministic primarily before I learned that a timer task will execute while holding a write lock for the whole tree. However, I think it's still useful to avoid a situation where buffered starts are recorded, but the generator's high water mark isn't yet been updated, and the process crashes before that gets to happen (since they are written on separate sub state machines with distinct MachineTransitions). Is that the situation you were referring to with computing next wakeup time instead of caching?

I would verify that we even support request IDs that aren't UUIDs (we may, I'm just not 100% sure).

I'll look into this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(since they are written on separate sub state machines with distinct MachineTransitions).

Oops, been a couple weeks since I've had this in my head - since the transaction also encloses the whole timer task, I don't think they really need to be deterministic, but it'd still be helpful for resolution after a split brain situation.

@lina-temporal lina-temporal marked this pull request as ready for review January 6, 2025 23:07
@lina-temporal lina-temporal requested a review from a team as a code owner January 6, 2025 23:07
@lina-temporal lina-temporal requested a review from bergundy January 6, 2025 23:08
Base automatically changed from sched2_proto to main January 16, 2025 23:06
@lina-temporal
Copy link
Contributor Author

Closing, will be merged as part of #6905

lina-temporal added a commit that referenced this pull request Jan 17, 2025
## What changed?
- Added the Generator component, a sub-state machine of the top-level Scheduler
- PRs #6904 and #6903 are merged as part of this commit, as they are interdependent:
  - #6903
  - #6904

## Why?
* The generator generates buffered actions, and we want those!

## How did you test it?
- New tests, `go test -v`
stephanos pushed a commit to stephanos/temporal that referenced this pull request Jan 17, 2025
## What changed?
- Added the Generator component, a sub-state machine of the top-level Scheduler
- PRs temporalio#6904 and temporalio#6903 are merged as part of this commit, as they are interdependent:
  - temporalio#6903
  - temporalio#6904

## Why?
* The generator generates buffered actions, and we want those!

## How did you test it?
- New tests, `go test -v`
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