From commits-return-44742-archive-asf-public=cust-asf.ponee.io@nifi.apache.org Tue Jun 8 16:00:13 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 8696818060E for ; Tue, 8 Jun 2021 18:00:13 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id F2AAC3FAED for ; Tue, 8 Jun 2021 16:00:10 +0000 (UTC) Received: (qmail 65264 invoked by uid 500); 8 Jun 2021 16:00:10 -0000 Mailing-List: contact commits-help@nifi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@nifi.apache.org Delivered-To: mailing list commits@nifi.apache.org Received: (qmail 65255 invoked by uid 99); 8 Jun 2021 16:00:10 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Jun 2021 16:00:10 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 5E64C81A86; Tue, 8 Jun 2021 16:00:10 +0000 (UTC) Date: Tue, 08 Jun 2021 16:00:10 +0000 To: "commits@nifi.apache.org" Subject: [nifi] branch main updated: NIFI-8667: When marking a Controller Service as enabled, ensure that we release the write lock before calling validation methods of referencing components. Otherwise, we can encounter a deadlock. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <162316800958.4887.6124459460549675618@gitbox.apache.org> From: mattyb149@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: nifi X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Oldrev: 659fda10f3b7ed3d398c2ab8c1cb505880924594 X-Git-Newrev: 07ff4f2592b26a5b556bb1297c42325233bdb101 X-Git-Rev: 07ff4f2592b26a5b556bb1297c42325233bdb101 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. mattyb149 pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git The following commit(s) were added to refs/heads/main by this push: new 07ff4f2 NIFI-8667: When marking a Controller Service as enabled, ensure that we release the write lock before calling validation methods of referencing components. Otherwise, we can encounter a deadlock. 07ff4f2 is described below commit 07ff4f2592b26a5b556bb1297c42325233bdb101 Author: Mark Payne AuthorDate: Mon Jun 7 17:59:34 2021 -0400 NIFI-8667: When marking a Controller Service as enabled, ensure that we release the write lock before calling validation methods of referencing components. Otherwise, we can encounter a deadlock. Signed-off-by: Matthew Burgess This closes #5134 --- .../controller/service/ServiceStateTransition.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java index ae19388..afcfec4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java @@ -77,18 +77,28 @@ public class ServiceStateTransition { logger.debug("{} transitioned to ENABLED", controllerServiceNode); enabledFutures.forEach(future -> future.complete(null)); + } finally { + writeLock.unlock(); + } - final List referencingComponents = controllerServiceReference.findRecursiveReferences(ComponentNode.class); - for (final ComponentNode component : referencingComponents) { - component.performValidation(); - } + // We want to perform validation against other components outside of the write lock. Component validation could be expensive + // and more importantly could reference other controller services, which could result in a dead lock if we run the validation + // while holding this.writeLock. + final List referencingComponents = controllerServiceReference.findRecursiveReferences(ComponentNode.class); + for (final ComponentNode component : referencingComponents) { + component.performValidation(); + } + // Now that the write lock was relinquished in order to perform validation on referencing components, we must re-acquire it + // in order to signal that a state change has completed. + writeLock.lock(); + try { stateChangeCondition.signalAll(); - - return true; } finally { writeLock.unlock(); } + + return true; } public boolean transitionToDisabling(final ControllerServiceState expectedState, final CompletableFuture disabledFuture) {