Skip to content

Commit f718c8a

Browse files
virajjasaniwenwj0
authored andcommitted
Revert "HBASE-25709 Close region may stuck when region is compacting and skipped most cells read (apache#3117)" (apache#4524)
This reverts commit f3a48d1. Signed-off-by: Andrew Purtell <apurtell@apache.org>
1 parent 2a195e6 commit f718c8a

File tree

3 files changed

+0
-142
lines changed

3 files changed

+0
-142
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,11 +749,6 @@ public boolean next(List<Cell> outResult, ScannerContext scannerContext) throws
749749
default:
750750
throw new RuntimeException("UNEXPECTED");
751751
}
752-
753-
// when reaching the heartbeat cells, try to return from the loop.
754-
if (kvsScanned % cellsPerHeartbeatCheck == 0) {
755-
return scannerContext.setScannerState(NextState.MORE_VALUES).hasMoreValues();
756-
}
757752
} while ((cell = this.heap.peek()) != null);
758753

759754
if (count > 0) {

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHRegion.java

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6923,74 +6923,6 @@ public void testCellTTLs() throws IOException {
69236923
assertNull(r.getValue(fam1, q1));
69246924
}
69256925

6926-
@Test
6927-
public void testTTLsUsingSmallHeartBeatCells() throws IOException {
6928-
IncrementingEnvironmentEdge edge = new IncrementingEnvironmentEdge();
6929-
EnvironmentEdgeManager.injectEdge(edge);
6930-
6931-
final byte[] row = Bytes.toBytes("testRow");
6932-
final byte[] q1 = Bytes.toBytes("q1");
6933-
final byte[] q2 = Bytes.toBytes("q2");
6934-
final byte[] q3 = Bytes.toBytes("q3");
6935-
final byte[] q4 = Bytes.toBytes("q4");
6936-
final byte[] q5 = Bytes.toBytes("q5");
6937-
final byte[] q6 = Bytes.toBytes("q6");
6938-
final byte[] q7 = Bytes.toBytes("q7");
6939-
final byte[] q8 = Bytes.toBytes("q8");
6940-
6941-
// 10 seconds
6942-
int ttlSecs = 10;
6943-
TableDescriptor tableDescriptor =
6944-
TableDescriptorBuilder.newBuilder(TableName.valueOf(name.getMethodName())).setColumnFamily(
6945-
ColumnFamilyDescriptorBuilder.newBuilder(fam1).setTimeToLive(ttlSecs).build()).build();
6946-
6947-
Configuration conf = new Configuration(TEST_UTIL.getConfiguration());
6948-
conf.setInt(HFile.FORMAT_VERSION_KEY, HFile.MIN_FORMAT_VERSION_WITH_TAGS);
6949-
// using small heart beat cells
6950-
conf.setLong(StoreScanner.HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK, 2);
6951-
6952-
region = HBaseTestingUtil.createRegionAndWAL(
6953-
RegionInfoBuilder.newBuilder(tableDescriptor.getTableName()).build(),
6954-
TEST_UTIL.getDataTestDir(), conf, tableDescriptor);
6955-
assertNotNull(region);
6956-
long now = EnvironmentEdgeManager.currentTime();
6957-
// Add a cell that will expire in 5 seconds via cell TTL
6958-
region.put(new Put(row).addColumn(fam1, q1, now, HConstants.EMPTY_BYTE_ARRAY));
6959-
region.put(new Put(row).addColumn(fam1, q2, now, HConstants.EMPTY_BYTE_ARRAY));
6960-
region.put(new Put(row).addColumn(fam1, q3, now, HConstants.EMPTY_BYTE_ARRAY));
6961-
// Add a cell that will expire after 10 seconds via family setting
6962-
region
6963-
.put(new Put(row).addColumn(fam1, q4, now + ttlSecs * 1000 + 1, HConstants.EMPTY_BYTE_ARRAY));
6964-
region
6965-
.put(new Put(row).addColumn(fam1, q5, now + ttlSecs * 1000 + 1, HConstants.EMPTY_BYTE_ARRAY));
6966-
6967-
region.put(new Put(row).addColumn(fam1, q6, now, HConstants.EMPTY_BYTE_ARRAY));
6968-
region.put(new Put(row).addColumn(fam1, q7, now, HConstants.EMPTY_BYTE_ARRAY));
6969-
region
6970-
.put(new Put(row).addColumn(fam1, q8, now + ttlSecs * 1000 + 1, HConstants.EMPTY_BYTE_ARRAY));
6971-
6972-
// Flush so we are sure store scanning gets this right
6973-
region.flush(true);
6974-
6975-
// A query at time T+0 should return all cells
6976-
checkScan(8);
6977-
6978-
// Increment time to T+ttlSecs seconds
6979-
edge.incrementTime(ttlSecs * 1000);
6980-
checkScan(3);
6981-
}
6982-
6983-
private void checkScan(int expectCellSize) throws IOException {
6984-
Scan s = new Scan().withStartRow(row);
6985-
ScannerContext.Builder contextBuilder = ScannerContext.newBuilder(true);
6986-
ScannerContext scannerContext = contextBuilder.build();
6987-
RegionScanner scanner = region.getScanner(s);
6988-
List<Cell> kvs = new ArrayList<>();
6989-
scanner.next(kvs, scannerContext);
6990-
assertEquals(expectCellSize, kvs.size());
6991-
scanner.close();
6992-
}
6993-
69946926
@Test
69956927
public void testIncrementTimestampsAreMonotonic() throws IOException {
69966928
region = initHRegion(tableName, method, CONF, fam1);

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestHStore.java

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,75 +1258,6 @@ public long getSmallestReadPoint(HStore store) {
12581258
}
12591259
}
12601260

1261-
@Test
1262-
public void testPreventLoopRead() throws Exception {
1263-
init(this.name.getMethodName());
1264-
Configuration conf = HBaseConfiguration.create();
1265-
// use small heart beat cells
1266-
conf.setLong(StoreScanner.HBASE_CELLS_SCANNED_PER_HEARTBEAT_CHECK, 2);
1267-
IncrementingEnvironmentEdge edge = new IncrementingEnvironmentEdge();
1268-
EnvironmentEdgeManager.injectEdge(edge);
1269-
byte[] r0 = Bytes.toBytes("row0");
1270-
byte[] value0 = Bytes.toBytes("value0");
1271-
byte[] value1 = Bytes.toBytes("value1");
1272-
MemStoreSizing memStoreSizing = new NonThreadSafeMemStoreSizing();
1273-
long ts = EnvironmentEdgeManager.currentTime();
1274-
long seqId = 100;
1275-
init(name.getMethodName(), conf, TableDescriptorBuilder.newBuilder(TableName.valueOf(table)),
1276-
ColumnFamilyDescriptorBuilder.newBuilder(family).setTimeToLive(10).build(),
1277-
new MyStoreHook() {
1278-
@Override
1279-
public long getSmallestReadPoint(HStore store) {
1280-
return seqId + 3;
1281-
}
1282-
});
1283-
// The cells having the value0 will be expired
1284-
store.add(createCell(r0, qf1, ts, seqId, value0), memStoreSizing);
1285-
store.add(createCell(r0, qf2, ts, seqId, value0), memStoreSizing);
1286-
store.add(createCell(r0, qf3, ts, seqId, value0), memStoreSizing);
1287-
store.add(createCell(r0, qf4, ts + 10000 + 1, seqId, value1), memStoreSizing);
1288-
store.add(createCell(r0, qf5, ts, seqId, value0), memStoreSizing);
1289-
store.add(createCell(r0, qf6, ts + 10000 + 1, seqId, value1), memStoreSizing);
1290-
1291-
List<Cell> myList = new ArrayList<>();
1292-
Scan scan = new Scan().withStartRow(r0);
1293-
ScannerContext.Builder contextBuilder = ScannerContext.newBuilder(false);
1294-
// test normal scan, should return all the cells
1295-
ScannerContext scannerContext = contextBuilder.build();
1296-
try (InternalScanner scanner = (InternalScanner) store.getScanner(scan, null, seqId + 3)) {
1297-
scanner.next(myList, scannerContext);
1298-
assertEquals(6, myList.size());
1299-
}
1300-
1301-
// test skip two ttl cells and return with empty results, default prevent loop skip is on
1302-
edge.incrementTime(10 * 1000);
1303-
scannerContext = contextBuilder.build();
1304-
myList.clear();
1305-
try (InternalScanner scanner = (InternalScanner) store.getScanner(scan, null, seqId + 3)) {
1306-
// r0
1307-
scanner.next(myList, scannerContext);
1308-
assertEquals(0, myList.size());
1309-
}
1310-
1311-
// should scan all non-ttl expired cells by iterative next
1312-
int resultCells = 0;
1313-
try (InternalScanner scanner = (InternalScanner) store.getScanner(scan, null, seqId + 3)) {
1314-
boolean hasMore = true;
1315-
while (hasMore) {
1316-
myList.clear();
1317-
hasMore = scanner.next(myList, scannerContext);
1318-
assertTrue(myList.size() < 6);
1319-
resultCells += myList.size();
1320-
}
1321-
for (Cell c : myList) {
1322-
byte[] actualValue = CellUtil.cloneValue(c);
1323-
assertTrue("expected:" + Bytes.toStringBinary(value1) + ", actual:"
1324-
+ Bytes.toStringBinary(actualValue), Bytes.equals(actualValue, value1));
1325-
}
1326-
}
1327-
assertEquals(2, resultCells);
1328-
}
1329-
13301261
@Test
13311262
public void testCreateScannerAndSnapshotConcurrently() throws IOException, InterruptedException {
13321263
Configuration conf = HBaseConfiguration.create();

0 commit comments

Comments
 (0)