-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Updates forceCommit APIs to handle Pauseless #14828
Merged
Jackie-Jiang
merged 15 commits into
apache:master
from
noob-se7en:update_forceCommit_status
Jan 24, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ab2220f
Updates foceCommit API to handle Pauseless
noob-se7en ed90f11
updates metadata
noob-se7en e88aa2a
fixes lint
noob-se7en 8c8d8d3
adds tests
noob-se7en 1be0316
saves 1 zk call
noob-se7en 095acc0
Addresses PR comments
noob-se7en 36360b8
nit
noob-se7en 68cdc26
adds unit test
noob-se7en b8a2e7f
Merge branch 'master' of github.com:apache/pinot into update_forceCom…
noob-se7en 5730a06
addresses PR comments
noob-se7en c8565d6
nit
noob-se7en 857dd6a
attempt to fix test
noob-se7en 2f7e5d9
Merge branch 'master' of github.com:apache/pinot into update_forceCom…
noob-se7en 0b64439
nit
noob-se7en 9e3ddad
Attempts to fix test
noob-se7en 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 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
This file contains 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 |
---|---|---|
|
@@ -2009,4 +2009,20 @@ String moveSegmentFile(String rawTableName, String segmentName, String segmentLo | |
URI createSegmentPath(String rawTableName, String segmentName) { | ||
return URIUtils.getUri(_controllerConf.getDataDir(), rawTableName, URIUtils.encode(segmentName)); | ||
} | ||
|
||
public Set<String> getSegmentsYetToBeCommitted(String tableNameWithType, Set<String> segmentsToCheck) { | ||
Set<String> segmentsYetToBeCommitted = new HashSet<>(); | ||
for (String segmentName: segmentsToCheck) { | ||
SegmentZKMetadata segmentZKMetadata = | ||
_helixResourceManager.getSegmentZKMetadata(tableNameWithType, segmentName); | ||
if (segmentZKMetadata == null) { | ||
// Segment is deleted. No need to track this segment among segments yetToBeCommitted. | ||
continue; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (minor) Add some comment about this behavior. We are counting deleted segment as not need to be committed |
||
} | ||
if (!(segmentZKMetadata.getStatus().equals(Status.DONE))) { | ||
segmentsYetToBeCommitted.add(segmentName); | ||
} | ||
} | ||
return segmentsYetToBeCommitted; | ||
} | ||
} |
This file contains 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 |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
package org.apache.pinot.controller.helix.core.realtime; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.ImmutableSet; | ||
import com.google.common.collect.Lists; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
@@ -1247,6 +1248,36 @@ public void testGetPartitionIds() | |
Assert.assertEquals(partitionIds.size(), 2); | ||
} | ||
|
||
@Test | ||
public void getSegmentsYetToBeCommitted() { | ||
PinotHelixResourceManager mockHelixResourceManager = mock(PinotHelixResourceManager.class); | ||
FakePinotLLCRealtimeSegmentManager realtimeSegmentManager = | ||
new FakePinotLLCRealtimeSegmentManager(mockHelixResourceManager); | ||
|
||
SegmentZKMetadata mockSegmentZKMetadataDone = mock(SegmentZKMetadata.class); | ||
when(mockSegmentZKMetadataDone.getStatus()).thenReturn(Status.DONE); | ||
|
||
SegmentZKMetadata mockSegmentZKMetadataUploaded = mock(SegmentZKMetadata.class); | ||
when(mockSegmentZKMetadataUploaded.getStatus()).thenReturn(Status.UPLOADED); | ||
|
||
SegmentZKMetadata mockSegmentZKMetadataInProgress = mock(SegmentZKMetadata.class); | ||
when(mockSegmentZKMetadataInProgress.getStatus()).thenReturn(Status.IN_PROGRESS); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also add one for Status.COMMITTING |
||
|
||
SegmentZKMetadata mockSegmentZKMetadataInCommitting = mock(SegmentZKMetadata.class); | ||
when(mockSegmentZKMetadataInCommitting.getStatus()).thenReturn(Status.COMMITTING); | ||
|
||
when(mockHelixResourceManager.getSegmentZKMetadata("test", "s0")).thenReturn(mockSegmentZKMetadataDone); | ||
when(mockHelixResourceManager.getSegmentZKMetadata("test", "s3")).thenReturn(mockSegmentZKMetadataDone); | ||
when(mockHelixResourceManager.getSegmentZKMetadata("test", "s2")).thenReturn(mockSegmentZKMetadataUploaded); | ||
when(mockHelixResourceManager.getSegmentZKMetadata("test", "s4")).thenReturn(mockSegmentZKMetadataInProgress); | ||
when(mockHelixResourceManager.getSegmentZKMetadata("test", "s1")).thenReturn(null); | ||
when(mockHelixResourceManager.getSegmentZKMetadata("test", "s5")).thenReturn(mockSegmentZKMetadataInCommitting); | ||
|
||
Set<String> segmentsToCheck = ImmutableSet.of("s0", "s1", "s2", "s3", "s4", "s5"); | ||
Set<String> segmentsYetToBeCommitted = realtimeSegmentManager.getSegmentsYetToBeCommitted("test", segmentsToCheck); | ||
assert ImmutableSet.of("s2", "s4", "s5").equals(segmentsYetToBeCommitted); | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////////////////// | ||
// Fake classes | ||
///////////////////////////////////////////////////////////////////////////////// | ||
|
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.
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.
@noob-se7en iiuc the objective of introducing this field is to reduce the number of segmentZKMetadata that we will be iterating over.
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.
Does it server any other purpose ?
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, Just to reduce the ZK calls only.