HBASE-25459 WAL can't be cleaned in some scenes (#2848)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
(cherry picked from commit 6a401d89f8
)
This commit is contained in:
parent
75f5cb2450
commit
aa27488268
|
@ -249,7 +249,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();
|
||||
}
|
||||
|
|
|
@ -42,10 +42,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
|
||||
|
@ -117,6 +121,20 @@ public class TestSequenceIdAccounting {
|
|||
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
|
||||
sida.update(ENCODED_REGION_NAME, FAMILIES, ++sequenceid, true);
|
||||
assertTrue(sida.areAllLower(m));
|
||||
m.put(ENCODED_REGION_NAME, sequenceid);
|
||||
assertFalse(sida.areAllLower(m));
|
||||
|
||||
// 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));
|
||||
meta_m.put(ENCODED_REGION_NAME, sequenceid);
|
||||
assertTrue(meta_sida.areAllLower(meta_m));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue