Skip to content

Comments

[HUDI-3798] Fixing ending of a transaction by different owner and removing some extraneous methods in trxn manager#5255

Merged
codope merged 2 commits intoapache:masterfrom
nsivabalan:txnManagerRefactoring
Apr 11, 2022
Merged

[HUDI-3798] Fixing ending of a transaction by different owner and removing some extraneous methods in trxn manager#5255
codope merged 2 commits intoapache:masterfrom
nsivabalan:txnManagerRefactoring

Conversation

@nsivabalan
Copy link
Contributor

What is the purpose of the pull request

  • We had 2 begin and 2 end transaction methods in transaction manager, where one of them did not take in the owner info. Cleaning those up and fixed all callers to send in the transaction onwer info.
  • Also, if transaction was started by caller1, but if end transaction was called by caller2, we were letting the caller2 release the lock. So, fixed that to ensure only the owner who acquired the lock can end the transaction.

Brief change log

  • Cleaned up an extraneous begin and end method in transaction manager.
  • Fixed ending of a transaction by a different caller than who acquired the lock.

Verify this pull request

This change added tests and can be verified as follows:

  • Added a test to TestTransactionManager to verify the fix.

Committer checklist

  • Has a corresponding JIRA in PR title & commit

  • Commit message is descriptive of the change

  • CI is green

  • Necessary doc changes done or have another open PR

  • For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.

@nsivabalan nsivabalan added the priority:blocker Production down; release blocker label Apr 7, 2022
@nsivabalan nsivabalan assigned yihua and codope and unassigned yihua Apr 7, 2022
writer2.start();
countDownLatch.await(30, TimeUnit.SECONDS);
// should not have reset the state within transaction manager since the owner is different.
Assertions.assertTrue(transactionManager.getCurrentTransactionOwner().isPresent());
Copy link
Member

Choose a reason for hiding this comment

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

iiuc, even in this scenario, without this patch, reset would be called and it would return w/o resetting but then unlock would also be called which we don't want. And this patch fixes this behavior. So, can we verify that not only state is not reset but also unlock is not called?

Copy link
Member

Choose a reason for hiding this comment

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

maybe make reset method just visible for testing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we usually don't use VisibleForTesting annotation. lets sync up on this. we might have tests in InProcessLockProvider to assert for the condition you are talking about

Copy link
Member

Choose a reason for hiding this comment

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

Ok found it: TestInProcessLockProvider#testLockReAcquisitionByDifferentThread. That's good enough.
Since we already use Mocito, maybe we can use its verify API to just verify calls.

@hudi-bot
Copy link
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:blocker Production down; release blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants