[ https://issues.apache.org/jira/browse/HDFS-17384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17908260#comment-17908260 ]
ASF GitHub Bot commented on HDFS-17384: --------------------------------------- ZanderXu commented on PR #6762: URL: https://github.com/apache/hadoop/pull/6762#issuecomment-2562240142 > I know this PR is phase 1 work: split global lock into fslock and bmlock. We should ensure the lock order: bmlock cannot occur in front of fslock. Can we add some restrictions or check mechanisms to avoid getting a bmlock before fslock? Thanks, @zhengchenyu . This is a good idea. The check mechanism is theoretically feasible (verifying whether the BMLock is already held when acquiring the FSLock). However, due to lock reentry, this approach introduces complexity and negatively impacts the performance. Let's briefly consider some common scenarios: 1. A thread acquires the FS read lock for the first time. 2. A thread acquires the FS write lock for the first time. 3. A thread holding the Global read lock reenters the FS read lock (already holding the BM read lock). 4. A thread holding the Global write lock reenters the FS read lock (already holding the BM write lock). 5. A thread holding the Global write lock reenters the FS write lock (already holding the BM write lock). In scenarios 3, 4, and 5, the BM lock already held is normal when acquiring FS lock. However, in scenarios 1 and 2, the BM lock already held is abnormal when acquiring FS lock. Indeed, lock reentry can also be checked, but I think it’s unnecessary as it’s overly complicated. We can use other methods to detect deadlock issues. > [FGL] Replace the global lock with global FS Lock and global BM lock > -------------------------------------------------------------------- > > Key: HDFS-17384 > URL: https://issues.apache.org/jira/browse/HDFS-17384 > Project: Hadoop HDFS > Issue Type: Improvement > Reporter: ZanderXu > Assignee: ZanderXu > Priority: Major > Labels: FGL, pull-request-available > > First, we can replace the current global lock with two locks, global FS lock > and global BM lock. > The global FS lock is used to make directory tree-related operations > thread-safe. > The global BM lock is used to make block-related operations and DN-related > operations thread-safe. > > For some operations involving both directory tree and block or DN, the global > FS lock and the global BM lock are acquired. > > The lock order should be: > * The global FS lock > * The global BM lock > > There are some special requirements for this ticket. > * End-user can choose to use global lock or fine-grained lock through > configuration. > * Try not to modify the current implementation logic as much as possible. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org