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
[7338] Allow Reloading Segments with Multiple Threads #7893
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
5a626b7
Added reload parallelism to SegmentReloadMessage
suddendust 3be37c7
Undo unwanted change
suddendust 801b2b6
Accept parallelism param in PinotSegmentRestletResource
suddendust bcc17b7
Added default parallelism value in PinotSegmentRestletResource reload…
suddendust 3817fce
Minor refactoring
suddendust f5f9eb8
Fixed checkstyle violations
suddendust 98d1fe9
Added @QueryParam in API signatures
suddendust 00047d8
fix worker pool size
suddendust a7602c1
added preconditions on parallelism param, added log when noSegments <…
suddendust 0d30a5b
better use of completablefuture API as recommended
suddendust 5242862
spotless
suddendust 7963329
Use existing _refreshThreadsSemaphore to control reload parallelism
suddendust 416b7e8
Reverted unwanted changes
suddendust 14f608e
Removed signature change for InstanceDataManager#reloadSegment
suddendust 00f6a8d
Nullcheck during sema release, minor refactoring
suddendust 6cc9635
fix checkstyle
suddendust 80ebb4d
refactor
suddendust 49ea862
Addressed comments
suddendust db376e9
Refactoring
suddendust efb8a3f
spotless
suddendust ea7800b
Added missing header
suddendust 29c52d4
Update pinot-core/src/main/java/org/apache/pinot/core/util/SegmentRef…
suddendust 2fdb3c2
fixed compilation issue due to upstream commit
suddendust b486e5a
removed redundant catch block
suddendust File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
60 changes: 60 additions & 0 deletions
60
pinot-core/src/main/java/org/apache/pinot/core/util/SegmentRefreshSemaphore.java
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.apache.pinot.core.util; | ||
|
||
import java.util.concurrent.Semaphore; | ||
import org.slf4j.Logger; | ||
|
||
|
||
/** | ||
* Wrapper class for semaphore used to control concurrent segment reload/refresh | ||
*/ | ||
public class SegmentRefreshSemaphore { | ||
|
||
private final Semaphore _semaphore; | ||
|
||
public SegmentRefreshSemaphore(int permits, boolean fair) { | ||
if (permits > 0) { | ||
_semaphore = new Semaphore(permits, fair); | ||
} else { | ||
_semaphore = null; | ||
} | ||
} | ||
|
||
public void acquireSema(String segmentName, Logger logger) | ||
throws InterruptedException { | ||
if (_semaphore != null) { | ||
long startTime = System.currentTimeMillis(); | ||
logger.info("Waiting for lock to refresh : {}, queue-length: {}", segmentName, | ||
_semaphore.getQueueLength()); | ||
_semaphore.acquire(); | ||
logger.info("Acquired lock to refresh segment: {} (lock-time={}ms, queue-length={})", segmentName, | ||
System.currentTimeMillis() - startTime, _semaphore.getQueueLength()); | ||
} else { | ||
logger.info("Locking of refresh threads disabled (segment: {})", segmentName); | ||
} | ||
} | ||
|
||
public void releaseSema() { | ||
if (_semaphore != null) { | ||
_semaphore.release(); | ||
} | ||
} | ||
} |
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
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.
Do you need to shut down the executor service after it is done?
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.
It should be GCed after ~ 60s (TTL of cached threads). However, it's a good idea to shut it down explicitly. Addressed.