Skip to content

Fix panic when attempting to set default_timestamp_interval to 0#36853

Merged
peterdukelarsen merged 4 commits into
MaterializeInc:mainfrom
peterdukelarsen:pl/ss-147-thread-coordinator-panic
Jun 3, 2026
Merged

Fix panic when attempting to set default_timestamp_interval to 0#36853
peterdukelarsen merged 4 commits into
MaterializeInc:mainfrom
peterdukelarsen:pl/ss-147-thread-coordinator-panic

Conversation

@peterdukelarsen
Copy link
Copy Markdown
Contributor

@peterdukelarsen peterdukelarsen commented Jun 1, 2026

Motivation

Closes ss-147

Description

Adds a non-zero constraint to the "default_timestamp_interval" system parameter. This prevents an issue where setting it to 0 causes a panic and the database won't start up until you go in and update the parameter by different means.

Verification

  1. Reproduced the issue locally, updated code and confirmed we received an error instead of crashing when the ALTER ... statement is issued
  2. Added basic sqllogictest tests

@peterdukelarsen peterdukelarsen requested a review from a team as a code owner June 1, 2026 20:03
@peterdukelarsen peterdukelarsen requested a review from ublubu June 1, 2026 20:08
Copy link
Copy Markdown
Contributor

@ublubu ublubu left a comment

Choose a reason for hiding this comment

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

Looks good. It does give me a new question, though. (inline)

Comment thread src/sql/src/session/vars/constraints.rs Outdated
Comment on lines +127 to +131
if d.is_zero() {
Err(VarError::InvalidParameterValue {
name: var.name(),
invalid_values: vec![format!("{:?}", d)],
reason: "only supports durations greater than zero".to_string(),
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.

It looks a little weird to is_zero() and then say greater than zero. I had to double-check that Duration can't be negative 😅

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.

Ah whoops, I'll change this to "only supports non-zero durations" - I had originally named this struct PositiveDuration which I later realized was a little weird/redundant given Durations are never negative. But then I forgot to update this reason field.

simple conn=mz_system,user=mz_system
ALTER SYSTEM SET default_timestamp_interval = '-1';
----
db error: ERROR: parameter "default_timestamp_interval" requires a "duration" value
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 realize this isn't a regression, but this error message is interesting, especially given that the above tests use values like 1 and 0, which don't appear to be durations either.

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.

Poked around here a bit, and it looks like default unit for a Duration in our parsing logic is "ms", see here:

// Default unit is milliseconds
"ms" | "" => (Duration::from_millis, 1),
.

This seems to be consistent across durations, but is documented on a per-field level. I.e. see docs for "idle_in_transaction_session_timeout" under https://materialize.com/docs/sql/alter-system-set/.

Discussed offline that this may also align with postgres.

@peterdukelarsen peterdukelarsen merged commit 2b5b078 into MaterializeInc:main Jun 3, 2026
117 checks passed
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