You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2026/09/19 17:41:37 UTC

(nifi) 01/01: NIFI-16370 Use non-fair locking in SwappablePriorityQueue

This is an automated email from the ASF dual-hosted git repository.

joewitt pushed a commit to branch NIFI-16370
in repository https://gitbox.apache.org/repos/asf/nifi.git

commit 21b25196e06f06b4ed1c97d50b4b4bd2745a9eaa
Author: Joseph Witt <jo...@apache.org>
AuthorDate: Sat Sep 19 10:40:55 2026 -0700

    NIFI-16370 Use non-fair locking in SwappablePriorityQueue
    
    Co-authored-by: Cursor <cu...@cursor.com>
---
 .../java/org/apache/nifi/controller/queue/SwappablePriorityQueue.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/SwappablePriorityQueue.java b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/SwappablePriorityQueue.java
index 57f18cc7640..a07101abdfe 100644
--- a/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/SwappablePriorityQueue.java
+++ b/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/queue/SwappablePriorityQueue.java
@@ -107,7 +107,9 @@ public class SwappablePriorityQueue {
         this.dropAction = dropAction;
         this.swapPartitionName = swapPartitionName;
 
-        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock(true);
+        // Queue ordering is controlled by QueuePrioritizer, not lock-acquisition FIFO.
+        // Non-fair locking avoids a thread-handoff convoy on the high-frequency put/poll path.
+        final ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
         readLock = new TimedLock(lock.readLock(), flowFileQueue.getIdentifier() + " Read Lock", 100);
         writeLock = new TimedLock(lock.writeLock(), flowFileQueue.getIdentifier() + " Write Lock", 100);
     }