Skip to content

Commit 6a401d8

Browse files
leyangyueshanwchevreuil
authored andcommitted
HBASE-25459 WAL can't be cleaned in some scenes (#2848)
Signed-off-by: Wellington Chevreuil <[email protected]>
1 parent 751431d commit 6a401d8

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,11 @@ ConcurrentMap<ImmutableByteArray, Long> getOrCreateLowestSequenceIds(byte[] enco
249249
*/
250250
private static long getLowestSequenceId(Map<?, Long> sequenceids) {
251251
long lowest = HConstants.NO_SEQNUM;
252-
for (Long sid: sequenceids.values()) {
252+
for (Map.Entry<? , Long> entry : sequenceids.entrySet()){
253+
if (entry.getKey().toString().equals("METAFAMILY")){
254+
continue;
255+
}
256+
Long sid = entry.getValue();
253257
if (lowest == HConstants.NO_SEQNUM || sid.longValue() < lowest) {
254258
lowest = sid.longValue();
255259
}

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ public class TestSequenceIdAccounting {
4242

4343
private static final byte [] ENCODED_REGION_NAME = Bytes.toBytes("r");
4444
private static final byte [] FAMILY_NAME = Bytes.toBytes("cf");
45+
private static final byte [] META_FAMILY = Bytes.toBytes("METAFAMILY");
4546
private static final Set<byte[]> FAMILIES;
47+
private static final Set<byte[]> META_FAMILY_SET;
4648
static {
4749
FAMILIES = new HashSet<>();
4850
FAMILIES.add(FAMILY_NAME);
51+
META_FAMILY_SET = new HashSet<>();
52+
META_FAMILY_SET.add(META_FAMILY);
4953
}
5054

5155
@Test
@@ -117,6 +121,20 @@ public void testAreAllLower() {
117121
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
118122
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
119123
assertTrue(sida.areAllLower(m));
124+
m.put(ENCODED_REGION_NAME, sequenceid);
125+
assertFalse(sida.areAllLower(m));
126+
127+
// Test the METAFAMILY is filtered in SequenceIdAccounting.lowestUnflushedSequenceIds
128+
SequenceIdAccounting meta_sida = new SequenceIdAccounting();
129+
Map<byte[], Long> meta_m = new HashMap<>();
130+
meta_sida.getOrCreateLowestSequenceIds(ENCODED_REGION_NAME);
131+
meta_m.put(ENCODED_REGION_NAME, sequenceid);
132+
meta_sida.update(ENCODED_REGION_NAME, META_FAMILY_SET, ++sequenceid, true);
133+
meta_sida.update(ENCODED_REGION_NAME, META_FAMILY_SET, ++sequenceid, true);
134+
meta_sida.update(ENCODED_REGION_NAME, META_FAMILY_SET, ++sequenceid, true);
135+
assertTrue(meta_sida.areAllLower(meta_m));
136+
meta_m.put(ENCODED_REGION_NAME, sequenceid);
137+
assertTrue(meta_sida.areAllLower(meta_m));
120138
}
121139

122140
@Test

0 commit comments

Comments
 (0)