This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
optional validation of immutable ts on read operations #3414
Merged
gozakdag
merged 8 commits into
develop
from
gozakdag/optional-validation-of-immutable-ts
Aug 16, 2018
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bfca148
validate on reads if necessary
gozakdag c7fe9e4
add tests
gozakdag 3a5f028
renaming
gozakdag bb1bc42
fix merge conflict
gozakdag 2aabe24
adding wrapping task
gozakdag 517ff03
wrapping transaction task to check immutable ts lock
gozakdag 9c4ce05
merge develop, fix conflicts
gozakdag ec4d13f
release notes
gozakdag 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
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
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 |
---|---|---|
|
@@ -218,6 +218,7 @@ private enum State { | |
private final Timer.Context transactionTimerContext; | ||
protected final CommitProfileProcessor commitProfileProcessor; | ||
protected final TransactionOutcomeMetrics transactionOutcomeMetrics; | ||
protected final boolean validateLocksOnReads; | ||
|
||
protected volatile boolean hasReads; | ||
|
||
|
@@ -248,7 +249,8 @@ private enum State { | |
int defaultGetRangesConcurrency, | ||
MultiTableSweepQueueWriter sweepQueue, | ||
ExecutorService deleteExecutor, | ||
CommitProfileProcessor commitProfileProcessor) { | ||
CommitProfileProcessor commitProfileProcessor, | ||
boolean validateLocksOnReads) { | ||
this.metricsManager = metricsManager; | ||
this.transactionTimerContext = getTimer("transactionMillis").time(); | ||
this.keyValueService = keyValueService; | ||
|
@@ -274,6 +276,7 @@ private enum State { | |
this.hasReads = false; | ||
this.commitProfileProcessor = commitProfileProcessor; | ||
this.transactionOutcomeMetrics = TransactionOutcomeMetrics.create(metricsManager); | ||
this.validateLocksOnReads = validateLocksOnReads; | ||
} | ||
|
||
@Override | ||
|
@@ -333,7 +336,7 @@ public SortedMap<byte[], RowResult<byte[]>> getRows(TableReference tableRef, Ite | |
perfLogger.debug("getRows({}, {} rows) found {} rows, took {} ms", | ||
tableRef, Iterables.size(rows), results.size(), getRowsMillis); | ||
} | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
return results; | ||
} | ||
|
||
|
@@ -378,7 +381,7 @@ public Iterator<Map.Entry<Cell, byte[]>> getRowsColumnRange(TableReference table | |
batchHint, | ||
getStartTimestamp()); | ||
if (!rawResults.hasNext()) { | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
} // else the postFiltered iterator will check for each batch. | ||
|
||
Iterator<Map.Entry<byte[], RowColumnRangeIterator>> rawResultsByRow = partitionByRow(rawResults); | ||
|
@@ -431,7 +434,7 @@ protected Iterator<Map.Entry<Cell, byte[]>> computeNext() { | |
rawBuilder.put(result); | ||
} | ||
Map<Cell, Value> raw = rawBuilder.build(); | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
if (raw.isEmpty()) { | ||
return endOfData(); | ||
} | ||
|
@@ -508,7 +511,7 @@ public SortedMap<byte[], RowResult<byte[]>> getRowsIgnoringLocalWrites( | |
ColumnSelection.all(), | ||
getStartTimestamp())); | ||
|
||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
return filterRowResults(tableRef, rawResults, ImmutableMap.builderWithExpectedSize(rawResults.size())); | ||
} | ||
|
||
|
@@ -572,7 +575,7 @@ public Map<Cell, byte[]> get(TableReference tableRef, Set<Cell> cells) { | |
perfLogger.debug("get({}, {} cells) found {} cells (some possibly deleted), took {} ms", | ||
tableRef, cells.size(), result.size(), getMillis); | ||
} | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
return Maps.filterValues(result, Predicates.not(Value.IS_EMPTY)); | ||
} | ||
|
||
|
@@ -585,7 +588,7 @@ public Map<Cell, byte[]> getIgnoringLocalWrites(TableReference tableRef, Set<Cel | |
hasReads = true; | ||
|
||
Map<Cell, byte[]> result = getFromKeyValueService(tableRef, cells); | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
|
||
return Maps.filterValues(result, Predicates.not(Value.IS_EMPTY)); | ||
} | ||
|
@@ -631,7 +634,7 @@ public Iterable<BatchingVisitable<RowResult<byte[]>>> getRanges(final TableRefer | |
Timer.Context timer = getTimer("processedRangeMillis").time(); | ||
Map<RangeRequest, TokenBackedBasicResultsPage<RowResult<Value>, byte[]>> firstPages = | ||
keyValueService.getFirstBatchForRanges(tableRef, input, getStartTimestamp()); | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
|
||
SortedMap<Cell, byte[]> postFiltered = postFilterPages( | ||
tableRef, | ||
|
@@ -747,13 +750,17 @@ protected <K extends Exception> void batchAcceptSizeHint( | |
}; | ||
} | ||
|
||
private void validateExternalAndCommitLocksIfNecessary(TableReference tableRef, long timestamp) { | ||
if (!isValidationNecessary(tableRef)) { | ||
private void validateExternalAndCommitLocksOnReadIfNecessary(TableReference tableRef, long timestamp) { | ||
if (!isValidationNecessaryOnReads(tableRef)) { | ||
return; | ||
} | ||
throwIfPreCommitRequirementsNotMet(null, timestamp); | ||
} | ||
|
||
private boolean isValidationNecessaryOnReads(TableReference tableRef) { | ||
return isValidationNecessary(tableRef) && validateLocksOnReads; | ||
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. probably premature, but if in most usage |
||
} | ||
|
||
private boolean isValidationNecessary(TableReference tableRef) { | ||
return sweepStrategyManager.get().get(tableRef) == SweepStrategy.THOROUGH; | ||
} | ||
|
@@ -902,7 +909,7 @@ protected <T> ClosableIterator<RowResult<T>> postFilterIterator( | |
@Override | ||
protected Iterator<RowResult<T>> computeNext() { | ||
List<RowResult<Value>> batch = results.getBatch(); | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
if (batch.isEmpty()) { | ||
return endOfData(); | ||
} | ||
|
@@ -1131,7 +1138,7 @@ private <T> Map<Cell, Value> getWithPostFilteringInternal(TableReference tableRe | |
|
||
if (!keysToReload.isEmpty()) { | ||
Map<Cell, Value> nextRawResults = keyValueService.get(tableRef, keysToReload); | ||
validateExternalAndCommitLocksIfNecessary(tableRef, getStartTimestamp()); | ||
validateExternalAndCommitLocksOnReadIfNecessary(tableRef, getStartTimestamp()); | ||
return nextRawResults; | ||
} else { | ||
return ImmutableMap.of(); | ||
|
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
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.
nit: can we rename this to
validatePreCommitRequirementsOnReadIfNecessary
? Mainly because this checks the pre-commit conditions too, which may not be 'external locks'