Skip to content
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

[PINOT-6701] Controller API to check storage quota before segment upload #3068

Closed
wants to merge 1 commit into from

Conversation

sunithabeeram
Copy link
Contributor

Expose a controller API to check storage quota before segments are uploaded. The API expects, as a query parameter, the uncompressed size of all segments that are to be uploaded. The API accounts for the appropriate push-type (refresh vs append) and whether the segments to be uploaded have indices or not and returns whether the upload can go through or not.

Eventually, we will drop the quota checks that are done per segment and expect all push jobs to call this API before starting the upload. That will save a lot of unnecessary calls to the servers for get table sizes as well as prevent partial uploads if the size is exceeded mid way through the segments push.

Testing Done: added integration test that covers the append use-case upload. Plan to add more after initial review.

@codecov-io
Copy link

Codecov Report

Merging #3068 into master will increase coverage by 0.05%.
The diff coverage is 56.09%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #3068      +/-   ##
============================================
+ Coverage     70.29%   70.34%   +0.05%     
  Complexity        4        4              
============================================
  Files           935      936       +1     
  Lines         43471    43511      +40     
  Branches       5894     5901       +7     
============================================
+ Hits          30556    30606      +50     
+ Misses        10869    10845      -24     
- Partials       2046     2060      +14
Impacted Files Coverage Δ Complexity Δ
...not/controller/validation/StorageQuotaChecker.java 79.71% <100%> (+1.44%) 0 <0> (ø) ⬇️
...ontroller/api/resources/TableUploadQuotaCheck.java 55% <55%> (ø) 0 <0> (?)
...lix/EmptyBrokerOnlineOfflineStateModelFactory.java 86.66% <0%> (-13.34%) 0% <0%> (ø)
...m/linkedin/pinot/broker/queryquota/HitCounter.java 92.3% <0%> (-7.7%) 0% <0%> (ø)
...kedin/pinot/core/util/SortedRangeIntersection.java 83.82% <0%> (-7.36%) 0% <0%> (ø)
...e/impl/dictionary/LongOnHeapMutableDictionary.java 88.88% <0%> (-6.67%) 0% <0%> (ø)
...impl/dictionary/FloatOffHeapMutableDictionary.java 87.27% <0%> (-5.46%) 0% <0%> (ø)
...not/core/query/pruner/DataSchemaSegmentPruner.java 66.66% <0%> (-4.45%) 0% <0%> (ø)
...r/filter/predicate/PredicateEvaluatorProvider.java 65.21% <0%> (-4.35%) 0% <0%> (ø)
...inot/transport/netty/NettyTCPClientConnection.java 82.31% <0%> (-3.41%) 0% <0%> (ø)
... and 25 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3147d2a...cafa123. Read the comment docs.

public void testUploadQuotaCheck() throws Exception {
try {
// upload 1G
sendGetRequest(_controllerBaseApiUrl + "/tables/mytable/checkQuotaForUpload?size=1000000000");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add an Assert.fail(); statement after this line.

@ApiResponse(code = 413, message = "Proposed upload size too large"),
@ApiResponse(code = 500, message = "Internal server error")})
public SuccessResponse checkQuotaForUpload(
@ApiParam(value = "Table name without type", required = true, example = "myTable")
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be good to add some logic to check whether the input tableName contains suffix.

ZKMetadataProvider.getOfflineTableConfig(_pinotHelixResourceManager.getPropertyStore(), offlineTableName);
if (offlineTableConfig == null) {
throw new ControllerApplicationException(LOGGER,
"Table: " + tableName + "not found", Response.Status.NOT_FOUND);
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a space before "not found".

if (!offlineTableConfig.getIndexingConfig().isCreateInvertedIndexDuringSegmentGeneration()) {
if (!offlineTableConfig.getIndexingConfig().getInvertedIndexColumns().isEmpty()) {
size = size + (long)(size * INDEX_RATIO);
LOGGER.info("Size (in bytes) estimate with indices included is ", size);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please log the tableName here as well.

}

if (tableSizeDetails.estimatedSizeInBytes + uploadSizeForAllReplicas > configured) {
String message = "Upload of " + DataSize.fromBytes(size) + " will exceed quota. Estimated append size "
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's best to use String.format() to form the String.

@npawar npawar closed this May 22, 2020
@npawar
Copy link
Contributor

npawar commented May 22, 2020

Closed this PR due to 6 months inactivity. Reopen if needed.

@Jackie-Jiang Jackie-Jiang deleted the quotaCheckAPI branch August 25, 2020 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants