From 95661df2515aa5241b95e0e532d1415ad4dd1b86 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Cryans Date: Thu, 17 Mar 2011 23:45:38 +0000 Subject: [PATCH] HBASE-3664 [replication] Adding a slave when there's none may kill the cluster git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1082752 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + .../regionserver/ReplicationSourceManager.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 93b9559463b..788a43a49b1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -145,6 +145,7 @@ Release 0.90.2 - Unreleased HBASE-3650 HBA.delete can return too fast HBASE-3659 Fix TestHLog to pass on newer versions of Hadoop HBASE-3595 get_counter broken in shell + HBASE-3664 [replication] Adding a slave when there's none may kill the cluster IMPROVEMENTS HBASE-3542 MultiGet methods in Thrift diff --git a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java index 239d7752371..2d533e3272a 100644 --- a/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java +++ b/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java @@ -228,12 +228,16 @@ public class ReplicationSourceManager { LOG.warn("Replication stopped, won't add new log"); return; } - - if (this.sources.size() > 0) { - this.zkHelper.addLogToList(newLog.getName(), - this.sources.get(0).getPeerClusterZnode()); - } + synchronized (this.hlogs) { + if (this.sources.size() > 0) { + this.zkHelper.addLogToList(newLog.getName(), + this.sources.get(0).getPeerClusterZnode()); + } else { + // If there's no slaves, don't need to keep the old hlogs since + // we only consider the last one when a new slave comes in + this.hlogs.clear(); + } this.hlogs.add(newLog.getName()); } this.latestPath = newLog;