-
Notifications
You must be signed in to change notification settings - Fork 124
[vpj]: Always refresh storage quota to honor mid-push quota changes #2912
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
eldernewborn
wants to merge
5
commits into
linkedin:main
from
eldernewborn:eldernewborn/refresh-quota-before-exceed-check
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
70d522c
[vpj]: Refresh quota before quota exceeded
b600906
[vpj]: Always refresh storage quota to honor mid-push quota changes
fcab8fa
[vpj]: Gate quota refresh skip on repush to enforce mid-push reductions
5e1cb7d
[vpj]: Refresh quota at driver check with truncation-aware guard
e7ecb1c
[vpj]: Clarify quota-exceeded message for mid-push increase and trunc…
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1910,8 +1910,37 @@ String updatePushJobDetailsWithJobDetails(DataWriterTaskTracker dataWriterTaskTr | |
| // Quota exceeded | ||
| final long totalInputDataSizeInBytes = | ||
| dataWriterTaskTracker.getTotalKeySize() + dataWriterTaskTracker.getTotalValueSize(); | ||
| if (inputStorageQuotaTracker.exceedQuota(totalInputDataSizeInBytes)) { | ||
| // Re-fetch the store quota from the controller so a mid-push quota change is honored. The store | ||
| // quota can be raised (or lowered) while a push is running; because this driver-side check runs | ||
| // after the data writer job completes, refreshing here lets the push reflect the current quota. | ||
| // | ||
| // Safety for engines that truncate data beyond the quota while writing (e.g. MapReduce): such | ||
| // engines drop records once the job-start quota is hit, leaving a partial dataset on the topic. For | ||
| // those we must NOT accept a mid-push increase, or we would promote an incomplete version. Spark | ||
| // never truncates (the full dataset is always written), so accepting an increase is safe. | ||
| final long quotaUsedByWriters = pushJobSetting.storeStorageQuota; | ||
| refreshStorageQuota(); | ||
| // If the engine is unknown (null) assume it truncates (fail-safe); Spark reports false, MR true. | ||
| final boolean writersMayHaveTruncated = | ||
| (dataWriterComputeJob == null || dataWriterComputeJob.truncatesDataExceedingQuota()) | ||
| && new InputStorageQuotaTracker(quotaUsedByWriters).exceedQuota(totalInputDataSizeInBytes); | ||
| final boolean refreshedQuotaExceeded = inputStorageQuotaTracker.exceedQuota(totalInputDataSizeInBytes); | ||
| if (refreshedQuotaExceeded || writersMayHaveTruncated) { | ||
| updatePushJobDetailsWithCheckpoint(PushJobCheckpoints.QUOTA_EXCEEDED); | ||
| if (writersMayHaveTruncated && !refreshedQuotaExceeded) { | ||
| // The current quota now covers the input, but the writers already truncated the dataset against | ||
| // the quota that was in effect when the job started, so this version is incomplete. The operator | ||
| // does not need more quota (they may have already raised it) — they need to re-run the push. | ||
| return String.format( | ||
| "Storage quota exceeded while writing the data. The store quota when the push started was %s" | ||
| + " and the input data size is %s, so the data writer truncated the dataset. The quota has" | ||
| + " since been increased to %s; please re-run the push to write the complete dataset.", | ||
| generateHumanReadableByteCountString(quotaUsedByWriters), | ||
| generateHumanReadableByteCountString(totalInputDataSizeInBytes), | ||
| generateHumanReadableByteCountString(inputStorageQuotaTracker.getStoreStorageQuota())); | ||
| } | ||
| // Report the shortfall against the current (refreshed) store quota so the operator requests the | ||
| // right amount. | ||
| Long storeQuota = inputStorageQuotaTracker.getStoreStorageQuota(); | ||
| return String.format( | ||
| "Storage quota exceeded. Store quota %s, Input data size %s." | ||
|
|
@@ -1959,6 +1988,54 @@ String updatePushJobDetailsWithJobDetails(DataWriterTaskTracker dataWriterTaskTr | |
| return null; | ||
| } | ||
|
|
||
| /** | ||
| * Re-fetch the store storage quota from the controller and update the quota tracker if it changed. | ||
| * This is invoked from the driver-side quota check ({@link #updatePushJobDetailsWithJobDetails}) after | ||
| * the data writer job completes, so a quota change that happened while the push was running is honored. | ||
| * | ||
| * <p>This performs a targeted quota-only fetch and intentionally does not reuse | ||
| * {@link #getStoreResponse(String, boolean)} so it won't mutate the other cached store settings | ||
| * (compression strategy, chunking, max record size, etc.). | ||
| * | ||
| * <p>Repush jobs (source Kafka) deliberately set the quota to {@link Store#UNLIMITED_STORAGE_QUOTA} | ||
| * to skip the quota check, so those are left untouched. If the controller call fails, the cached | ||
| * quota is retained so a transient controller error does not derail the push. | ||
| */ | ||
| private void refreshStorageQuota() { | ||
| // Repush (source Kafka) intentionally disables the quota check; don't re-fetch and re-enable it. | ||
| // Note: this is gated on isSourceKafka rather than the quota value, so a regular store that is | ||
| // genuinely configured with an unlimited quota is still refreshed and a mid-push reduction to a | ||
| // finite quota is honored. | ||
| if (pushJobSetting.isSourceKafka) { | ||
| return; | ||
| } | ||
| try { | ||
| StoreResponse storeResponse = ControllerClient.retryableRequest( | ||
| controllerClient, | ||
| pushJobSetting.controllerRetries, | ||
| c -> c.getStore(pushJobSetting.storeName)); | ||
| if (storeResponse.isError()) { | ||
| LOGGER.warn( | ||
| "Failed to refresh storage quota for store {} from controller: {}. Using cached value.", | ||
|
Contributor
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. super nit: might be better to include the cached value pushJobSetting.storeStorageQuota in the log like below |
||
| pushJobSetting.storeName, | ||
| storeResponse.getError()); | ||
| return; | ||
| } | ||
| long freshQuota = storeResponse.getStore().getStorageQuotaInByte(); | ||
| if (freshQuota != pushJobSetting.storeStorageQuota) { | ||
| LOGGER.info( | ||
| "Storage quota for store {} changed during push from {} to {}.", | ||
| pushJobSetting.storeName, | ||
| pushJobSetting.storeStorageQuota, | ||
| freshQuota); | ||
| pushJobSetting.storeStorageQuota = freshQuota; | ||
| inputStorageQuotaTracker = new InputStorageQuotaTracker(freshQuota); | ||
| } | ||
| } catch (Exception e) { | ||
| LOGGER.warn("Failed to refresh storage quota from controller. Using cached value.", e); | ||
| } | ||
| } | ||
|
|
||
| /* Helper function to format part of the record too large compression status */ | ||
| private String formatRecordTooLargeCompressionStatus() { | ||
| if (this.pushJobSetting.storeCompressionStrategy != null | ||
|
|
||
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
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
Oops, something went wrong.
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.
super nit: if the refresh is after the calculation, then a new object
InputStorageQuotaTrackershouldn't need to be created right?