Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBASE-24183 [flakey test] replication.TestAddToSerialReplicationPeer #1514

Merged
merged 1 commit into from
Apr 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ private void moveRegionAndArchiveOldWals(RegionInfo region, HRegionServer rs) th
rollAllWALs();
}

private void waitUntilReplicatedToTheCurrentWALFile(HRegionServer rs) throws Exception {
private void waitUntilReplicatedToTheCurrentWALFile(HRegionServer rs, final String oldWalName)
throws Exception {
Path path = ((AbstractFSWAL<?>) rs.getWAL(null)).getCurrentFileName();
String logPrefix = AbstractFSWALProvider.getWALPrefixFromWALName(path.getName());
UTIL.waitFor(30000, new ExplainingPredicate<Exception>() {
Expand All @@ -77,7 +78,9 @@ private void waitUntilReplicatedToTheCurrentWALFile(HRegionServer rs) throws Exc
public boolean evaluate() throws Exception {
ReplicationSourceManager manager =
((Replication) rs.getReplicationSourceService()).getReplicationManager();
return manager.getWALs().get(PEER_ID).get(logPrefix).size() == 1;
// Make sure replication moves to the new file.
return (manager.getWALs().get(PEER_ID).get(logPrefix).size() == 1) &&
!oldWalName.equals(manager.getWALs().get(PEER_ID).get(logPrefix).first());
}

@Override
Expand Down Expand Up @@ -124,10 +127,14 @@ public void testChangeToSerial() throws Exception {

RegionInfo region = UTIL.getAdmin().getRegions(tableName).get(0);
HRegionServer srcRs = UTIL.getRSForFirstRegionInTable(tableName);
// Get the current wal file name
String walFileNameBeforeRollover =
((AbstractFSWAL<?>) srcRs.getWAL(null)).getCurrentFileName().getName();

HRegionServer rs = UTIL.getOtherRegionServer(srcRs);
moveRegionAndArchiveOldWals(region, rs);
waitUntilReplicationDone(100);
waitUntilReplicatedToTheCurrentWALFile(srcRs);
waitUntilReplicatedToTheCurrentWALFile(srcRs, walFileNameBeforeRollover);

UTIL.getAdmin().disableReplicationPeer(PEER_ID);
UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID,
Expand Down Expand Up @@ -160,8 +167,16 @@ public void testAddToSerialPeer() throws Exception {
RegionInfo region = UTIL.getAdmin().getRegions(tableName).get(0);
HRegionServer srcRs = UTIL.getRSForFirstRegionInTable(tableName);
HRegionServer rs = UTIL.getOtherRegionServer(srcRs);

// Get the current wal file name
String walFileNameBeforeRollover =
((AbstractFSWAL<?>) srcRs.getWAL(null)).getCurrentFileName().getName();

moveRegionAndArchiveOldWals(region, rs);
waitUntilReplicatedToTheCurrentWALFile(rs);

// Make sure that the replication done for the oldWal at source rs.
waitUntilReplicatedToTheCurrentWALFile(srcRs, walFileNameBeforeRollover);

UTIL.getAdmin().disableReplicationPeer(PEER_ID);
UTIL.getAdmin().updateReplicationPeerConfig(PEER_ID,
ReplicationPeerConfig.newBuilder(peerConfig)
Expand Down