Skip to content

Conversation

@chaplinthink
Copy link
Contributor

Tips

What is the purpose of the pull request

synchronized is not necessary, because the sync operation already has WriteLock to ensure synchronization

Brief change log

(for example:)

  • Modify AnnotationLocation checkstyle rule in checkstyle.xml

Verify this pull request

(Please pick either of the following options)

This pull request is a trivial rework / code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end.
  • Added HoodieClientWriteTest to verify the change.
  • Manually verified the change by running a job locally.

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.

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2021

Codecov Report

Merging #3041 (2a77d2a) into master (08464a6) will increase coverage by 5.28%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3041      +/-   ##
============================================
+ Coverage     49.86%   55.14%   +5.28%     
- Complexity     3527     3865     +338     
============================================
  Files           488      488              
  Lines         23618    23616       -2     
  Branches       2528     2528              
============================================
+ Hits          11777    13023    +1246     
+ Misses        10802     9434    -1368     
- Partials       1039     1159     +120     
Flag Coverage Δ
hudicli 39.55% <ø> (ø)
hudiclient ∅ <ø> (∅)
hudicommon 50.33% <ø> (+0.04%) ⬆️
hudiflink 63.26% <ø> (ø)
hudihadoopmr 51.43% <ø> (ø)
hudisparkdatasource 74.30% <ø> (ø)
hudisync 46.60% <ø> (ø)
huditimelineservice 64.65% <0.00%> (+0.28%) ⬆️
hudiutilities 70.83% <ø> (+61.55%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...g/apache/hudi/timeline/service/RequestHandler.java 73.88% <0.00%> (+0.50%) ⬆️
...e/hudi/common/table/log/HoodieLogFormatWriter.java 79.68% <0.00%> (+1.56%) ⬆️
.../apache/hudi/utilities/HoodieSnapshotExporter.java 88.79% <0.00%> (+5.17%) ⬆️
...ache/hudi/common/fs/inline/InMemoryFileSystem.java 89.65% <0.00%> (+10.34%) ⬆️
...e/hudi/utilities/transform/ChainedTransformer.java 100.00% <0.00%> (+11.11%) ⬆️
...in/java/org/apache/hudi/utilities/UtilHelpers.java 64.53% <0.00%> (+30.23%) ⬆️
...ties/deltastreamer/HoodieDeltaStreamerMetrics.java 36.11% <0.00%> (+36.11%) ⬆️
...g/apache/hudi/utilities/schema/SchemaProvider.java 100.00% <0.00%> (+42.85%) ⬆️
...ities/checkpointing/InitialCheckPointProvider.java 45.45% <0.00%> (+45.45%) ⬆️
...di/utilities/sources/helpers/IncrSourceHelper.java 54.54% <0.00%> (+54.54%) ⬆️
... and 34 more

String lastKnownInstantFromClient =
ctx.queryParam(RemoteHoodieTableFileSystemView.LAST_INSTANT_TS, HoodieTimeline.INVALID_INSTANT_TS);
SyncableFileSystemView view = viewManager.getFileSystemView(basePath);
synchronized (view) {
Copy link
Contributor

Choose a reason for hiding this comment

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

hi, @chaplinthink I think it is necessary to use synchronization to sync view locally since the handler would handle different request from clients concurrently. cc @bvaradar

Copy link
Contributor Author

@chaplinthink chaplinthink Jun 8, 2021

Choose a reason for hiding this comment

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

I mean the implementation of view.sync(); already has WriteLock to handle multiple requests from clients concurrently @leesf

 try {
      writeLock.lock();
      runSync(oldTimeline, newTimeline);
    } finally {
      writeLock.unlock();
    }

Copy link
Contributor

@leesf leesf Jun 8, 2021

Choose a reason for hiding this comment

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

@chaplinthink Thanks for the explanation, make sense to me. @vinothchandar @bvaradar do you have any other concern?

Copy link
Member

Choose a reason for hiding this comment

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

I was mulling about the reloading of timeline that happens before the write lock.

@Override
  public void sync() {
    HoodieTimeline oldTimeline = getTimeline();
    HoodieTimeline newTimeline = metaClient.reloadActiveTimeline().filterCompletedAndCompactionInstants();
    try {
      writeLock.lock();
      runSync(oldTimeline, newTimeline);
    } finally {
      writeLock.unlock();
    }
  }

runSync() actually could init/reassign metaClient, so in theory removing synchornized could in theory make it non-serializable.

I would suggest that we either move the timeline reload into the write lock and leave this as-is. Whatever we change, we need to validate with more concurrent testing. So not sure if this is all worth the trouble.

Are you hitting real concurrency bottlenecks around 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.

Thanks a lot for reply. Do you mean the synchornized is to ensure HoodieTimeline newTimeline = metaClient.reloadActiveTimeline().filterCompletedAndCompactionInstants(); concurrently?

In fact, we are also to do this right ?

@Override
  public void sync() {
    HoodieTimeline oldTimeline = getTimeline();
    try {
      writeLock.lock();
      HoodieTimeline newTimeline = metaClient.reloadActiveTimeline().filterCompletedAndCompactionInstants();
      runSync(oldTimeline, newTimeline);
    } finally {
      writeLock.unlock();
    }
  }

I am confused when I see the code that we use synchornized and writeLock at the same time.

I agree to validate this with more concurrent testing. Currently i have not encountered concurrency bottlenecks.

@vinothchandar vinothchandar self-assigned this Sep 7, 2021
@hudi-bot
Copy link
Collaborator

hudi-bot commented Nov 5, 2021

CI report:

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

@yihua yihua added priority:high Significant impact; potential bugs writer-core labels Sep 13, 2022
@bvaradar
Copy link
Contributor

@yihua : As you had fixed this issue in master, this PR can be closed. right ?

@yihua
Copy link
Contributor

yihua commented Mar 30, 2023

@yihua : As you had fixed this issue in master, this PR can be closed. right ?

Yes. @chaplinthink #8079 has simplified the synchronization with the fix to HoodieMetadataFileSystemView so this PR is no longer needed.

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

Labels

priority:high Significant impact; potential bugs

Projects

Status: 🚧 Needs Repro
Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants