Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: failing test est_restore_by_datetime #2000

Closed
wants to merge 8 commits into from

Conversation

r3stl355
Copy link
Contributor

@r3stl355 r3stl355 commented Dec 29, 2023

Description

This started as a fix for the issue occurring on CI Mac only. Turns out it is not Mac only but could also happen in other systems if commit takes more than a millisecond. Fix changes the following:

  1. Previous logic: get_version_timestamp would get the timestamp from the last_modified property of the log entry file
  2. New logic: get_version_timestamp will first attempt to get the timestamp from CommitInfo and will revert to previous logic of getting the timestamp from file's last_modified if CommitInfo does not contain a timestamp. This will also help restoring a correct version for tables which get copied to a different location (e.g. for in case of DR)

Related Issue(s)

#1925

Signed-off-by: Nikolay Ulmasov <[email protected]>
@github-actions github-actions bot added binding/rust Issues for the Rust crate crate/core labels Dec 29, 2023
Signed-off-by: Nikolay Ulmasov <[email protected]>
@r3stl355
Copy link
Contributor Author

It wasn't meant to pass the CI 🤦 as I'm still trying to trace but I think I know where the issue is - during the version search a blank table is initiated which has no timestamp stored and get_version_timestamp is called on it which ends up retrieving the timestamp from the file which I believe leads to an issue.
I'll do further tests in my GitHub, will be faster and less noisy

@r3stl355 r3stl355 marked this pull request as draft December 29, 2023 17:58
@r3stl355 r3stl355 marked this pull request as ready for review December 30, 2023 15:47
@r3stl355
Copy link
Contributor Author

@ion-elgreco are you able to start the workflows here?

@r3stl355
Copy link
Contributor Author

There is good in every bad - different tests are failing now. Of course I didn't run them locally 🤦

@github-actions github-actions bot added the binding/python Issues for the Python package label Dec 31, 2023
@r3stl355
Copy link
Contributor Author

Hmm, this was unexpected overflow failure here but it is only a problem with the test itself, not the library.

Looks like utime::set_file_times is expecting timestamp in seconds whereas our timestamps are in millis (for some reason it only broke on Windows).

.await?;
let ts = meta.last_modified.timestamp_millis();
// Load the version specified
if self.version() != version {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of loading the version each time, we could also just do this

self.state.commit_infos().get(version).unwrap().timestamp

Copy link
Member

Choose a reason for hiding this comment

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

@ion-elgreco Setting aside the concerns I have shared with reliance on commitInfo, I believe that invocation is not guaranteed to return the right versioned information if the version has not been loaded already.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just think aloud here but in general you shouldn't be able to restore to a version of a table that's above the current loaded table version

Comment on lines +649 to +650
let timestamp: Option<i64> = if !self.state.commit_infos().is_empty() {
self.state.commit_infos().last().unwrap().timestamp
Copy link
Member

Choose a reason for hiding this comment

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

This is a concept I've discussed with @ion-elgreco in Slack a bit. The value of the commitInfo is not governed by the protocol and therefore any timestamp field should not be relied upon for anything.

Since the protocol doesn't dictate the format here, this could be epoch, or any other random timestmap and we have no guarantees other than Delta/Spark's convention that it will actually represent the timestamp of the last written version.

All that said, I like that this is a sort of guarded optimization, I'm really not sure how to make this much safer though 🤔

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we just check the clientVersion and only take the timestamp from engines that we know use timestamp defined in the same format

.await?;
let ts = meta.last_modified.timestamp_millis();
// Load the version specified
if self.version() != version {
Copy link
Member

Choose a reason for hiding this comment

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

@ion-elgreco Setting aside the concerns I have shared with reliance on commitInfo, I believe that invocation is not guaranteed to return the right versioned information if the version has not been loaded already.

let ts = meta.last_modified.timestamp_millis();
// Load the version specified
if self.version() != version {
self.load_version(version).await?;
Copy link
Member

Choose a reason for hiding this comment

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

@r3stl355 I am not as familiar with the callers of get_version_timestamp but this call will actually reset the self table state to the version specified. That seems like it would be a concerning side effect.

I'm honestly not sure if load_version is more/less work than just creating a new DeltaTable at that specific version, and then returning newtable.get_version_timestamp(version) to preserve self here 🤔

@r3stl355 r3stl355 marked this pull request as draft January 1, 2024 17:31
@r3stl355
Copy link
Contributor Author

r3stl355 commented Jan 1, 2024

Closing this because a simpler fix for the test only was implemented in #2010

@r3stl355 r3stl355 closed this Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binding/python Issues for the Python package binding/rust Issues for the Rust crate crate/core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants