Skip to content

Commit

Permalink
NIFI-4436: Fixed bug that causes a deadlock when changing version of …
Browse files Browse the repository at this point in the history
…a PG. Before this patch, an update would obtain a write lock and then recurse downward through the child groups, obtaining write locks to update variable registries. At the same time, if a Processor is obtaining a Controller Service, it will obtain a Read Lock on the Process Group and then recurse upward through the ancestors, obtaining Read Lock. If the timing is right, we can have a group obtain a read lock, then try to obtain its parent's Read Lock. At the same time, an update to the group could hold the Write Lock on the Process Group and attempt to obtain a Write Lock on child (where the Processor lives), resulting in a deadlock.

Signed-off-by: Matt Gilman <matt.c.gilman@gmail.com>
  • Loading branch information
markap14 authored and bbende committed Jan 8, 2018
1 parent c5b0931 commit 0127b02
Showing 1 changed file with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2028,19 +2028,23 @@ public ControllerServiceNode getControllerService(final String id) {

@Override
public Set<ControllerServiceNode> getControllerServices(final boolean recursive) {
final Set<ControllerServiceNode> services = new HashSet<>();

readLock.lock();
try {
final Set<ControllerServiceNode> services = new HashSet<>();
services.addAll(controllerServices.values());

if (recursive && parent.get() != null) {
services.addAll(parent.get().getControllerServices(true));
}

return services;
} finally {
readLock.unlock();
}

if (recursive) {
final ProcessGroup parentGroup = parent.get();
if (parentGroup != null) {
services.addAll(parentGroup.getControllerServices(true));
}
}

return services;
}

@Override
Expand Down

0 comments on commit 0127b02

Please sign in to comment.