You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecate TableMetadata.removeSnapshotsIf in favor of metadata builder #3900
After #3883 gets closed, I'll raise a PR for this that I have ready. I am planning on deprecating the existing TableMetadata#removeSnapshotsIf and adding the a new removeSnapshots method which simply accepts a set of snapshot ids to remove. It will do validation that the set of snapshot ids passed in does not contain the latest snapshot id. Something like the following.
public TableMetadata removeSnapshots(Set<Long> snapshotIdsToRemove) {
Preconditions.checkArgument(snapshotIdsToRemove != null,
"Snapshot ids to remove cannot be null");
ValidationException.check(!snapshotIdsToRemove.contains(currentSnapshotId),
String.format("Cannot remove the latest snapshot id: %d", currentSnapshotId));
return new Builder(this)
.removeSnapshots(snapshotIdsToRemove)
.build();
}
Then in a later PR to address updating the expiration logic to account for references, we would start calling removeSnapshots along with replaceRefs. @jackye1995 thoughts on this?
As a follow up, I think in the scope of the API we should also make sure we are cleaning up any references as well, as to prevent a "corrupt" state of TableMetadata. So if snapshot 2 is to be removed and there are references to snapshot 2, within this API we should also remove those references. This way we don't have any dangling references. We could also filter and not remove any snapshots which have references in this method, and then force callers to remove references first and then the snapshot ids. This seems like too much work for callers, and to me is not as intuitive. Let me know your thoughts.
When we add branching and tagging, we will have a much more complex if statement to filter out snapshots, and we should be sure that the snapshots passed into the method are the ones we truly want to remove. The snapshot might have associated refs, but removing the refs along the way seems like the correct choice, so that we don't need to have another operation like RemoveSnapshotRef to clean those things up.
Based on this, I think option 3 makes sense to me at this point of time based on the use case.
This is also not a one way door, we can always add a flag to achieve 1 or 2 in the future if that is absolutely needed, but it should be simpler to enforce that requirement before the information is passed into the method.
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
Activity
amogh-jahagirdar commentedon Jan 20, 2022
After #3883 gets closed, I'll raise a PR for this that I have ready. I am planning on deprecating the existing TableMetadata#removeSnapshotsIf and adding the a new removeSnapshots method which simply accepts a set of snapshot ids to remove. It will do validation that the set of snapshot ids passed in does not contain the latest snapshot id. Something like the following.
Then in a later PR to address updating the expiration logic to account for references, we would start calling removeSnapshots along with replaceRefs. @jackye1995 thoughts on this?
amogh-jahagirdar commentedon Jan 20, 2022
As a follow up, I think in the scope of the API we should also make sure we are cleaning up any references as well, as to prevent a "corrupt" state of TableMetadata. So if snapshot 2 is to be removed and there are references to snapshot 2, within this API we should also remove those references. This way we don't have any dangling references. We could also filter and not remove any snapshots which have references in this method, and then force callers to remove references first and then the snapshot ids. This seems like too much work for callers, and to me is not as intuitive. Let me know your thoughts.
jackye1995 commentedon Jan 21, 2022
Overall there are 3 use cases:
Consider the use case if this method, it is basically used for snapshot expiration and nothing else. The logic is:
When we add branching and tagging, we will have a much more complex if statement to filter out snapshots, and we should be sure that the snapshots passed into the method are the ones we truly want to remove. The snapshot might have associated refs, but removing the refs along the way seems like the correct choice, so that we don't need to have another operation like
RemoveSnapshotRefto clean those things up.Based on this, I think option 3 makes sense to me at this point of time based on the use case.
This is also not a one way door, we can always add a flag to achieve 1 or 2 in the future if that is absolutely needed, but it should be simpler to enforce that requirement before the information is passed into the method.
github-actions commentedon Aug 22, 2022
This issue has been automatically marked as stale because it has been open for 180 days with no activity. It will be closed in next 14 days if no further activity occurs. To permanently prevent this issue from being considered stale, add the label 'not-stale', but commenting on the issue is preferred when possible.
github-actions commentedon Sep 5, 2022
This issue has been closed because it has not received any activity in the last 14 days since being marked as 'stale'