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

Improving retention manager to handle segment lineage clean-up #5828

Merged
merged 2 commits into from Aug 11, 2020

Conversation

snleee
Copy link
Contributor

@snleee snleee commented Aug 7, 2020

  1. Added the logic to handle segment lineage clean-up in the
    retention manager.
  2. Added the unit test

1. Added the logic to handle segment lineage clean-up in the
   retention manager.
2. Added the unit test
@snleee snleee force-pushed the merge-rentention-manager branch 4 times, most recently from 2a5b3d4 to 8bf18a7 Compare August 10, 2020 07:55
Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

No need to check segmentsTo for COMPLETED. We can delete the lineage entry once all the segments in segmentsFrom are already deleted (not in the current round).

Comment on lines 218 to 223
segmentsToDelete.addAll(lineageEntry.getSegmentsFrom());

// The lineage entry with 'COMPLETED' state can only be safely removed when both segmentFrom & segmentTo
// are all removed from the table.
if (Collections.disjoint(segmentsForTable, lineageEntry.getSegmentsFrom()) && Collections
.disjoint(segmentsForTable, lineageEntry.getSegmentsTo())) {
segmentLineage.deleteLineageEntry(lineageEntryId);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We can simplify the logic as following, same for IN_PROGRESS

Suggested change
segmentsToDelete.addAll(lineageEntry.getSegmentsFrom());
// The lineage entry with 'COMPLETED' state can only be safely removed when both segmentFrom & segmentTo
// are all removed from the table.
if (Collections.disjoint(segmentsForTable, lineageEntry.getSegmentsFrom()) && Collections
.disjoint(segmentsForTable, lineageEntry.getSegmentsTo())) {
segmentLineage.deleteLineageEntry(lineageEntryId);
}
Set<String> sourceSegments = new HashSet<>(lineageEntry.getSegmentsFrom());
sourceSegments.retainAll(segmentsForTable);
if (sourceSegments.isEmpty()) {
segmentLineage.deleteLineageEntry(lineageEntryId);
} else {
segmentsToDelete.addAll(sourceSegments);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed. Please double check the logic for IN_PROGRESS as well.

Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

LGTM

@snleee snleee merged commit 3785aa7 into apache:master Aug 11, 2020
@snleee snleee deleted the merge-rentention-manager branch August 11, 2020 01:32
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.

None yet

2 participants