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

[Spark] InCommitTimestamp: Use clock.currentTimeMillis() instead of nanoTime() in commitLarge #3111

Merged
merged 7 commits into from
May 17, 2024

Conversation

dhruvarya-db
Copy link
Collaborator

@dhruvarya-db dhruvarya-db commented May 17, 2024

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

We currently use NANOSECONDS.toMillis(System.nanoTime()) for generating the ICT when commitLarge is called. However, this usage of System.nanoTime() is not correct as it should only be used for measuring time difference, not to get an approximate wall clock time. This leads to scenarios where the ICT becomes very small (e.g. 1 Jan 1970) sometimes because some systems return a very small number when System.nanoTime() is called. This PR changes this so that clock.getCurrentTimeMillis() is used instead.

How was this patch tested?

Added a test case to ensure that clock.getCurrentTimeMillis() is being used.

Does this PR introduce any user-facing changes?

No

Map.empty)
}
val ver1Snapshot = deltaLog.snapshot
val retrievedTimestamp = getInCommitTimestamp(deltaLog, 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] used named parameter.

@@ -143,6 +143,33 @@ class InCommitTimestampSuite
}
}

test("commitLarge should use clock.currentTimeMillis() for ICT") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we have a similar test for txn.commit API?

@vkorukanti vkorukanti merged commit eca5a7f into delta-io:master May 17, 2024
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants