-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-5280] Fix taskmanager concurrent registry #7306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
kaori-seasons
wants to merge
2
commits into
apache:master
from
kaori-seasons:fix-taskmanager-concurrent-registry
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...udi-client-common/src/test/java/org/apache/hudi/config/metrics/TestHoodieLockMetrics.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package org.apache.hudi.config.metrics; | ||
|
|
||
| import org.apache.hudi.client.transaction.lock.metrics.HoodieLockMetrics; | ||
| import org.apache.hudi.common.config.HoodieMetadataConfig; | ||
| import org.apache.hudi.common.table.view.FileSystemViewStorageConfig; | ||
| import org.apache.hudi.common.table.view.FileSystemViewStorageType; | ||
| import org.apache.hudi.common.util.CustomizedThreadFactory; | ||
| import org.apache.hudi.config.HoodieCompactionConfig; | ||
| import org.apache.hudi.config.HoodieIndexConfig; | ||
| import org.apache.hudi.config.HoodieStorageConfig; | ||
| import org.apache.hudi.config.HoodieWriteConfig; | ||
| import org.apache.hudi.index.HoodieIndex; | ||
| import org.apache.hudi.metrics.Metrics; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.ValueSource; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import java.util.concurrent.ThreadPoolExecutor; | ||
|
|
||
| import static org.apache.hudi.common.testutils.HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA; | ||
|
|
||
| public class TestHoodieLockMetrics { | ||
|
|
||
| @TempDir | ||
| public java.nio.file.Path tempDir; | ||
| protected String basePath = null; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() throws IOException { | ||
| java.nio.file.Path basePath = tempDir.resolve("dataset"); | ||
| java.nio.file.Files.createDirectories(basePath); | ||
| this.basePath = basePath.toString(); | ||
| } | ||
|
|
||
| @ParameterizedTest | ||
| @ValueSource(booleans = {true, false}) | ||
| public void testTaskManagerConcurrentRegisterMetrics(){ | ||
| ExecutorService threadPoolExecutor = Executors.newFixedThreadPool(10, new CustomizedThreadFactory("hudi-metrics-")); | ||
|
|
||
| threadPoolExecutor.submit( () -> { | ||
| HoodieWriteConfig writeConfig = getConfigBuilder(false).build(); | ||
| return new HoodieLockMetrics(writeConfig); | ||
| }); | ||
| } | ||
| protected HoodieWriteConfig.Builder getConfigBuilder(Boolean autoCommit) { | ||
|
|
||
| return HoodieWriteConfig.newBuilder().withPath(basePath) | ||
| .withSchema(TRIP_EXAMPLE_SCHEMA) | ||
| .withParallelism(2, 2) | ||
| .withAutoCommit(autoCommit) | ||
| .withMetadataConfig(HoodieMetadataConfig.newBuilder().withAssumeDatePartitioning(true).build()) | ||
| .withCompactionConfig(HoodieCompactionConfig.newBuilder().compactionSmallFileSize(1024 * 1024 * 1024) | ||
| .withInlineCompaction(false).withMaxNumDeltaCommitsBeforeCompaction(1).build()) | ||
| .withStorageConfig(HoodieStorageConfig.newBuilder() | ||
| .hfileMaxFileSize(1024 * 1024 * 1024).parquetMaxFileSize(1024 * 1024 * 1024).orcMaxFileSize(1024 * 1024 * 1024).build()) | ||
| .forTable("test-trip-table") | ||
| .withIndexConfig(HoodieIndexConfig.newBuilder().withIndexType(HoodieIndex.IndexType.BLOOM).build()) | ||
| .withEmbeddedTimelineServerEnabled(true).withFileSystemViewConfig(FileSystemViewStorageConfig.newBuilder() | ||
| .withStorageType(FileSystemViewStorageType.EMBEDDED_KV_STORE).build()); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the
REGISTRY_LOCKcan not work correctly here, can you elaborate the explanation then ?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using the reentrant lock, the Task threads are isolated from each other before, but there will be a situation where the second Task thread enters the synchronized scope and waits after the first Task thread registers the value. At this time, the metrics may not be obtained. So there is a duplicate registration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the
REGISTRY_LOCKcan still be used instead of the class obj lockRegistry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is not necessary to lock the whole class. I will make the correction in these two days