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

Read delta lake table history when initial transaction logs are deleted #18845

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

krvikash
Copy link
Contributor

@krvikash krvikash commented Aug 29, 2023

Description

This PR handles the case when transaction logs are deleted because the retention time of the transaction log is over.

This issue will occur when initial transaction logs get deleted because of log retention interval is exceeded while writing a new checkpoint file.

Release notes

( ) This is not user-visible or is docs only, and no release notes are required.
(X) Release notes are required. Please propose a release note for me.
( ) Release notes are required, with the following suggested text:

# Deltalake
* Fix reading delta lake table history when initial transaction logs are removed. ({issue}`18845`)

@cla-bot cla-bot bot added the cla-signed label Aug 29, 2023
@krvikash krvikash self-assigned this Aug 29, 2023
@krvikash krvikash added the delta-lake Delta Lake connector label Aug 29, 2023
@krvikash krvikash force-pushed the krvikash/delta-history-table branch 2 times, most recently from 7f6e106 to 8f8bcb2 Compare September 4, 2023 06:42
@@ -94,6 +94,45 @@ public static TransactionLogTail loadNewTail(
return new TransactionLogTail(entriesBuilder.build(), version);
}

// Load a section of the Transaction Log JSON entries. Optionally from a given end version (inclusive) through an start version (inclusive)
public static TransactionLogTail loadNewTailBackward(
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason for reading backward, because we try to reverse them later in getPageSource

Copy link
Contributor Author

@krvikash krvikash Sep 4, 2023

Choose a reason for hiding this comment

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

Yes, the transaction log we intend to access through loadNewTailBackward will start from the final checkpoint file version and continue all the way back to version 0. This will remain true even if the log retention period is exceeded, leading to the removal of some of the initial transaction logs (0, 1, etc.). In this way, we can still retrieve the complete history of the table till the last checkpoint version.

@krvikash krvikash force-pushed the krvikash/delta-history-table branch from 8f8bcb2 to 049175b Compare September 8, 2023 06:38
@krvikash
Copy link
Contributor Author

krvikash commented Sep 8, 2023

Thanks @findinpath for the review. I have addressed comments.

if (lastCheckpointVersion.isPresent() && endVersionInclusive.isPresent()) {
middleVersion = Optional.of(Math.min(lastCheckpointVersion.get(), endVersionInclusive.get()));
}
commitInfoEntries.addAll(TransactionLogTail.loadNewTailBackward(fileSystem, tableLocation, startVersionExclusive, middleVersion, true).getFileEntries().stream()
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need to do this from the middle backwards and then from the middle forward separately? Rather than from endVersion backwards in one pass.

It's not obvious to me this way that you're not potentially going to have duplicates.

@krvikash krvikash force-pushed the krvikash/delta-history-table branch from 049175b to c91fde5 Compare September 8, 2023 19:20
@krvikash
Copy link
Contributor Author

krvikash commented Sep 8, 2023

Thanks @alexjo2144 for the review. AC.

@krvikash krvikash force-pushed the krvikash/delta-history-table branch from c91fde5 to 27afeaf Compare September 8, 2023 19:22
@krvikash
Copy link
Contributor Author

krvikash commented Sep 8, 2023

(resolved conflicts)

@krvikash krvikash force-pushed the krvikash/delta-history-table branch from 27afeaf to 1b629c8 Compare September 13, 2023 08:58
@krvikash
Copy link
Contributor Author

(resolved conflicts)

@krvikash krvikash requested a review from findepi September 13, 2023 08:59
@krvikash krvikash force-pushed the krvikash/delta-history-table branch from 1b629c8 to d046069 Compare September 13, 2023 15:24
@krvikash
Copy link
Contributor Author

(fixed CI failure)

@krvikash krvikash force-pushed the krvikash/delta-history-table branch from d046069 to 1922381 Compare September 13, 2023 18:13
@krvikash
Copy link
Contributor Author

Thanks @alexjo2144 for the review. Addressed comments.

@findepi findepi merged commit 5548599 into trinodb:master Sep 14, 2023
@github-actions github-actions bot added this to the 427 milestone Sep 14, 2023
@krvikash krvikash deleted the krvikash/delta-history-table branch September 14, 2023 08:16
@krvikash
Copy link
Contributor Author

krvikash commented Sep 14, 2023

ci / test (plugin/trino-delta-lake, cloud-tests) is failing in master. I am working on fixing it.

Failing for ADLS and GCS. S3 is passing.

@krvikash
Copy link
Contributor Author

minio.removeObject is not removing files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed delta-lake Delta Lake connector
Development

Successfully merging this pull request may close these issues.

5 participants