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

ASF GitHub Bot commented on HADOOP-19918:
-----------------------------------------

hadoop-yetus commented on PR #8969:
URL: https://github.com/apache/hadoop/pull/8969#issuecomment-6804148263

   :confetti_ball: **+1 overall**
   
   
   
   
   
   
   | Vote | Subsystem | Runtime |  Logfile | Comment |
   |:----:|----------:|--------:|:--------:|:-------:|
   | +0 :ok: |  reexec  |   0m 37s |  |  Docker mode activated.  |
   |||| _ Prechecks _ |
   | +1 :green_heart: |  dupname  |   0m  0s |  |  No case conflicting files 
found.  |
   | +0 :ok: |  codespell  |   0m  1s |  |  codespell was not available.  |
   | +0 :ok: |  detsecrets  |   0m  1s |  |  detect-secrets was not available.  
|
   | +1 :green_heart: |  @author  |   0m  0s |  |  The patch does not contain 
any @author tags.  |
   | +1 :green_heart: |  test4tests  |   0m  0s |  |  The patch appears to 
include 2 new or modified test files.  |
   |||| _ trunk Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |  44m 30s |  |  trunk passed  |
   | +1 :green_heart: |  compile  |  16m 32s |  |  trunk passed with JDK 
Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu  |
   | +1 :green_heart: |  compile  |  16m 56s |  |  trunk passed with JDK 
Ubuntu-17.0.20.1+1-1-24.04-Ubuntu  |
   | +1 :green_heart: |  checkstyle  |   1m 33s |  |  trunk passed  |
   | +1 :green_heart: |  mvnsite  |   2m  2s |  |  trunk passed  |
   | +1 :green_heart: |  javadoc  |   1m 32s |  |  trunk passed with JDK 
Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu  |
   | +1 :green_heart: |  javadoc  |   1m 30s |  |  trunk passed with JDK 
Ubuntu-17.0.20.1+1-1-24.04-Ubuntu  |
   | +1 :green_heart: |  spotbugs  |   3m 11s |  |  trunk passed  |
   | +1 :green_heart: |  shadedclient  |  31m 49s |  |  branch has no errors 
when building and testing our client artifacts.  |
   |||| _ Patch Compile Tests _ |
   | +1 :green_heart: |  mvninstall  |   1m 15s |  |  the patch passed  |
   | +1 :green_heart: |  compile  |  15m 56s |  |  the patch passed with JDK 
Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu  |
   | +1 :green_heart: |  javac  |  15m 56s |  |  the patch passed  |
   | +1 :green_heart: |  compile  |  16m 53s |  |  the patch passed with JDK 
Ubuntu-17.0.20.1+1-1-24.04-Ubuntu  |
   | +1 :green_heart: |  javac  |  16m 53s |  |  the patch passed  |
   | +1 :green_heart: |  blanks  |   0m  0s |  |  The patch has no blanks 
issues.  |
   | +1 :green_heart: |  checkstyle  |   1m 25s |  |  the patch passed  |
   | +1 :green_heart: |  mvnsite  |   2m  3s |  |  the patch passed  |
   | +1 :green_heart: |  javadoc  |   1m 29s |  |  the patch passed with JDK 
Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu  |
   | +1 :green_heart: |  javadoc  |   1m 28s |  |  the patch passed with JDK 
Ubuntu-17.0.20.1+1-1-24.04-Ubuntu  |
   | +1 :green_heart: |  spotbugs  |   3m 25s |  |  the patch passed  |
   | +1 :green_heart: |  shadedclient  |  31m 56s |  |  patch has no errors 
when building and testing our client artifacts.  |
   |||| _ Other Tests _ |
   | +1 :green_heart: |  unit  |  24m  6s |  |  hadoop-common in the patch 
passed.  |
   | +1 :green_heart: |  asflicense  |   1m 14s |  |  The patch does not 
generate ASF License warnings.  |
   |  |   | 222m 51s |  |  |
   
   
   | Subsystem | Report/Notes |
   |----------:|:-------------|
   | Docker | ClientAPI=1.56 ServerAPI=1.56 base: 
https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8969/1/artifact/out/Dockerfile
 |
   | GITHUB PR | https://github.com/apache/hadoop/pull/8969 |
   | Optional Tests | dupname asflicense compile javac javadoc mvninstall 
mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets |
   | uname | Linux 1f394507e6ce 5.15.0-198-generic #208-Ubuntu SMP Fri Sep 4 
10:22:38 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux |
   | Build tool | maven |
   | Personality | dev-support/bin/hadoop.sh |
   | git revision | trunk / 5c25535cfe410e40bfb0c6067e8c337a4d3aa4b3 |
   | Default Java | Ubuntu-17.0.20.1+1-1-24.04-Ubuntu |
   | Multi-JDK versions | 
/usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu 
/usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu |
   |  Test Results | 
