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

TEZ-4542: Tez application may fail due to int overflow when record size is large and sort memory is low. #336

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void sort() throws IOException {
}
Preconditions.checkArgument(buffers.get(bufferIndex) != null, "block should not be empty");
//TODO: fix per item being passed.
span = new SortSpan((ByteBuffer)buffers.get(bufferIndex).clear(), (1024*1024),
span = new SortSpan((ByteBuffer)buffers.get(bufferIndex).clear(), items,
perItem, ConfigUtils.getIntermediateOutputKeyComparator(this.conf));
} else {
// queue up the sort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,32 @@ public void testWithLargeKeyValueWithMinBlockSize() throws IOException {
basicTest(1, 5, (2 << 20), (48 * 1024l * 1024l), 16 << 20);
}

@Test
public void testWithLargeRecordAndLowMemory() throws IOException {
this.numOutputs = 1;
this.initialAvailableMem = 1 * 1024 * 1024;
conf.setBoolean(TezRuntimeConfiguration.TEZ_RUNTIME_ENABLE_FINAL_MERGE_IN_OUTPUT, true);
conf.setInt(TezRuntimeConfiguration.TEZ_RUNTIME_PIPELINED_SORTER_MIN_BLOCK_SIZE_IN_MB, 1);
PipelinedSorter sorter = new PipelinedSorter(this.outputContext, conf, numOutputs, initialAvailableMem);

// Set the record size to exceed 2k to trigger bug described in TEZ-4542.
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 3072; i++) {
builder.append("1");
}
Text value = new Text(builder.toString());
long size = 50 * 1024 * 1024;
while (size > 0) {
Text key = RandomTextGenerator.generateSentence();
sorter.write(key, value);
size -= key.getLength();
}

sorter.flush();
sorter.close();
verifyOutputPermissions(outputContext.getUniqueIdentifier());
}

private void verifyOutputPermissions(String spillId) throws IOException {
String subpath = Constants.TEZ_RUNTIME_TASK_OUTPUT_DIR + "/" + spillId
+ "/" + Constants.TEZ_RUNTIME_TASK_OUTPUT_FILENAME_STRING;
Expand Down
Loading