Skip to content

Commit

Permalink
HBASE-24758 Avoid flooding replication source RSes logs when no sinks… (
Browse files Browse the repository at this point in the history
apache#2118)

Signed-off-by: Josh Elser <elserj@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>

(cherry picked from commit 8c0d7fa)
  • Loading branch information
wchevreuil authored and clarax committed Nov 15, 2020
1 parent fe7ff3e commit 927f3e3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ protected static List<ServerName> fetchSlavesAddresses(ZKWatcher zkw)
}

/**
* Get a list of all the addresses of all the region servers
* for this peer cluster
* Get a list of all the addresses of all the available region servers
* for this peer cluster, or an empty list if no region servers available at peer cluster.
* @return list of addresses
*/
// Synchronize peer cluster connection attempts to avoid races and rate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ public class HBaseInterClusterReplicationEndpoint extends HBaseReplicationEndpoi
private boolean dropOnDeletedTables;
private boolean dropOnDeletedColumnFamilies;
private boolean isSerial = false;
//Initialising as 0 to guarantee at least one logging message
private long lastSinkFetchTime = 0;

/*
* Some implementations of HBaseInterClusterReplicationEndpoint may require instantiating
Expand Down Expand Up @@ -518,8 +520,14 @@ public boolean replicate(ReplicateContext replicateContext) {

int numSinks = replicationSinkMgr.getNumSinks();
if (numSinks == 0) {
LOG.warn("{} No replication sinks found, returning without replicating. "
+ "The source should retry with the same set of edits.", logPeerId());
if((System.currentTimeMillis() - lastSinkFetchTime) >= (maxRetriesMultiplier*1000)) {
LOG.warn(
"No replication sinks found, returning without replicating. "
+ "The source should retry with the same set of edits. Not logging this again for "
+ "the next {} seconds.", maxRetriesMultiplier);
lastSinkFetchTime = System.currentTimeMillis();
}
sleepForRetries("No sinks available at peer", sleepMultiplier);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ public synchronized void reportSinkSuccess(SinkPeer sinkPeer) {
*/
public synchronized void chooseSinks() {
List<ServerName> slaveAddresses = endpoint.getRegionServers();
if(slaveAddresses.isEmpty()){
LOG.warn("No sinks available at peer. Will not be able to replicate");
}
Collections.shuffle(slaveAddresses, random);
int numSinks = (int) Math.ceil(slaveAddresses.size() * ratio);
sinks = slaveAddresses.subList(0, numSinks);
Expand Down

0 comments on commit 927f3e3

Please sign in to comment.