You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Duo Zhang (Jira)" <ji...@apache.org> on 2025/06/06 15:44:00 UTC

[jira] [Commented] (HBASE-29380) Two concurrent remove peer requests may hang

    [ https://issues.apache.org/jira/browse/HBASE-29380?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17956627#comment-17956627 ] 

Duo Zhang commented on HBASE-29380:
-----------------------------------

OK, I found the problem.

If both RemovePeerProcedure are polled out to run, one of the procedure will be waiting in the LockAndQueue object, and then when executing a sub procedure of RemovePeerProcedure, in its cleanup step, we will call MasterProcedureScheduler.tryCleanupPeerQueue, the code is like

{code}
  private void tryCleanupPeerQueue(String peerId, Procedure<?> procedure) {
    schedLock();
    try {
      PeerQueue queue = AvlTree.get(peerMap, peerId, PEER_QUEUE_KEY_COMPARATOR);
      if (queue == null) {
        return;
      }

      final LockAndQueue lock = locking.getPeerLock(peerId);
      if (queue.isEmpty() && lock.tryExclusiveLock(procedure)) { <===== this line is the problem
        removeFromRunQueue(peerRunQueue, queue,
          () -> "clean up peer queue after " + procedure + " completed");
        removePeerQueue(peerId);
      }
    } finally {
      schedUnlock();
    }
  }
{code}

There are basically two problems, first, now in tryExclusiveLock, if the procedure can inherit exclusive lock from parent procedure, even if it does not hold the exclusive lock, this method will return true. And also, we may still have some procedures waiting in the lock object's waiting queue. So here after call removePeerQueue, the LockAndQueue object will be cleared, then the procedures in its waiting queue will never be waked up.

I think the logic here is incorrect after we changed a bunch of the semantics, we need to revisit when can we clean up the run queue and the lock...

Thanks.

> Two concurrent remove peer requests may hang
> --------------------------------------------
>
>                 Key: HBASE-29380
>                 URL: https://issues.apache.org/jira/browse/HBASE-29380
>             Project: HBase
>          Issue Type: Bug
>          Components: proc-v2, Replication
>            Reporter: Duo Zhang
>            Assignee: Duo Zhang
>            Priority: Critical
>
> TestAsyncReplicationAdminApi fails about 75% on flaky dashboard.
> Tried locally, sometimes testRemovePeerTableCFs may hang.
> The situation here is that, at the end of this test method, we will call
> admin.removeReplicationPeer(ID_ONE);
> The admin here is an AsyncAdmin, so it will return immediately, and then in the Junit's AFter methods, we will call
> admin.removeReplicationPeer(ID_ONE).join();
> Sometimes, if the first request runs first, the remove peer procedure for the second one will not wake up so we hang there forever.
> Need to dig more.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)