[
https://issues.apache.org/jira/browse/NIFI-16633?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xinyu Wang updated NIFI-16633:
------------------------------
Description:
When a processor is configured with Execution = Primary node and the node is
not the primary node, ConnectableTask skips the invocation and returns a yield
result, but it does not yield the component:
{code:java}
if (!isRunOnCluster(flowController)) {
...
return NOT_PRIMARY_NODE_YIELD_RESULT; // InvocationResult.yield("This
node is not the primary node")
}
{code}
TimerDrivenSchedulingAgent reschedules the task after the component's yield
only if connectable.getYieldExpiration() is in the future, which requires the
component to have called yield(). For any other yield result it reschedules the
task after nifi.bored.yield.duration (default 10 ms). Since nothing calls
connectable.yield() on this path, a Primary-only processor that is RUNNING on a
non-primary node is retried about every 10 ms, regardless of its scheduling
period and of its configured Yield Duration (default 1 sec).
Each retry calls isPrimary(), which asks the LeaderElectionManager whether this
node is the primary node.
This looks different from the usual case that the bored yield is designed for.
For a processor without work, the node could have work on the next trigger, so
a short retry is reasonable. Here the reason for skipping is the node role,
which does not change until the leadership changes, and no new data on this
node can make the processor run.
h3. Observed
On a 3-node cluster running on EKS, with 100 timer-driven threads, about 30
Primary-only processors in the RUNNING state (about 290 before part of them
were stopped), and several thousand RUNNING processors in total:
* {{nifi.sh diagnostics}} shows the Leader Election service being polled about
170,000 times in 5 minutes on a non-primary node and about 73,000 times on the
primary node. The difference is about 98,000 polls (roughly 330 per second).
With a 1 second yield, about 30 processors would only account for around 9,000
polls in 5 minutes, so this is about ten times higher.
These numbers were measured on a 2.5.0 based build. The relevant code is the
same in 2.12.0 and main.
h3. Questions
# Is it intended that the not-primary-node path uses the bored yield duration,
rather than the Yield Duration of the processor or its scheduling period?
# Would it be acceptable to call connectable.yield() in this case, so that a
Primary-only processor on a non-primary node is retried after its Yield
Duration?
h3. Trade-off
A longer retry interval delays the first run on a node that becomes the primary
node. With the default Yield Duration of 1 sec, a processor could start up to
about 1 sec later after a failover than with the 10 ms retry. If that delay is
a concern, the yield could be limited to a smaller value or only apply to
timer-driven components.
Cron-driven components are not affected by the 10 ms retry, because the next
trigger is determined by the cron schedule.
was:
When a processor is configured with Execution = Primary node and the node is
not the primary node, ConnectableTask skips the invocation and returns a yield
result, but it does not yield the component:
{code:java}
if (!isRunOnCluster(flowController)) {
...
return NOT_PRIMARY_NODE_YIELD_RESULT; // InvocationResult.yield("This
node is not the primary node")
}
{code}
TimerDrivenSchedulingAgent reschedules the task after the component's yield
only if connectable.getYieldExpiration() is in the future, which requires the
component to have called yield(). For any other yield result it reschedules the
task after nifi.bored.yield.duration (default 10 ms). Since nothing calls
connectable.yield() on this path, a Primary-only processor that is RUNNING on a
non-primary node is retried about every 10 ms, regardless of its scheduling
period and of its configured Yield Duration (default 1 sec).
Each retry calls isPrimary(), which asks the LeaderElectionManager whether this
node is the primary node.
This looks different from the usual case that the bored yield is designed for.
For a processor without work, the node could have work on the next trigger, so
a short retry is reasonable. Here the reason for skipping is the node role,
which does not change until the leadership changes, and no new data on this
node can make the processor run.
h3. Observed
On a 3-node cluster running on EKS, with 100 timer-driven threads, about 30
Primary-only processors in the RUNNING state (about 290 before part of them
were stopped), and several thousand RUNNING processors in total:
* {{nifi.sh diagnostics}} reports that the Leader Election service was polled
about 170,000 times in 5 minutes on a non-primary node (about 570 per second)
and about 73,000 times in 5 minutes on the primary node (about 240 per second).
With a 1 second yield for roughly 30 processors, a non-primary node would be
expected to show about 9,000 polls in 5 minutes.
* A thread dump of both nodes shows about half of the 100 timer-driven threads
inside the rescheduling branch of TimerDrivenSchedulingAgent (waiting on the
lock of the scheduled executor's delay queue and on the synchronized block on
the LifecycleState), so the reschedule itself is a significant part of the work
of those threads.
The counts are lower than 100 retries per second for each processor, which
suggests that the scheduler is already saturated at this flow size, and I would
not read them as an exact retry rate.
These numbers were measured on a 2.5.0 based build. The relevant code is the
same in 2.12.0 and main.
h3. Questions
# Is it intended that the not-primary-node path uses the bored yield duration,
rather than the Yield Duration of the processor or its scheduling period?
# Would it be acceptable to call connectable.yield() in this case, so that a
Primary-only processor on a non-primary node is retried after its Yield
Duration?
h3. Trade-off
A longer retry interval delays the first run on a node that becomes the primary
node. With the default Yield Duration of 1 sec, a processor could start up to
about 1 sec later after a failover than with the 10 ms retry. If that delay is
a concern, the yield could be limited to a smaller value or only apply to
timer-driven components.
Cron-driven components are not affected by the 10 ms retry, because the next
trigger is determined by the cron schedule.
Priority: Minor (was: Major)
> Primary-only processors on non-primary nodes are rescheduled every
> nifi.bored.yield.duration instead of using the yield duration
> --------------------------------------------------------------------------------------------------------------------------------
>
> Key: NIFI-16633
> URL: https://issues.apache.org/jira/browse/NIFI-16633
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Core Framework
> Affects Versions: 2.12.0
> Reporter: Xinyu Wang
> Priority: Minor
>
> When a processor is configured with Execution = Primary node and the node is
> not the primary node, ConnectableTask skips the invocation and returns a
> yield result, but it does not yield the component:
> {code:java}
> if (!isRunOnCluster(flowController)) {
> ...
> return NOT_PRIMARY_NODE_YIELD_RESULT; // InvocationResult.yield("This
> node is not the primary node")
> }
> {code}
> TimerDrivenSchedulingAgent reschedules the task after the component's yield
> only if connectable.getYieldExpiration() is in the future, which requires the
> component to have called yield(). For any other yield result it reschedules
> the task after nifi.bored.yield.duration (default 10 ms). Since nothing calls
> connectable.yield() on this path, a Primary-only processor that is RUNNING on
> a non-primary node is retried about every 10 ms, regardless of its scheduling
> period and of its configured Yield Duration (default 1 sec).
> Each retry calls isPrimary(), which asks the LeaderElectionManager whether
> this node is the primary node.
> This looks different from the usual case that the bored yield is designed
> for. For a processor without work, the node could have work on the next
> trigger, so a short retry is reasonable. Here the reason for skipping is the
> node role, which does not change until the leadership changes, and no new
> data on this node can make the processor run.
> h3. Observed
> On a 3-node cluster running on EKS, with 100 timer-driven threads, about 30
> Primary-only processors in the RUNNING state (about 290 before part of them
> were stopped), and several thousand RUNNING processors in total:
> * {{nifi.sh diagnostics}} shows the Leader Election service being polled
> about 170,000 times in 5 minutes on a non-primary node and about 73,000 times
> on the primary node. The difference is about 98,000 polls (roughly 330 per
> second). With a 1 second yield, about 30 processors would only account for
> around 9,000 polls in 5 minutes, so this is about ten times higher.
> These numbers were measured on a 2.5.0 based build. The relevant code is the
> same in 2.12.0 and main.
> h3. Questions
> # Is it intended that the not-primary-node path uses the bored yield
> duration, rather than the Yield Duration of the processor or its scheduling
> period?
> # Would it be acceptable to call connectable.yield() in this case, so that a
> Primary-only processor on a non-primary node is retried after its Yield
> Duration?
> h3. Trade-off
> A longer retry interval delays the first run on a node that becomes the
> primary node. With the default Yield Duration of 1 sec, a processor could
> start up to about 1 sec later after a failover than with the 10 ms retry. If
> that delay is a concern, the yield could be limited to a smaller value or
> only apply to timer-driven components.
> Cron-driven components are not affected by the 10 ms retry, because the next
> trigger is determined by the cron schedule.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)