Skip to content

db: migrate client_reports table to new times#4373

Merged
tgeoghegan merged 2 commits intomainfrom
timg/datastore-time-precision-client-reports-table
Feb 24, 2026
Merged

db: migrate client_reports table to new times#4373
tgeoghegan merged 2 commits intomainfrom
timg/datastore-time-precision-client-reports-table

Conversation

@tgeoghegan
Copy link
Contributor

@tgeoghegan tgeoghegan commented Feb 20, 2026

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

@tgeoghegan tgeoghegan added the allow-changed-migrations Override the ci-migrations check to allow migrations that have changed. label Feb 20, 2026
@tgeoghegan tgeoghegan force-pushed the timg/datastore-time-precision-tasks-table branch from 1e3fc83 to 6de7119 Compare February 20, 2026 21:39
Base automatically changed from timg/datastore-time-precision-tasks-table to main February 20, 2026 22:06
@tgeoghegan tgeoghegan force-pushed the timg/datastore-time-precision-client-reports-table branch from cd4e188 to 4f5c305 Compare February 24, 2026 00:22
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
@tgeoghegan tgeoghegan force-pushed the timg/datastore-time-precision-client-reports-table branch from 4f5c305 to 72be386 Compare February 24, 2026 18:47
@tgeoghegan tgeoghegan marked this pull request as ready for review February 24, 2026 18:48
@tgeoghegan tgeoghegan requested a review from a team as a code owner February 24, 2026 18:48
now: DateTime<Utc>,
) -> Result<Timestamp<DateTime<Utc>>, Error> {
self.report_expiry_threshold_internal(now).map(
|report_expiry_age| match report_expiry_age {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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 {


/// 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
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Contributor

@jcjones jcjones left a comment

Choose a reason for hiding this comment

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

approved with nits

|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())),
Copy link
Contributor

Choose a reason for hiding this comment

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

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),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I got lazy there. I went with Error::TimeOverflow.

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
Copy link
Contributor

Choose a reason for hiding this comment

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

"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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

"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.

@tgeoghegan tgeoghegan enabled auto-merge (squash) February 24, 2026 22:19
@tgeoghegan tgeoghegan merged commit 9893837 into main Feb 24, 2026
8 checks passed
@tgeoghegan tgeoghegan deleted the timg/datastore-time-precision-client-reports-table branch February 24, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-changed-migrations Override the ci-migrations check to allow migrations that have changed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants