Skip to content

[HUDI-7156] Abstract an independent hoodie table filesystem view lock#10197

Closed
zhuanshenbsj1 wants to merge 3 commits intoapache:masterfrom
zhuanshenbsj1:HUDI-7156
Closed

[HUDI-7156] Abstract an independent hoodie table filesystem view lock#10197
zhuanshenbsj1 wants to merge 3 commits intoapache:masterfrom
zhuanshenbsj1:HUDI-7156

Conversation

@zhuanshenbsj1
Copy link
Contributor

Change Logs

Describe context and summary for this change. Highlight if any code was copied.

Impact

Describe any public API or user-facing feature change or any performance impact.

Risk level (write none, low medium or high below)

If medium or high, explain what verification was done to mitigate the risks.

Documentation Update

Describe any necessary documentation update if there is any new feature, config, or user-facing change

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

* Check if the current thread holds write lock
*/
public boolean hasWriteLock() {
return globalLock.isWriteLockedByCurrentThread();
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like the return value is not used, will it block when calling this method? Otherwise we don't need to call it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a reentrant read-write lock, and with this function we just confirm whether the lock has been acquired. The outer layer has actually acquired the writelock, there we just verify it.
image

Copy link
Contributor

Choose a reason for hiding this comment

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

How do we verify this? I mean, do we need to check the return value of hasWriteLock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we verify this? I mean, do we need to check the return value of hasWriteLock?

I'll add a unit test later for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we verify this? I mean, do we need to check the return value of hasWriteLock?

Sorry, I've been busy lately. Added ut to check the value of hasWriteLock, cc~ @stream2000


LOG.info("Timeline Diff Result is :" + diffResult);

viewLock.hasWriteLock();
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this line necessary if we're not checking the return value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake, assertion has been added

* Clear the resource.
*/
protected void clear() {
viewLock.hasWriteLock();
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto

* Clear the resource.
*/
protected void clear() {
assert viewLock.hasWriteLock();
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 use ValidationUtils.checkArgument to check the result here.

e.g.,
ValidationUtils.checkArgument(viewLock.hasWriteLock(), "Current thread must hold the write lock on viewLock when clearing the resource");

@stream2000
Copy link
Contributor

Let's provide more details in the PR description explaining why this PR is necessary. Also, are there plans to support different types of filesystem view locks in the future?

@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

@github-actions github-actions bot added the size:M PR with lines of changes in (100, 300] label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M PR with lines of changes in (100, 300]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants