db: migrate client_reports table to new times#4373
Merged
tgeoghegan merged 2 commits intomainfrom Feb 24, 2026
Merged
Conversation
1e3fc83 to
6de7119
Compare
Base automatically changed from
timg/datastore-time-precision-tasks-table
to
main
February 20, 2026 22:06
cd4e188 to
4f5c305
Compare
Store client timestamps in time precision units in the `client_reports` table. This requires temporarily disabling some tests until the `collection_jobs` table also gets migrated; see comments for discussion. Part of #4206
4f5c305 to
72be386
Compare
divergentdave
approved these changes
Feb 24, 2026
aggregator_core/src/datastore.rs
Outdated
| now: DateTime<Utc>, | ||
| ) -> Result<Timestamp<DateTime<Utc>>, Error> { | ||
| self.report_expiry_threshold_internal(now).map( | ||
| |report_expiry_age| match report_expiry_age { |
Collaborator
There was a problem hiding this comment.
I think this variable name is misleading, since this is a time and not a duration. (same in the next method)
Suggested change
| |report_expiry_age| match report_expiry_age { | |
| |threshold| match threshold { |
aggregator_core/src/datastore.rs
Outdated
|
|
||
| /// Like [`Self::report_expiry_threshold`], but the value returned is a number of time precision | ||
| /// units instead of a timestamp, so that it can be compared against database columns that store | ||
| /// values in that unit. The represented time is at least as long as the report expiry threshold |
Collaborator
There was a problem hiding this comment.
nit: clarity
Suggested change
| /// values in that unit. The represented time is at least as long as the report expiry threshold | |
| /// values in that unit. The represented time is at least as long ago as the report expiry threshold |
Suggested change
| /// values in that unit. The represented time is at least as long as the report expiry threshold | |
| /// values in that unit. The represented time is at least as old as the report expiry threshold |
jcjones
approved these changes
Feb 24, 2026
aggregator_core/src/datastore.rs
Outdated
| |report_expiry_age| match report_expiry_age { | ||
| Some(t) => Time::from_date_time(t, self.time_precision) | ||
| .as_signed_time_precision_units() | ||
| .map_err(|e| Error::User(e.into())), |
Contributor
There was a problem hiding this comment.
User doesn't seem appropriate here:
/// An arbitrary error returned from the user callback; unrelated to DB internals. This error
/// will never be generated by the datastore library itself.
Perhaps Message?
Suggested change
| .map_err(|e| Error::User(e.into())), | |
| .map_err(Error::Message), |
Contributor
Author
There was a problem hiding this comment.
Yep, I got lazy there. I went with Error::TimeOverflow.
aggregator_core/src/datastore.rs
Outdated
| Some(t) => Time::from_date_time(t, self.time_precision) | ||
| .as_signed_time_precision_units() | ||
| .map_err(|e| Error::User(e.into())), | ||
| // Return a time in the distant past |
Contributor
There was a problem hiding this comment.
"distant past" always seems like it would be ... more distant than the epoch imo
Suggested change
| // Return a time in the distant past | |
| // No expiry, so return the epoch. |
aggregator_core/src/datastore.rs
Outdated
Comment on lines
5776
to
5777
| /// values in that unit. The represented time is at least as long as the report expiry threshold | ||
| /// in seconds. |
Contributor
There was a problem hiding this comment.
"at least as long..." is kinda confusing to me. Consider:
Suggested change
| /// values in that unit. The represented time is at least as long as the report expiry threshold | |
| /// in seconds. | |
| /// values in that unit. Due to rounding down to the nearest time precision unit, | |
| /// the threshold may be up to one time precision earlier than the raw | |
| /// calculated threshold. |
jcjones
approved these changes
Feb 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Store client timestamps in time precision units in the
client_reportstable. This requires temporarily disabling some tests until thecollection_jobstable also gets migrated; see comments for discussion.Part of #4206