HBASE-25459 WAL can't be cleaned in some scenes (#2848)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
This commit is contained in:
parent
a348204d4a
commit
5c233e9785
|
@ -250,7 +250,11 @@ class SequenceIdAccounting {
|
||||||
*/
|
*/
|
||||||
private static long getLowestSequenceId(Map<?, Long> sequenceids) {
|
private static long getLowestSequenceId(Map<?, Long> sequenceids) {
|
||||||
long lowest = HConstants.NO_SEQNUM;
|
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) {
|
if (lowest == HConstants.NO_SEQNUM || sid.longValue() < lowest) {
|
||||||
lowest = sid.longValue();
|
lowest = sid.longValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,10 +44,14 @@ public class TestSequenceIdAccounting {
|
||||||
|
|
||||||
private static final byte [] ENCODED_REGION_NAME = Bytes.toBytes("r");
|
private static final byte [] ENCODED_REGION_NAME = Bytes.toBytes("r");
|
||||||
private static final byte [] FAMILY_NAME = Bytes.toBytes("cf");
|
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[]> FAMILIES;
|
||||||
|
private static final Set<byte[]> META_FAMILY_SET;
|
||||||
static {
|
static {
|
||||||
FAMILIES = new HashSet<>();
|
FAMILIES = new HashSet<>();
|
||||||
FAMILIES.add(FAMILY_NAME);
|
FAMILIES.add(FAMILY_NAME);
|
||||||
|
META_FAMILY_SET = new HashSet<>();
|
||||||
|
META_FAMILY_SET.add(META_FAMILY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -123,6 +127,20 @@ public class TestSequenceIdAccounting {
|
||||||
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
|
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
|
||||||
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
|
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
|
||||||
assertTrue(sida.areAllLower(m, null));
|
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
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue