anoopsjohn commented on a change in pull request #603: HBASE-22965 RS Crash due
to DBE reference to an reused ByteBuff
URL: https://github.com/apache/hbase/pull/603#discussion_r329007832
##########
File path:
hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestHFile.java
##########
@@ -760,5 +763,30 @@ public void testGetShortMidpoint() {
0, expectedArray.length);
}
+ @Test
+ public void testDBEShipped() throws IOException {
+ for (DataBlockEncoding encoding : DataBlockEncoding.values()) {
+ DataBlockEncoder encoder = encoding.getEncoder();
+ if (encoder == null) {
+ continue;
+ }
+ Path f = new Path(ROOT_DIR, testName.getMethodName() + "_" + encoding);
+ HFileContext context = new HFileContextBuilder()
+ .withIncludesTags(false)
+ .withDataBlockEncoding(encoding).build();
+ HFileWriterImpl writer = (HFileWriterImpl) HFile.getWriterFactory(conf,
cacheConf)
+ .withPath(fs, f).withFileContext(context).create();
+
+ KeyValue kv = new KeyValue(Bytes.toBytes("testkey"),
Bytes.toBytes("family"),
+ Bytes.toBytes("qual"), Bytes.toBytes("testvalue"));
+ ByteBuffer buffer = ByteBuffer.wrap(kv.getBuffer());
+ ByteBufferKeyValue bbCell = new ByteBufferKeyValue(buffer, 0,
buffer.remaining());
+ writer.append(bbCell);
+ writer.beforeShipped();
+
+ Cell cell = writer.blockWriter.getEncodingState().getLastCell();
+ assertTrue(cell instanceof KeyValue);
Review comment:
The UT is not really doing a meaningful test. Write a cell first and then
pollute its backing ByteBuffer by directly manipulating few bytes which comes
at some KeyLen part or so. Then write another cell. Call the beforeShipped()
before manipulating this 1st BB. With out the patch, we will end up in some
issues. The patch should fix it.
Even we can remove all these new getters exposed in different classes for
testing.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services