HBASE-25459 WAL can't be cleaned in some scenes (#2848)

Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
This commit is contained in:
xijiawen 2021-01-09 00:00:15 +08:00 committed by GitHub
parent a348204d4a
commit 5c233e9785
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -250,7 +250,11 @@ class SequenceIdAccounting {
*/
private static long getLowestSequenceId(Map<?, Long> sequenceids) {
long lowest = HConstants.NO_SEQNUM;
for (Long sid: sequenceids.values()) {
for (Map.Entry<? , Long> entry : sequenceids.entrySet()){
if (entry.getKey().toString().equals("METAFAMILY")){
continue;
}
Long sid = entry.getValue();
if (lowest == HConstants.NO_SEQNUM || sid.longValue() < lowest) {
lowest = sid.longValue();
}

View File

@ -44,10 +44,14 @@ public class TestSequenceIdAccounting {
private static final byte [] ENCODED_REGION_NAME = Bytes.toBytes("r");
private static final byte [] FAMILY_NAME = Bytes.toBytes("cf");
private static final byte [] META_FAMILY = Bytes.toBytes("METAFAMILY");
private static final Set<byte[]> FAMILIES;
private static final Set<byte[]> META_FAMILY_SET;
static {
FAMILIES = new HashSet<>();
FAMILIES.add(FAMILY_NAME);
META_FAMILY_SET = new HashSet<>();
META_FAMILY_SET.add(META_FAMILY);
}
@Test
@ -123,6 +127,20 @@ public class TestSequenceIdAccounting {
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
assertTrue(sida.areAllLower(m, null));
m.put(ENCODED_REGION_NAME, sequenceid);
assertFalse(sida.areAllLower(m, null));
// Test the METAFAMILY is filtered in SequenceIdAccounting.lowestUnflushedSequenceIds
SequenceIdAccounting meta_sida = new SequenceIdAccounting();
Map<byte[], Long> meta_m = new HashMap<>();
meta_sida.getOrCreateLowestSequenceIds(ENCODED_REGION_NAME);
meta_m.put(ENCODED_REGION_NAME, sequenceid);
meta_sida.update(ENCODED_REGION_NAME, META_FAMILY_SET, ++sequenceid, true);
meta_sida.update(ENCODED_REGION_NAME, META_FAMILY_SET, ++sequenceid, true);
meta_sida.update(ENCODED_REGION_NAME, META_FAMILY_SET, ++sequenceid, true);
assertTrue(meta_sida.areAllLower(meta_m, null));
meta_m.put(ENCODED_REGION_NAME, sequenceid);
assertTrue(meta_sida.areAllLower(meta_m, null));
}
@Test