shahrs87 commented on a change in pull request #2960:
URL: https://github.com/apache/hbase/pull/2960#discussion_r579384941
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSource.java
##########
@@ -792,9 +795,13 @@ protected void shipEdits(WALEntryBatch entryBatch) {
}
private void updateLogPosition(long lastReadPosition) {
- manager.logPositionAndCleanOldLogs(lastLoggedPath, peerClusterZnode,
lastReadPosition,
- this.replicationQueueInfo.isQueueRecovered(), false);
- lastLoggedPosition = lastReadPosition;
+ try {
+ manager.logPositionAndCleanOldLogs(lastLoggedPath, peerClusterZnode,
lastReadPosition,
+ this.replicationQueueInfo.isQueueRecovered(), false);
+ lastLoggedPosition = lastReadPosition;
+ } catch (ReplicationSourceWithoutPeerException re) {
+ source.terminate("Replication peer is removed and source should
terminate", re);
Review comment:
I am not an expert in this so please correct me if I missed anything.
Whenever zk listener is invoked for peersRemoved event, we do the following
things.
https://github.com/apache/hbase/blob/branch-1/hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationTrackerZKImpl.java#L175
https://github.com/apache/hbase/blob/branch-1/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/ReplicationSourceManager.java#L637-L640
One of the steps in ReplicationSourceManager#peerRemoved code path is to
terminate the source but in addition to that it does many things like
removingPeersFromHFileRefs and removing that source from
ReplicationSourceManager#sources and ReplicationSourceManager#oldSources data
structure. If we invoke the source#terminate method directly we will miss all
these cleanup steps.
@apurtell While typing this comment it looks like this patch got merged but
I think we need more changes on this patch.
Cc @sandeepvinayak @wchevreuil
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/replication/ReplicationQueuesZKImpl.java
##########
@@ -132,17 +132,44 @@ public void addLog(String queueId, String filename)
throws ReplicationException
}
@Override
- public void removeLog(String queueId, String filename) {
+ public void removeLog(String queueId, String filename)
+ throws ReplicationSourceWithoutPeerException {
try {
- String znode = ZKUtil.joinZNode(this.myQueuesZnode, queueId);
- znode = ZKUtil.joinZNode(znode, filename);
- ZKUtil.deleteNode(this.zookeeper, znode);
- } catch (KeeperException e) {
- this.abortable.abort("Failed to remove wal from queue (queueId=" +
queueId + ", filename="
- + filename + ")", e);
+ try {
+ String znode = ZKUtil.joinZNode(this.myQueuesZnode, queueId);
+ znode = ZKUtil.joinZNode(znode, filename);
+ ZKUtil.deleteNode(this.zookeeper, znode);
+ } catch (KeeperException.NoNodeException e) {
+ // in case of no node exception we should not crash the region server
+ // but instead check if the replication peer has been removed.
+ // If so, we can throw here so that the source can terminate itself.
+ // This situation can occur when the replication peer znodes has been
+ // removed but the sources not terminated due to any miss from zk node
delete watcher.
+ if (!doesPeerExist(queueId)) {
+ LOG.warn("Replication peer " + queueId + " has been removed", e);
+ throw new ReplicationSourceWithoutPeerException(
+ "Znodes for peer has been delete while a source is still active",
e);
+ } else {
+ throw e;
+ }
+ }
+ } catch (KeeperException ke) {
+ this.abortable.abort(
+ "Failed to remove wal from queue (queueId=" + queueId + ", filename="
+ filename + ")", ke);
}
}
+ private boolean doesPeerExist(String queueId) throws KeeperException {
+ String peerId = queueId;
+ if (peerId.contains("-")) {
+ // queueId will be in the form peerId + "-" + rsZNode.
+ // A peerId will not have "-" in its name, see HBASE-11394
+ peerId = queueId.split("-")[0];
+ }
+
Review comment:
nit: extra line.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]