From 3a587aec79fde46d5006789d1fa1d226f6e33899 Mon Sep 17 00:00:00 2001 From: Sergey Matvienko Date: Sun, 18 Oct 2026 11:29:21 +0200 Subject: [PATCH] Use the preloaded rule node only for the first rule node actor init ComponentActor.init calls createProcessor on every init attempt: the mailbox retries a failed start, and re-initializes an INIT_FAILED actor (failed start, or failed restart after a configuration update) on the next RuleNodeUpdatedMsg, reusing the same actor instance. Reusing the snapshot from actor creation there would keep a stale configuration and ignore later fixes, so later attempts read the rule node from the database, as before. --- .../actors/ruleChain/RuleNodeActor.java | 8 ++- .../RuleNodeActorMessageProcessorTest.java | 19 +++++++ .../server/actors/ActorSystemTest.java | 56 +++++++++++++++++++ 3 files changed, 81 insertions(+), 2 deletions(-) diff --git a/application/src/main/java/org/thingsboard/server/actors/ruleChain/RuleNodeActor.java b/application/src/main/java/org/thingsboard/server/actors/ruleChain/RuleNodeActor.java index 56ac543085..89ca84b5a5 100644 --- a/application/src/main/java/org/thingsboard/server/actors/ruleChain/RuleNodeActor.java +++ b/application/src/main/java/org/thingsboard/server/actors/ruleChain/RuleNodeActor.java @@ -25,7 +25,7 @@ public class RuleNodeActor extends RuleEngineComponentActor initAttempts.get() == 2); + actorRef.tell(new IntTbActorMsg(42)); + + Assertions.assertTrue(testCtx.getLatch().await(TIMEOUT_AWAIT_MAX_SEC, TimeUnit.SECONDS)); + // the same actor instance is initialized again, so state it kept from its creation is reused by the re-init + assertThat(createdActors.get()).isEqualTo(1); + } + public void testActorsAndMessages(int actorsCount, int msgNumber, int times) throws InterruptedException { Random random = new Random();