Skip to content

Remove the old timestamp selection - #34712

Merged
ggevay merged 5 commits into
MaterializeInc:mainfrom
ggevay:remove-old-timestamp-selection
Mar 8, 2026
Merged

ggevay merged 5 commits into
MaterializeInc:mainfrom
ggevay:remove-old-timestamp-selection

Conversation

@ggevay

@ggevay ggevay commented Jan 15, 2026 •

Copy link
Copy Markdown
Contributor

The first commit removes the old timestamp selection, as discussed here: https://materializeinc.slack.com/archives/C08A62E0751/p1767794273757089?thread_ts=1764865885.225539&cid=C08A62E0751

The second commit updates a bunch of tests and fixes the error message when we don't find a suitable timestamp: Both the old and the new timestamp selection were relying on generate_timestamp_not_valid_error_msg, but that doesn't work well for the new timestamp selection for AS OF queries: the candidate comes out not as the AS OF time, so

SELECT * FROM t AS OF 1

would regress from

Timestamp (1) is not valid for all inputs: [u1]

to

Timestamp (1768481949666) is not valid for all inputs: []

which does not make sense: The [] is the list of inputs that this timestamp is not valid for, so we can see that actually this timestamp is valid for all inputs. But the problem here is not that this timestamp is not valid for an input, but the problem is the AS OF, which is not mentioned by the error msg.

So, the PR makes the error message print the constraints instead. It also tweaks the formatting of constraints a bit, to use more user-facing terminology, e.g., instead of ComputeInput we now say Indexed input. So, now we have stuff like:

select * from t AS OF 7;

ERROR:  could not find a valid timestamp for the query
DETAIL:  Constraints:
lower:
  (Storage inputs: [u1]): [1768492534743 (2026-01-15 15:55:34.743)]
upper:
  (Query's AS OF): [            7 (1970-01-01 00:00:00.007)]

Edit: I'm still fighting with a lot of annoying test output rewrites. Edit 2: Nightly is green. https://buildkite.com/materialize/nightly/builds/14740

@ggevay ggevay added the A-ADAPTER Topics related to the ADAPTER layer label Jan 15, 2026
@ggevay
ggevay force-pushed the remove-old-timestamp-selection branch 12 times, most recently from ece50ad to e5b7d27 Compare January 15, 2026 15:53
@ggevay
ggevay marked this pull request as ready for review January 15, 2026 15:56
@ggevay
ggevay requested review from a team as code owners January 15, 2026 15:56
@ggevay
ggevay requested a review from aljoscha January 15, 2026 15:56
@ggevay
ggevay force-pushed the remove-old-timestamp-selection branch 4 times, most recently from f39cf63 to 1cc5929 Compare January 16, 2026 16:10

@def- def- 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.

I like removing code!

# -----
# Others (ordered by name)
"allow_real_time_recency": "true",
"constraint_based_timestamp_selection": "verify",

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.

We might want to keep this for older versions

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.

Yes, I've added it back.

@ggevay
ggevay force-pushed the remove-old-timestamp-selection branch 5 times, most recently from 319a8be to 4ddb963 Compare January 18, 2026 14:48

@aljoscha aljoscha 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.

Changes look good, but I had a comment about naming that we might want to change. And about the lifetime of comments.

Reason::ComputeInput(ids) => {
let formatted: Vec<_> =
ids.iter().map(|(c, g)| format!("({}, {})", c, g)).collect();
write!(f, "Indexed inputs: [{}]", formatted.join(", "))

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 I get where you're coming from, but before we at least had the symmetry of "Storage inputs" and "Compute Inputs". And I'm not 100 % sure that a compute input is always an indexed input, or that this will stay true in the future.

@ggevay ggevay Jan 19, 2026 •

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.

I'm fairly certain that currently it's always an indexed input: It comes from CollectionIdBundle::compute_ids, whose comment is /// The identifiers for indexes in the compute layer..

My problem with "Compute Inputs" is that this phrase does not tell much to users, in that they probably don't realize that it's an index. I would feel a little bad to print this in a non-understandable way because of a future possibility of introducing some other thing here later.

How about I add a comment on CollectionIdBundle::compute_ids and Reason::ComputeInput that if this ever changes to include other things than indexes, then we should update the printing of Reason::ComputeInput?

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.

@aljoscha, what do you think?

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.

I've added the code comment, and merging the PR. We can get back to this later if needed.

}
},
"when": "AtLeastTimestamp:13",
"instance": "s1"

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.

Why did the "instance" output go away here?

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 not an output, but an input to the test. It went away because:

  • this json mirrors the Determine struct in src/adapter/tests/timestamp_selection.rs, and I removed the instance field from that struct.
  • And the reason for that is that the determine_timestamp_for call in test_timestamp_selection no longer needs it, because I removed the compute_instance argument of determine_timestamp_for.
  • And the reason I removed that is that it was only used by the generate_timestamp_not_valid_error_msg call, which I completely removed, and instead using the constraints in the error message.

@ggevay
ggevay force-pushed the remove-old-timestamp-selection branch from 4ddb963 to 7549684 Compare January 19, 2026 14:43
@ggevay
ggevay force-pushed the remove-old-timestamp-selection branch from 7549684 to 625d540 Compare March 8, 2026 15:46
@ggevay
ggevay enabled auto-merge (squash) March 8, 2026 15:47
@ggevay
ggevay merged commit b0ce85a into MaterializeInc:main Mar 8, 2026
1 check passed
def- added a commit to def-/materialize that referenced this pull request Mar 9, 2026
antiguru pushed a commit to antiguru/materialize that referenced this pull request Mar 26, 2026
The first commit removes the old timestamp selection, as discussed here:
https://materializeinc.slack.com/archives/C08A62E0751/p1767794273757089?thread_ts=1764865885.225539&cid=C08A62E0751

The second commit updates a bunch of tests and fixes the error message
when we don't find a suitable timestamp: Both the old and the new
timestamp selection were relying on
`generate_timestamp_not_valid_error_msg`, but that doesn't work well for
the new timestamp selection for `AS OF` queries: the candidate comes out
not as the `AS OF` time, so
```
SELECT * FROM t AS OF 1
```
would regress from
```
Timestamp (1) is not valid for all inputs: [u1]
```
to
```
Timestamp (1768481949666) is not valid for all inputs: []
```
which does not make sense: The `[]` is the list of inputs that this
timestamp is not valid for, so we can see that actually this timestamp
is valid for all inputs. But the problem here is not that this timestamp
is not valid for an input, but the problem is the `AS OF`, which is not
mentioned by the error msg.

So, the PR makes the error message print the constraints instead. It
also tweaks the formatting of constraints a bit, to use more user-facing
terminology, e.g., instead of `ComputeInput` we now say `Indexed input`.
So, now we have stuff like:
```
select * from t AS OF 7;

ERROR:  could not find a valid timestamp for the query
DETAIL:  Constraints:
lower:
  (Storage inputs: [u1]): [1768492534743 (2026-01-15 15:55:34.743)]
upper:
  (Query's AS OF): [            7 (1970-01-01 00:00:00.007)]
```

~**Edit:** I'm still fighting with a lot of annoying test output
rewrites.~ **Edit 2:** Nightly is green.
https://buildkite.com/materialize/nightly/builds/14740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ADAPTER Topics related to the ADAPTER layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants