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

HBASE-26901 delete with null columnQualifier occurs NullPointerException when NewVersionBehavior is on #4295

Merged
merged 4 commits into from
Apr 12, 2022
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 @@ -165,18 +165,15 @@ protected DeleteVersionsNode getDeepCopy() {
* Else return MAX_VALUE.
*/
protected long prepare(Cell cell) {
boolean matchCq =
PrivateCellUtil.matchingQualifier(cell, lastCqArray, lastCqOffset, lastCqLength);
if (!matchCq) {
if (isColumnQualifierChanged(cell)) {
// The last cell is family-level delete and this is not, or the cq is changed,
// we should construct delColMap as a deep copy of delFamMap.
delColMap.clear();
for (Map.Entry<Long, DeleteVersionsNode> e : delFamMap.entrySet()) {
delColMap.put(e.getKey(), e.getValue().getDeepCopy());
}
countCurrentCol = 0;
}
if (matchCq && !PrivateCellUtil.isDelete(lastCqType) && lastCqType == cell.getTypeByte()
} else if (!PrivateCellUtil.isDelete(lastCqType) && lastCqType == cell.getTypeByte()
&& lastCqTs == cell.getTimestamp()) {
// Put with duplicate timestamp, ignore.
return lastCqMvcc;
Expand All @@ -190,6 +187,15 @@ protected long prepare(Cell cell) {
return Long.MAX_VALUE;
}

private boolean isColumnQualifierChanged(Cell cell) {
if (delColMap.isEmpty() && lastCqArray == null && cell.getQualifierLength() == 0
&& (PrivateCellUtil.isDeleteColumns(cell) || PrivateCellUtil.isDeleteColumnVersion(cell))) {
// for null columnQualifier
return true;
}
return !PrivateCellUtil.matchingQualifier(cell, lastCqArray, lastCqOffset, lastCqLength);
}

// DeleteTracker
@Override
public void add(Cell cell) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import java.io.IOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
Expand Down Expand Up @@ -358,4 +359,14 @@ public void testRawScanAndMajorCompaction() throws IOException {
}
}

@Test
public void testNullColumnQualifier() throws IOException {
try (Table t = createTable()) {
Delete del = new Delete(ROW);
del.addColumn(FAMILY, null);
t.delete(del);
Result r = t.get(new Get(ROW)); //NPE
assertTrue(r.isEmpty());
}
}
}