diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java index 028ab76..19f7afc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HColumnDescriptor.java @@ -1097,8 +1097,24 @@ public class HColumnDescriptor implements Comparable { public int compareTo(HColumnDescriptor o) { int result = Bytes.compareTo(this.name, o.getName()); if (result == 0) { - // punt on comparison for ordering, just calculate difference - result = this.values.hashCode() - o.values.hashCode(); + + // Comparing REPLICATION_SCOPE of two tables breaks the master-master (cyclic) replication + // scenario. We should ignore the difference in REPLICATION_SCOPE especially when the + // replication is not already enabled on the desired table. + // + Map leftValues = new HashMap(this.values); + + // Match the value of REPLICATION_SCOPE property of the two tables + // so that we can compare other properties and ignore REPLICATION_SCOPE. + // + if (o.values.get(new Bytes(REPLICATION_SCOPE_BYTES)).toString().equals("0")) { + leftValues.put(new Bytes(REPLICATION_SCOPE_BYTES), + o.values.get(new Bytes(REPLICATION_SCOPE_BYTES))); + } + + // punt on comparison for ordering, just calculate difference. + // + result = leftValues.hashCode() - o.values.hashCode(); if (result < 0) result = -1; else if (result > 0)