Skip to content

[Scheduler] Generator should respect MaxBufferSize#11072

Merged
lina-temporal merged 4 commits into
mainfrom
chasm-generator-buffer-limit
Jul 17, 2026
Merged

[Scheduler] Generator should respect MaxBufferSize#11072
lina-temporal merged 4 commits into
mainfrom
chasm-generator-buffer-limit

Conversation

@lina-temporal

Copy link
Copy Markdown
Contributor

What changed?

  • Generator should respect MaxBufferSize, as Backfiller does.

Why?

  • Otherwise, a contrived situation could cause it to continually grow, and eventually hit the CHASM-level MS limit.

How did you test it?

  • built
  • run locally and tested manually
  • covered by existing tests
  • added new unit test(s)
  • added new functional test(s)

Comment thread tests/schedule_test.go

// A full buffer (MaxBufferSize reached) makes the CHASM generator drop further
// fires and increment ScheduleInfo.BufferDropped.
func testBufferOverrunDropsActions(t *testing.T, newContext contextFactory) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this repro the issue seen in the wild? I didn't follow what the bug was

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Something I noticed from manual inspection. If someone had a BUFFER_ALL policy, and a short interval (like 1s), and actions that never completed, they could overrun this limit. What would happen in practice (pre-fix) is they'd hit the MS size limit and CHASM would terminate the execution. Backfiller already respects this.

# Conflicts:
#	chasm/lib/scheduler/generator_tasks_test.go
#	chasm/lib/scheduler/spec_processor.go

@davidporter-id-au davidporter-id-au left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, added a couple of questions but think I eventually answered them myself.

fmt.Sprintf("buffer overrun, dropped %d actions", result.DroppedCount))
logger.Warn("Buffer overrun, dropping actions",
tag.Int64("dropped-count", result.DroppedCount))
if scheduler.Info.BufferDropped == 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

? should this be greater than zero? I am confused as to what this is.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

oh, I guess this is: emitting metrics in the event that this particular drop occurs, whereas other drops are summed up below, but not subject to this warning.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's actually so that we only emit the log warning/event line once/the first time we start overrunning (the metric is always incremented). This is because, if someone has a case where the buffer overruns (e.g., the BUFFER_ALL w/ 1s w/ stuck workflows case I mention), they'll probably keep overrunning until an operator takes some action.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IIUC, this would only log on the first set of drops. If that's the case why do we want to do that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

uh, my view must have been stale.

(e.g., the BUFFER_ALL w/ 1s w/ stuck workflows case I mention), they'll probably keep overrunning until an operator takes some action.

So the worry is that it would drown out other event logs? Seems reasonable but could you add a comment?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So the worry is that it would drown out other event logs?

Yeah. Maybe it's worth it for completeness' sake? I'll keep the guard around the actual logger.Warn call because we don't need that spammed, at least.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's fine to keep the guard. If I read the log and only saw it once, I'd expect for the event execution to have only dropped this set of actions. Ideally the log would communicate "you'll only see this once per execution". It's also easy enough to look what's producing the log, so a code comment is fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

dealers choice though

Comment thread chasm/lib/scheduler/helper_test.go Outdated
}

// configWithTweakables returns defaultConfig with its Tweakables mutated by fn.
func configWithTweakables(fn func(*scheduler.Tweakables)) *scheduler.Config {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not a blocking opinion, but any reason to not just set directly?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

not a blocking opinion, but any reason to not just set directly?

Because we'd still need to construct the default config somewhere (for the other tweakable values) and transform it into the per-namespace accessor function. That said, I tidied it up so there's not a separate function for setting the config (since we only need to modify the tweakables).

@chaptersix chaptersix left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Forgot to submit my previous review. LGTM aside from the conditional check.

@lina-temporal
lina-temporal enabled auto-merge (squash) July 16, 2026 21:40
@lina-temporal
lina-temporal merged commit 5c5ae9e into main Jul 17, 2026
95 of 99 checks passed
@lina-temporal
lina-temporal deleted the chasm-generator-buffer-limit branch July 17, 2026 18:36
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