Core: Ensure reactivated view version uses correct timestamp#12821
Conversation
| changes.add(new MetadataUpdate.SetCurrentViewVersion(newVersionId)); | ||
| } | ||
|
|
||
| // Use the timestamp from the view version if it was added in current set of changes; |
There was a problem hiding this comment.
I would slightly update/simplify this to
// Use the timestamp from the view version if it was added in current set of changes;
// otherwise, use the current system time. This handles cases where the view version
- // was created in a past commit and is being re-activated.
+ // was set as current in the past and is being re-activated.
boolean versionAddedInThisChange =
- changes.stream()
- .anyMatch(
- change ->
- change instanceof MetadataUpdate.AddViewVersion
- && ((MetadataUpdate.AddViewVersion) change).viewVersion().versionId()
- == newVersionId);
-
- long timestamp =
- versionAddedInThisChange ? version.timestampMillis() : System.currentTimeMillis();
+ changes(MetadataUpdate.AddViewVersion.class)
+ .anyMatch(added -> added.viewVersion().versionId() == newVersionId);
this.historyEntry =
ImmutableViewHistoryEntry.builder()
- .timestampMillis(timestamp)
+ .timestampMillis(
+ versionAddedInThisChange ? version.timestampMillis() : System.currentTimeMillis())
.versionId(version.versionId())
.build();
There was a problem hiding this comment.
@nastra Thanks for the review! I'll apply the comments and raise a revision.
But some concerns I have right now is that the change breaks existing unit tests like
In
.setCurrentVersionId(2), it's in different builder and have no local changes, causing the activation of view version to set to current timestamp even though version 2 never set as current before. And in the comment, we are trying to say only view version was set as current in the past will use current ts.
There was a problem hiding this comment.
changing the unit test with the changes you have here in order to match the version-log that we compare against (we compare against a fixed timestamp defined in ValidViewMetadata.json) makes sense to me as this is a consequence of using the current time millis instead of the view version's time when setting the view version from 1 to 2 without actually adding view version 2 in the same builder.
Co-authored-by: Eduard Tudenhoefner <etudenhoefner@gmail.com>
nastra
left a comment
There was a problem hiding this comment.
LGTM, thanks @lliangyu-lin
Description