Do not try to finish already completed phase 56/87756/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 14 Feb 2020 10:49:36 +0000 (11:49 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 16 Feb 2020 09:42:16 +0000 (10:42 +0100)
commitf9dc1a8a269c4622c123b542daf934ffb16b0751
treece9b04284290b8ec4ce275f178f0b85314d9fc2e
parent74b6b4a6e1b0125549326946a681dd1e08748f23
Do not try to finish already completed phase

Profiling shows that completion of substatement phases is the most
expensive operation we are performing. This stems from the fact
that inference is reactive and eager -- hence at we can attempt
to complete a particular phase against a statement multiple times.

Each time we will end up also walking all children (and their
children), attempting to complete the phase -- even when a particular
child has already successfully completed it.

This exposes a slight issue in our logic, as we have always assumed
child statements need to go through all the phases with us -- which
has not been true due to 'typedef' statements reuse, which would
end up being churned through phase complete (but always end with
EFFECTIVE_MODEL completed).

Fix both issues by checking whether the statement has executed
requested (or a subsequent) phase before going into actual phase
execution. This also requires that any substatements added to
a statement transition to the parent's completed phase before they
are made visible -- otherwise we could could end up with a statement
tree whose root has completed EFFECTIVE_MODEL, but not all of its
substatements have, triggering state violation assertions.

JIRA: YANGTOOLS-1082
Change-Id: Id6ed0d7feefc6d838c055e9690db69ae26633d95
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ModelProcessingPhase.java