Skip to content

Commit 1e6f108

Browse files
committed
HBASE-24758 Avoid flooding replication source RSes logs when no sinks… (#2118)
Signed-off-by: Josh Elser <elserj@apache.org> Signed-off-by: Viraj Jasani <vjasani@apache.org> (cherry picked from commit 8c0d7fa)
1 parent ba70566 commit 1e6f108

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/HBaseReplicationEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ protected static List<ServerName> fetchSlavesAddresses(ZKWatcher zkw)
168168
}
169169

170170
/**
171-
* Get a list of all the addresses of all the region servers
172-
* for this peer cluster
171+
* Get a list of all the addresses of all the available region servers
172+
* for this peer cluster, or an empty list if no region servers available at peer cluster.
173173
* @return list of addresses
174174
*/
175175
// Synchronize peer cluster connection attempts to avoid races and rate

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/HBaseInterClusterReplicationEndpoint.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public class HBaseInterClusterReplicationEndpoint extends HBaseReplicationEndpoi
128128
private boolean dropOnDeletedTables;
129129
private boolean dropOnDeletedColumnFamilies;
130130
private boolean isSerial = false;
131+
//Initialising as 0 to guarantee at least one logging message
132+
private long lastSinkFetchTime = 0;
131133

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

519521
int numSinks = replicationSinkMgr.getNumSinks();
520522
if (numSinks == 0) {
521-
LOG.warn("{} No replication sinks found, returning without replicating. "
522-
+ "The source should retry with the same set of edits.", logPeerId());
523+
if((System.currentTimeMillis() - lastSinkFetchTime) >= (maxRetriesMultiplier*1000)) {
524+
LOG.warn(
525+
"No replication sinks found, returning without replicating. "
526+
+ "The source should retry with the same set of edits. Not logging this again for "
527+
+ "the next {} seconds.", maxRetriesMultiplier);
528+
lastSinkFetchTime = System.currentTimeMillis();
529+
}
530+
sleepForRetries("No sinks available at peer", sleepMultiplier);
523531
return false;
524532
}
525533

hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSinkManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ public synchronized void reportSinkSuccess(SinkPeer sinkPeer) {
160160
*/
161161
public synchronized void chooseSinks() {
162162
List<ServerName> slaveAddresses = endpoint.getRegionServers();
163+
if(slaveAddresses.isEmpty()){
164+
LOG.warn("No sinks available at peer. Will not be able to replicate");
165+
}
163166
Collections.shuffle(slaveAddresses, random);
164167
int numSinks = (int) Math.ceil(slaveAddresses.size() * ratio);
165168
sinks = slaveAddresses.subList(0, numSinks);

0 commit comments

Comments
 (0)