https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8969/1/testReport/ |
   | Max. process+thread count | 1451 (vs. ulimit of 10000) |
   | modules | C: hadoop-common-project/hadoop-common U: 
hadoop-common-project/hadoop-common |
   | Console output | 
https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8969/1/console |
   | versions | git=2.43.0 maven=3.9.15 spotbugs=4.9.7 |
   | Powered by | Apache Yetus 0.14.1 https://yetus.apache.org |
   
   
   This message was automatically generated.
   
   




> MutableQuantiles.add() causes severe lock contention, blocking all IPC 
> Handler threads and degrading RPC performance
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-19918
>                 URL: https://issues.apache.org/jira/browse/HADOOP-19918
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: hadoop-common, metrics
>    Affects Versions: 3.3.3
>            Reporter: erzhen wu
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: image-2026-06-11-18-43-36-472.png, 
> image-2026-06-11-18-54-43-972.png, image-2026-06-11-18-55-17-240.png
>
>
> h2. Problem Description
>       When `rpc.metrics.quantile.enable=true` is enabled in production 
> NameNode, 
> we observed severe lock contention causing all IPC Handler threads to become
> BLOCKED on `MutableQuantiles.add()`, resulting in:
>  * *RpcQueueTimeAvgTime increases significantly* : Requests queuing in 
> CallQueue longer    
>  * *CallQueueLength increases dramatically*  :More requests waiting to be 
> processed
>  * NameNode RPC throughput degradation:Handler threads blocked on metrics 
> update                                                                        
>          
> h2. Thread Dump Analysis
>       From production NameNode jstack, we found 247 IPC Handler threads 
> BLOCKED 
> waiting on the same `MutableQuantiles` monitor lock:
> {code:java}
> Thread 283 (IPC Server handler 191 on default port 8020): 
> State: BLOCKED 
> Blocked count: 15596 
> Waited count: 28409 
> Blocked on org.apache.hadoop.metrics2.lib.MutableQuantiles@659a2455 
> Blocked by 300 (IPC Server handler 208 on default port 8020) 
> Stack: 
> org.apache.hadoop.metrics2.lib.MutableQuantiles.add(MutableQuantiles.java:133)
>  
> org.apache.hadoop.ipc.metrics.RpcMetrics.addRpcQueueTime(RpcMetrics.java:245) 
> org.apache.hadoop.ipc.Server.updateMetrics(Server.java:587) 
> org.apache.hadoop.ipc.Server$Handler.run(Server.java:3008){code}
> h3. Root Cause
> The `synchronized` keyword on `MutableQuantiles.add()` and 
> `SampleQuantiles.insert()` 
> creates a global lock contention point:
> {code:java}
> public synchronized void add(long value) {
>   estimator.insert(value);
> }
> /**
>  * Add a new value from the stream.
>  * 
>  * @param v
>  */
> synchronized public void insert(long v) {
>   buffer[bufferCount] = v;
>   bufferCount++;
>   count++;
>   if (bufferCount == buffer.length) {
>     insertBatch();
>     compress();
>   }
> }                                                                       {code}
>  
> Lock Contention Chain
>       When bufferCount == buffer.length (buffer is full), the thread holding 
> the lock  executes insertBatch() + compress() which can take milliseconds, 
> during which all other Handler threads are BLOCKED:
> {code:java}
> Thread A (holds lock):
>   → MutableQuantiles.add()
>     → SampleQuantiles.insert()
>       → buffer is full (500 elements)
>         → insertBatch()      
>         → compress()   
> Thread B, C, D, ... (247 threads): 
>   → MutableQuantiles.add()
>     → BLOCKED waiting for Thread A to release lock
>     → Cannot process next RPC request
>     → CallQueueLength increases
>     → RpcQueueTimeAvgTime increases {code}
> h3.  Metrics 
> !image-2026-06-11-18-54-43-972.png|width=580,height=247!
> !image-2026-06-11-18-55-17-240.png|width=590,height=246!
> h3.  Impact Analysis                                                          
>                                                     
>           The blocking happens in updateMetrics() after RPC processing is 
> complete: 
> {code:java}
> // Server.java - Handler.run()                                                
>                   
>   void updateMetrics(Call call, long startTime, boolean connDropped) {
>       // ...                                                                  
>                    
>       rpcMetrics.addRpcQueueTime(queueTime);        // ← BLOCKS HERE (95% of 
> threads)
>       rpcMetrics.addRpcLockWaitTime(waitTime);     
> rpcMetrics.addRpcProcessingTime(processingTime);                            
>   }  {code}
>  
> h3.   This means: 
>  # Handler thread completes RPC processing successfully   
>  # Calls updateMetrics() to report queue time 
>  # First call addRpcQueueTime() → BLOCKS on MutableQuantiles lock
>  # Handler thread cannot process next request in CallQueue
>  # CallQueueLength increases as new requests arrive
>  # RpcQueueTimeAvgTime increases as requests wait longer in queue
>  
>  
>  



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to