Skip to content

Fixes discrepancy between admin fate delete and UserFateStore.delete#5016

Merged
kevinrr888 merged 3 commits intoapache:mainfrom
kevinrr888:4.0-feature-req-status-discrepancy
Nov 5, 2024
Merged

Fixes discrepancy between admin fate delete and UserFateStore.delete#5016
kevinrr888 merged 3 commits intoapache:mainfrom
kevinrr888:4.0-feature-req-status-discrepancy

Conversation

@kevinrr888
Copy link
Member

admin fate delete allows users to delete a transaction. If this transaction is a USER transaction, UserFateStore.delete() is how this is achieved. The admin code allows transactions with a status of SUBMITTED, IN_PROGRESS, NEW, FAILED, FAILED_IN_PROGRESS, SUCCESSFUL to call delete(), but the delete() code only allows NEW, SUBMITTED, SUCCESSFUL, FAILED. I changed the UserFateStore.delete() code to match the admin delete code. I'm not sure which one should be changed, but one of them should be.

`admin fate delete` allows users to delete a transaction. If this transaction is a USER transaction, `UserFateStore.delete()` is how this is achieved. The admin code allows transactions with a status of SUBMITTED, IN_PROGRESS, NEW, FAILED, FAILED_IN_PROGRESS, SUCCESSFUL to call `delete()`, but the `delete()` code only allows NEW, SUBMITTED, SUCCESSFUL, FAILED. This commit fixes this discrepancy.
@kevinrr888 kevinrr888 added this to the 4.0.0 milestone Oct 25, 2024
@kevinrr888 kevinrr888 self-assigned this Oct 25, 2024
@dlmarion
Copy link
Contributor

Regarding consistency - what's the behavior in earlier releases? I think they both should be consistent with that answer.

@keith-turner
Copy link
Contributor

Regarding consistency - what's the behavior in earlier releases? I think they both should be consistent with that answer.

Looking at the 3.1 code it would delete the fate tx no matter what state it was in. In 3.1 there as no check in the fate store of the status.

I would recommend adding a forceDelete() call to the fate store that will delete no matter what the status. The admin code could call this and would have the same behavior as 3.1. However the non-admin fate code that calls delete would have this stronger check of the status that prevents bugs. Do not expect the non admin fate code to delete in progress transactions.

@kevinrr888
Copy link
Member Author

Looking at the 3.1 code it would delete the fate tx no matter what state it was in. In 3.1 there as no check in the fate store of the status.

Yeah, 3.1 and prior only has ZooStore/MetaFateStore which never checks for an expected status. The new UserFateStore does this for things like delete() since it can be performed atomically with conditional mutations. MetaFateStore can't do this yet (but should be able with #4905)

…tore.delete`

Admin now calls a force delete to delete the transaction regardless of state. forceDelete() is a new method only to be used by Admin.
void delete();

/**
* Force remove the transaction from the store. Only to be used by {@link AdminUtil}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Force remove the transaction from the store. Only to be used by {@link AdminUtil}
* Force remove the transaction from the store regardless of the status. Only to be used by {@link AdminUtil}


@Override
public void forceDelete() {
throw new UnsupportedOperationException(
Copy link
Contributor

@keith-turner keith-turner Nov 1, 2024

Choose a reason for hiding this comment

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

I like what this trying to do, but its far removed from the code that cares about this and if the code is refactored then this validation could be lost w/o anyone realizing it.

The following is a not a great solution, but its a solution. Could pass a boolean to the WrappedFateTxStore constructor that indicates if forceDelete should be allowed or not. This boolean could then cascade out to the code that creates the logging fate store. The boolean would always be false, but it links the code that really cares about this to this check and would force any refactorings to consider it.

Another solution is to add a comment exlaining why this throwing unsupported operation exception.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, good point... I feel like comments are also likely to be overlooked/forgotten. I added the boolean in 9069a33. It seems like a fine solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

Those changes look good.

@kevinrr888 kevinrr888 merged commit 7da7ac8 into apache:main Nov 5, 2024
@kevinrr888 kevinrr888 deleted the 4.0-feature-req-status-discrepancy branch November 6, 2024 16:43
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