From 5f3c374036f6b3f30659cd5a07938783ad2a9763 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 14:00:48 +0300 Subject: [PATCH 01/10] Stop installing and deploying boot jars, Windows zips and debs --- TEST_FAST.md | 2 +- msa/pom.xml | 11 ++++----- pom.xml | 65 +++++++++------------------------------------------- 3 files changed, 16 insertions(+), 62 deletions(-) diff --git a/TEST_FAST.md b/TEST_FAST.md index fbea72db9c..28f4b4059a 100644 --- a/TEST_FAST.md +++ b/TEST_FAST.md @@ -42,7 +42,7 @@ Use `-Dpkg.skip=true` to skip all packaging at once (equivalent to all four flag |----------------------------|-------------------------------------------|--------------------------------------------------------------| | `-Dpkg.skip=true` | All of the below (bootjar + deb + rpm + zip) | Yes | | `-Dpkg.skip.bootjar=true` | `spring-boot:repackage` (`*-boot.jar`) | Yes — tests use the regular `.jar`, not the fat boot jar | -| `-Dpkg.skip.deb=true` | Gradle `buildDeb` + Maven `attach-artifact` | Yes — MSA docker modules copy the DEB from `target/` directly | +| `-Dpkg.skip.deb=true` | Gradle `buildDeb` | Yes — MSA docker modules copy the DEB from `target/` directly | | `-Dpkg.skip.rpm=true` | Gradle `buildRpm` | Yes — no test depends on the RPM | | `-Dpkg.skip.zip=true` | `maven-assembly-plugin` Windows ZIP | Yes — no test depends on the ZIP | diff --git a/msa/pom.xml b/msa/pom.xml index 3ffd8ed28b..a44cbbb93c 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -55,10 +55,7 @@ - + skip-deb @@ -71,9 +68,9 @@ none - + skip-pkg diff --git a/pom.xml b/pom.xml index 6ecad4cd2c..0c563899c5 100755 --- a/pom.xml +++ b/pom.xml @@ -34,14 +34,13 @@ Individual flags below can be set independently for finer control. --> false - + false @@ -50,11 +49,6 @@ module depends on the ZIP artifact, so this flag can be toggled freely without breaking downstream modules. --> false - - ${pkg.package.phase} thingsboard ${project.name} /var/log/${pkg.name} @@ -215,26 +209,7 @@ - - - skip-deb - - - pkg.skip.deb - true - - - - none - - - - + skip-pkg @@ -248,7 +223,6 @@ true true true - none @@ -565,6 +539,8 @@ ${pkg.skip.bootjar} ${pkg.mainClass} boot + + false ZIP true true @@ -641,28 +617,9 @@ ${pkg.skip.zip} - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-deb - ${pkg.deb.phase} - - attach-artifact - - - - - ${project.build.directory}/${pkg.name}.deb - deb - deb - - + + false From 87a6f3088181c5a91bcf512af3cc4e4a316d5abd Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 14:02:33 +0300 Subject: [PATCH 02/10] Stop deploying the ui-ngx jar --- ui-ngx/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui-ngx/pom.xml b/ui-ngx/pom.xml index 164ce0d056..42b0fac027 100644 --- a/ui-ngx/pom.xml +++ b/ui-ngx/pom.xml @@ -71,6 +71,14 @@ + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + From 32fb97af7249a34eb9a38a1392713516c4aebb4f Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 21 Aug 2026 15:35:03 +0300 Subject: [PATCH 03/10] Honour skip.yarn in the JS module tests and packaging The yarn test execution in msa/js-executor declared its own skip flag, which overrode the mojo default of ${skip.yarn}, so a build run with -Dskip.yarn=true still invoked yarn run test with no node_modules installed. The two JS packaging modules had the same gap: the ZIP assembly requires a launcher binary produced by yarn run pkg, so it failed on a missing file rather than being skipped along with the yarn work that would have produced it. Both now follow skip.yarn while continuing to honour maven.test.skip. --- msa/js-executor/pom.xml | 26 +++++++++++++++++++++++++- msa/web-ui/pom.xml | 5 +++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 5d28be03f8..8c35b773db 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -30,6 +30,18 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows + + ${skip.yarn} + + ${skip.yarn} pre-integration-test @@ -112,7 +124,7 @@ test - ${maven.test.skip} + ${yarn.test.skip} --mutex network run test @@ -206,6 +218,18 @@ + + skip-yarn-test + + + maven.test.skip + true + + + + true + + yarn-start diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index b2d148d5b2..f2f5e31309 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -32,6 +32,11 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows + + ${skip.yarn} pre-integration-test From 6172ca8963f6feffe4ddcf80dc079f1dbbdd0e3c Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Fri, 21 Aug 2026 15:54:50 +0300 Subject: [PATCH 04/10] Add a skip.ui.build flag that skips only the UI builds frontend-maven-plugin reads skip.yarn on its own, so -Dskip.yarn=true switches off every yarn invocation in the project at once. That is the right shortcut for a local backend build, but it is too blunt for CI: it also silences the msa/js-executor sandbox tests, which are the only yarn-driven tests worth keeping. skip.ui.build is declared once in the root pom and defaults to ${skip.yarn}. It is wired into the frontend-maven-plugin configuration of ui-ngx and msa/web-ui, and into the pkg.skip.zip of msa/web-ui, whose Windows ZIP bundles the launcher that `yarn run pkg` produces. It is deliberately NOT wired into msa/js-executor: with -Dskip.ui.build=true that module still runs its yarn install, its `yarn run pkg` and its sandbox tests. Behaviour: no flags everything builds and is tested as before -Dskip.ui.build=true ui-ngx and msa/web-ui skip; msa/js-executor still builds and runs its tests -Dskip.yarn=true everything skips, exactly as before The element is declared at plugin level rather than per execution so that it also covers the executions contributed by the yarn-build and yarn-start profiles, and so that node/yarn itself is no longer downloaded when there is nothing to run. --- msa/web-ui/pom.xml | 7 +++++-- pom.xml | 7 +++++++ ui-ngx/pom.xml | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index f2f5e31309..93d2ecff76 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -33,10 +33,10 @@ ${project.build.directory}/package/linux ${project.build.directory}/package/windows - ${skip.yarn} + ${skip.ui.build} pre-integration-test @@ -65,6 +65,9 @@ target ${basedir} + + ${skip.ui.build} diff --git a/pom.xml b/pom.xml index 0c563899c5..11c0e52c30 100755 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,13 @@ 17 17 ${basedir} + + ${skip.yarn} none none + ${skip.ui.build} From 21e5d93aeca3ffc038cee2f3290df0a59c86e826 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 15:05:42 +0300 Subject: [PATCH 05/10] Skip all packaging when the UI build is skipped Packages built without the UI are incomplete, so -Dskip.yarn=true and -Dskip.ui.build=true now imply -Dpkg.skip=true through dedicated profiles in the root pom and msa/pom.xml. This replaces the module-level pkg.skip.zip properties in msa/js-executor and msa/web-ui, which shadowed the root skip-pkg profile and made -Dpkg.skip=true build their Windows ZIPs again. --- TEST_FAST.md | 2 ++ msa/js-executor/pom.xml | 5 ----- msa/pom.xml | 25 +++++++++++++++++++++++++ msa/web-ui/pom.xml | 5 ----- pom.xml | 37 ++++++++++++++++++++++++++++++++++++- 5 files changed, 63 insertions(+), 11 deletions(-) diff --git a/TEST_FAST.md b/TEST_FAST.md index 28f4b4059a..11f8969fca 100644 --- a/TEST_FAST.md +++ b/TEST_FAST.md @@ -46,6 +46,8 @@ Use `-Dpkg.skip=true` to skip all packaging at once (equivalent to all four flag | `-Dpkg.skip.rpm=true` | Gradle `buildRpm` | Yes — no test depends on the RPM | | `-Dpkg.skip.zip=true` | `maven-assembly-plugin` Windows ZIP | Yes — no test depends on the ZIP | +`-Dskip.yarn=true` and `-Dskip.ui.build=true` imply `-Dpkg.skip=true`: packages built without the UI are incomplete. + ## Testcontainers compatibility with the Docker API workaround In case your tests failed to run testcontainers due to unsupported Docker API version diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 8c35b773db..3a4a1ccda4 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -30,11 +30,6 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows - - ${skip.yarn} + + skip-pkg-without-yarn + + + skip.yarn + true + + + + none + + + + skip-pkg-without-ui-build + + + skip.ui.build + true + + + + none + + black-box-tests diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index 93d2ecff76..9e616482cf 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -32,11 +32,6 @@ package ${project.build.directory}/package/linux ${project.build.directory}/package/windows - - ${skip.ui.build} pre-integration-test diff --git a/pom.xml b/pom.xml index 11c0e52c30..77706d1627 100755 --- a/pom.xml +++ b/pom.xml @@ -33,7 +33,8 @@ cover msa/js-executor, whose yarn install and sandbox tests keep running. frontend-maven-plugin reads skip.yarn itself, so that property cannot be narrowed to a subset of the modules; this one can, and it defaults to skip.yarn so that - -Dskip.yarn=true still skips every yarn invocation in the project exactly as before. --> + -Dskip.yarn=true still skips every yarn invocation in the project exactly as before. + Either flag also skips all packaging (see the skip-pkg-without-* profiles). --> ${skip.yarn} none none @@ -233,6 +234,40 @@ + + + skip-pkg-without-yarn + + + skip.yarn + true + + + + true + true + true + true + + + + skip-pkg-without-ui-build + + + skip.ui.build + true + + + + true + true + true + true + + + packaging From ccf0581ac38f75461b8dc7511ddce557ef4701b2 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 15:35:28 +0300 Subject: [PATCH 06/10] Generate build-info outside the packaging profile Activating any other root profile (skip-pkg, skip-pkg-without-*) switches off the activeByDefault packaging profile, which held the only build-info execution, so such builds had no build-info.properties and ProjectInfo failed at runtime. The jar plugin config (logback.xml exclusion, manifest) moves out of the profile for the same reason. --- pom.xml | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 77706d1627..0a46f54ab1 100755 --- a/pom.xml +++ b/pom.xml @@ -554,21 +554,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - - - **/logback.xml - - - - ${pkg.implementationTitle} - ${project.version} - - - - org.springframework.boot spring-boot-maven-plugin @@ -597,7 +582,6 @@ repackage - build-info @@ -717,6 +701,18 @@ org.apache.maven.plugins maven-jar-plugin ${jar-plugin.version} + + + + **/logback.xml + + + + ${pkg.implementationTitle} + ${project.version} + + + org.apache.maven.plugins @@ -727,6 +723,20 @@ org.springframework.boot spring-boot-maven-plugin ${spring-boot.version} + + + + build-info + + build-info + + + + false + + + org.thingsboard From b6227edbc1ea6d7733ea0f74d9b535b7aa8b9a43 Mon Sep 17 00:00:00 2001 From: Viacheslav Klimov Date: Wed, 16 Sep 2026 17:12:32 +0300 Subject: [PATCH 07/10] Version set to 4.2.2.6-SNAPSHOT --- application/pom.xml | 2 +- common/actor/pom.xml | 2 +- common/cache/pom.xml | 2 +- common/cluster-api/pom.xml | 2 +- common/coap-server/pom.xml | 2 +- common/dao-api/pom.xml | 2 +- common/data/pom.xml | 2 +- common/discovery-api/pom.xml | 2 +- common/edge-api/pom.xml | 2 +- common/edge-api/src/main/proto/edge.proto | 1 + common/edqs/pom.xml | 2 +- common/message/pom.xml | 2 +- common/pom.xml | 2 +- common/proto/pom.xml | 2 +- common/queue/pom.xml | 2 +- common/script/pom.xml | 2 +- common/script/remote-js-client/pom.xml | 2 +- common/script/script-api/pom.xml | 2 +- common/stats/pom.xml | 2 +- common/transport/coap/pom.xml | 2 +- common/transport/http/pom.xml | 2 +- common/transport/lwm2m/pom.xml | 2 +- common/transport/mqtt/pom.xml | 2 +- common/transport/pom.xml | 2 +- common/transport/snmp/pom.xml | 2 +- common/transport/transport-api/pom.xml | 2 +- common/util/pom.xml | 2 +- common/version-control/pom.xml | 2 +- dao/pom.xml | 2 +- edqs/pom.xml | 2 +- monitoring/pom.xml | 2 +- msa/black-box-tests/pom.xml | 2 +- msa/edqs/pom.xml | 2 +- msa/js-executor/package.json | 2 +- msa/js-executor/pom.xml | 2 +- msa/monitoring/pom.xml | 2 +- msa/pom.xml | 2 +- msa/tb-node/pom.xml | 2 +- msa/tb/pom.xml | 2 +- msa/transport/coap/pom.xml | 2 +- msa/transport/http/pom.xml | 2 +- msa/transport/lwm2m/pom.xml | 2 +- msa/transport/mqtt/pom.xml | 2 +- msa/transport/pom.xml | 2 +- msa/transport/snmp/pom.xml | 2 +- msa/vc-executor-docker/pom.xml | 2 +- msa/vc-executor/pom.xml | 2 +- msa/web-ui/package.json | 2 +- msa/web-ui/pom.xml | 2 +- netty-mqtt/pom.xml | 4 ++-- pom.xml | 2 +- rest-client/pom.xml | 2 +- rule-engine/pom.xml | 2 +- rule-engine/rule-engine-api/pom.xml | 2 +- rule-engine/rule-engine-components/pom.xml | 2 +- tools/pom.xml | 2 +- transport/coap/pom.xml | 2 +- transport/http/pom.xml | 2 +- transport/lwm2m/pom.xml | 2 +- transport/mqtt/pom.xml | 2 +- transport/pom.xml | 2 +- transport/snmp/pom.xml | 2 +- ui-ngx/package.json | 2 +- ui-ngx/pom.xml | 2 +- 64 files changed, 65 insertions(+), 64 deletions(-) diff --git a/application/pom.xml b/application/pom.xml index ee2b77b4e4..b6a59dba10 100644 --- a/application/pom.xml +++ b/application/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard application diff --git a/common/actor/pom.xml b/common/actor/pom.xml index d715a42ac0..7e6bbe85ff 100644 --- a/common/actor/pom.xml +++ b/common/actor/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/cache/pom.xml b/common/cache/pom.xml index a4c580b5cc..cbfe90440b 100644 --- a/common/cache/pom.xml +++ b/common/cache/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/cluster-api/pom.xml b/common/cluster-api/pom.xml index 7210e5810f..06552c67ae 100644 --- a/common/cluster-api/pom.xml +++ b/common/cluster-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/coap-server/pom.xml b/common/coap-server/pom.xml index 1a4d7b3856..74e2777c4e 100644 --- a/common/coap-server/pom.xml +++ b/common/coap-server/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/dao-api/pom.xml b/common/dao-api/pom.xml index 225fc7230f..e91cb60df1 100644 --- a/common/dao-api/pom.xml +++ b/common/dao-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/data/pom.xml b/common/data/pom.xml index 2801f94153..5b9a8cc97c 100644 --- a/common/data/pom.xml +++ b/common/data/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/discovery-api/pom.xml b/common/discovery-api/pom.xml index 451833d3fa..6b12557443 100644 --- a/common/discovery-api/pom.xml +++ b/common/discovery-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/edge-api/pom.xml b/common/edge-api/pom.xml index e8df15a854..51c96c6f37 100644 --- a/common/edge-api/pom.xml +++ b/common/edge-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/edge-api/src/main/proto/edge.proto b/common/edge-api/src/main/proto/edge.proto index c7c71371e0..cddeb0191a 100644 --- a/common/edge-api/src/main/proto/edge.proto +++ b/common/edge-api/src/main/proto/edge.proto @@ -38,6 +38,7 @@ enum EdgeVersion { V_4_2_2_3 = 4223; V_4_2_2_4 = 4224; V_4_2_2_5 = 4225; + V_4_2_2_6 = 4226; V_LATEST = 99999; } diff --git a/common/edqs/pom.xml b/common/edqs/pom.xml index dd78323862..e61a27a8a8 100644 --- a/common/edqs/pom.xml +++ b/common/edqs/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/message/pom.xml b/common/message/pom.xml index e1fe0a464c..417916e518 100644 --- a/common/message/pom.xml +++ b/common/message/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/pom.xml b/common/pom.xml index 0c3a5ba927..c533e1554a 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard common diff --git a/common/proto/pom.xml b/common/proto/pom.xml index ed8713b624..7e835835fc 100644 --- a/common/proto/pom.xml +++ b/common/proto/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/queue/pom.xml b/common/queue/pom.xml index 6a682ac6d9..4a340a96ec 100644 --- a/common/queue/pom.xml +++ b/common/queue/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/script/pom.xml b/common/script/pom.xml index c6121aac6c..475151e2a9 100644 --- a/common/script/pom.xml +++ b/common/script/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/script/remote-js-client/pom.xml b/common/script/remote-js-client/pom.xml index d840887124..eac7a8561d 100644 --- a/common/script/remote-js-client/pom.xml +++ b/common/script/remote-js-client/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT script org.thingsboard.common.script diff --git a/common/script/script-api/pom.xml b/common/script/script-api/pom.xml index 9a8da08633..573f4b7ff4 100644 --- a/common/script/script-api/pom.xml +++ b/common/script/script-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT script org.thingsboard.common.script diff --git a/common/stats/pom.xml b/common/stats/pom.xml index a3ae0e3723..771d46eaaf 100644 --- a/common/stats/pom.xml +++ b/common/stats/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/transport/coap/pom.xml b/common/transport/coap/pom.xml index 890cc19a7b..6c05a559b8 100644 --- a/common/transport/coap/pom.xml +++ b/common/transport/coap/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/http/pom.xml b/common/transport/http/pom.xml index 2ec04ce75f..cb27c74bfa 100644 --- a/common/transport/http/pom.xml +++ b/common/transport/http/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/lwm2m/pom.xml b/common/transport/lwm2m/pom.xml index f9987105d5..271bd9dbc0 100644 --- a/common/transport/lwm2m/pom.xml +++ b/common/transport/lwm2m/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/mqtt/pom.xml b/common/transport/mqtt/pom.xml index 768e8c9b9e..da1fab79aa 100644 --- a/common/transport/mqtt/pom.xml +++ b/common/transport/mqtt/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/transport/pom.xml b/common/transport/pom.xml index 1a6bbb9c97..949f5da4ba 100644 --- a/common/transport/pom.xml +++ b/common/transport/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/transport/snmp/pom.xml b/common/transport/snmp/pom.xml index 337e707a7e..b372d17b11 100644 --- a/common/transport/snmp/pom.xml +++ b/common/transport/snmp/pom.xml @@ -10,7 +10,7 @@ org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport diff --git a/common/transport/transport-api/pom.xml b/common/transport/transport-api/pom.xml index 7623b2af19..021ef4ee16 100644 --- a/common/transport/transport-api/pom.xml +++ b/common/transport/transport-api/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.common - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.common.transport diff --git a/common/util/pom.xml b/common/util/pom.xml index a75a5124b6..eaa4edfaf8 100644 --- a/common/util/pom.xml +++ b/common/util/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/common/version-control/pom.xml b/common/version-control/pom.xml index 0d815961c1..17bf85d869 100644 --- a/common/version-control/pom.xml +++ b/common/version-control/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT common org.thingsboard.common diff --git a/dao/pom.xml b/dao/pom.xml index 31101398f1..b67f222401 100644 --- a/dao/pom.xml +++ b/dao/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard dao diff --git a/edqs/pom.xml b/edqs/pom.xml index 77c6cd7cb1..5efc955e57 100644 --- a/edqs/pom.xml +++ b/edqs/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard edqs diff --git a/monitoring/pom.xml b/monitoring/pom.xml index 06090c273b..26758d0170 100644 --- a/monitoring/pom.xml +++ b/monitoring/pom.xml @@ -10,7 +10,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard diff --git a/msa/black-box-tests/pom.xml b/msa/black-box-tests/pom.xml index 66b22cbb35..270921ed5e 100644 --- a/msa/black-box-tests/pom.xml +++ b/msa/black-box-tests/pom.xml @@ -10,7 +10,7 @@ org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/edqs/pom.xml b/msa/edqs/pom.xml index 93ac979d13..6129e3b9ab 100644 --- a/msa/edqs/pom.xml +++ b/msa/edqs/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/js-executor/package.json b/msa/js-executor/package.json index e88f5da2eb..fbadae3920 100644 --- a/msa/js-executor/package.json +++ b/msa/js-executor/package.json @@ -1,7 +1,7 @@ { "name": "thingsboard-js-executor", "private": true, - "version": "4.2.2.5", + "version": "4.2.2.6", "description": "ThingsBoard JavaScript Executor Microservice", "main": "server.ts", "bin": "server.js", diff --git a/msa/js-executor/pom.xml b/msa/js-executor/pom.xml index 5d28be03f8..063ad3e14d 100644 --- a/msa/js-executor/pom.xml +++ b/msa/js-executor/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/monitoring/pom.xml b/msa/monitoring/pom.xml index 1d7d16dec5..9566e83d71 100644 --- a/msa/monitoring/pom.xml +++ b/msa/monitoring/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa diff --git a/msa/pom.xml b/msa/pom.xml index 3ffd8ed28b..052102f508 100644 --- a/msa/pom.xml +++ b/msa/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard msa diff --git a/msa/tb-node/pom.xml b/msa/tb-node/pom.xml index 6bb28e833f..b70e55c691 100644 --- a/msa/tb-node/pom.xml +++ b/msa/tb-node/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/tb/pom.xml b/msa/tb/pom.xml index 41e8b5517d..26061eb43e 100644 --- a/msa/tb/pom.xml +++ b/msa/tb/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/transport/coap/pom.xml b/msa/transport/coap/pom.xml index a7caa361bc..7e04147081 100644 --- a/msa/transport/coap/pom.xml +++ b/msa/transport/coap/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/http/pom.xml b/msa/transport/http/pom.xml index 680b38df3e..ca0ee89f86 100644 --- a/msa/transport/http/pom.xml +++ b/msa/transport/http/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/lwm2m/pom.xml b/msa/transport/lwm2m/pom.xml index 86d79c322f..6a052bb5de 100644 --- a/msa/transport/lwm2m/pom.xml +++ b/msa/transport/lwm2m/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/mqtt/pom.xml b/msa/transport/mqtt/pom.xml index 15a2f8a3d5..ef9b03e5d1 100644 --- a/msa/transport/mqtt/pom.xml +++ b/msa/transport/mqtt/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard.msa - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.msa.transport diff --git a/msa/transport/pom.xml b/msa/transport/pom.xml index 21be0a04b2..650a011502 100644 --- a/msa/transport/pom.xml +++ b/msa/transport/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/transport/snmp/pom.xml b/msa/transport/snmp/pom.xml index 8e154ec5a6..4e3aec5733 100644 --- a/msa/transport/snmp/pom.xml +++ b/msa/transport/snmp/pom.xml @@ -10,7 +10,7 @@ org.thingsboard.msa transport - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT org.thingsboard.msa.transport diff --git a/msa/vc-executor-docker/pom.xml b/msa/vc-executor-docker/pom.xml index e8143ac7c1..7176dc6f8f 100644 --- a/msa/vc-executor-docker/pom.xml +++ b/msa/vc-executor-docker/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/vc-executor/pom.xml b/msa/vc-executor/pom.xml index ed5aa3662a..ebe5da9d4c 100644 --- a/msa/vc-executor/pom.xml +++ b/msa/vc-executor/pom.xml @@ -10,7 +10,7 @@ org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/msa/web-ui/package.json b/msa/web-ui/package.json index 4b1e489783..e0099bbdc5 100644 --- a/msa/web-ui/package.json +++ b/msa/web-ui/package.json @@ -1,7 +1,7 @@ { "name": "thingsboard-web-ui", "private": true, - "version": "4.2.2.5", + "version": "4.2.2.6", "description": "ThingsBoard Web UI Microservice", "main": "server.ts", "bin": "server.js", diff --git a/msa/web-ui/pom.xml b/msa/web-ui/pom.xml index b2d148d5b2..927cd21a1b 100644 --- a/msa/web-ui/pom.xml +++ b/msa/web-ui/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT msa org.thingsboard.msa diff --git a/netty-mqtt/pom.xml b/netty-mqtt/pom.xml index 18bab00e7d..15e2315aeb 100644 --- a/netty-mqtt/pom.xml +++ b/netty-mqtt/pom.xml @@ -8,11 +8,11 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard netty-mqtt - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT jar Netty MQTT Client diff --git a/pom.xml b/pom.xml index 6ecad4cd2c..4b239194a8 100755 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT pom Thingsboard diff --git a/rest-client/pom.xml b/rest-client/pom.xml index d897b1fe27..7477e9bc37 100644 --- a/rest-client/pom.xml +++ b/rest-client/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard rest-client diff --git a/rule-engine/pom.xml b/rule-engine/pom.xml index b6a3a43513..644d72831b 100644 --- a/rule-engine/pom.xml +++ b/rule-engine/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard rule-engine diff --git a/rule-engine/rule-engine-api/pom.xml b/rule-engine/rule-engine-api/pom.xml index fab00e3cb8..faf8b26dac 100644 --- a/rule-engine/rule-engine-api/pom.xml +++ b/rule-engine/rule-engine-api/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT rule-engine org.thingsboard.rule-engine diff --git a/rule-engine/rule-engine-components/pom.xml b/rule-engine/rule-engine-components/pom.xml index 615767fe63..40e1455aa3 100644 --- a/rule-engine/rule-engine-components/pom.xml +++ b/rule-engine/rule-engine-components/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT rule-engine org.thingsboard.rule-engine diff --git a/tools/pom.xml b/tools/pom.xml index fe46969c90..4025cf2b26 100644 --- a/tools/pom.xml +++ b/tools/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard tools diff --git a/transport/coap/pom.xml b/transport/coap/pom.xml index d104dcf2b9..4cf89f99e0 100644 --- a/transport/coap/pom.xml +++ b/transport/coap/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/http/pom.xml b/transport/http/pom.xml index f7d7d2b472..397c242314 100644 --- a/transport/http/pom.xml +++ b/transport/http/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/lwm2m/pom.xml b/transport/lwm2m/pom.xml index ca1ec8c822..b87170e421 100644 --- a/transport/lwm2m/pom.xml +++ b/transport/lwm2m/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/mqtt/pom.xml b/transport/mqtt/pom.xml index c26fb8b997..10df97f0b2 100644 --- a/transport/mqtt/pom.xml +++ b/transport/mqtt/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport org.thingsboard.transport diff --git a/transport/pom.xml b/transport/pom.xml index 66e962b674..cb177df37f 100644 --- a/transport/pom.xml +++ b/transport/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard transport diff --git a/transport/snmp/pom.xml b/transport/snmp/pom.xml index 8375236ee4..77e05aa684 100644 --- a/transport/snmp/pom.xml +++ b/transport/snmp/pom.xml @@ -10,7 +10,7 @@ org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT transport diff --git a/ui-ngx/package.json b/ui-ngx/package.json index 5358528a6b..c830027a3c 100644 --- a/ui-ngx/package.json +++ b/ui-ngx/package.json @@ -1,6 +1,6 @@ { "name": "thingsboard", - "version": "4.2.2.5", + "version": "4.2.2.6", "scripts": { "ng": "ng", "start": "node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve --configuration development --host 0.0.0.0 --open", diff --git a/ui-ngx/pom.xml b/ui-ngx/pom.xml index 164ce0d056..a9324f651c 100644 --- a/ui-ngx/pom.xml +++ b/ui-ngx/pom.xml @@ -9,7 +9,7 @@ 4.0.0 org.thingsboard - 4.2.2.5-SNAPSHOT + 4.2.2.6-SNAPSHOT thingsboard org.thingsboard From 7fa8edfd0e66acec6b841006dc74b14865224a5f Mon Sep 17 00:00:00 2001 From: Volodymyr Babak Date: Thu, 17 Sep 2026 10:05:40 +0300 Subject: [PATCH 08/10] fix: do not clear edge activity state when session moved to another node onEdgeDisconnect persisted active=false based only on this node's in-memory session map. When an edge drops and reconnects to a different TB-Core node, the new node sets active=true while the old node writes active=false whenever it finally notices its dead stream. If the stale write lands last, the edge stays marked inactive while its gRPC session is alive. That flag is not only a status indicator: saveEdgeEvent() consults it before queueing any server-to-edge event, and actions that are not on the offline allowlist - device and entity-group assignments among them - are dropped outright rather than queued. A stale active=false therefore makes assignments silently never reach the edge, with a full "Sync Edge" as the only recovery. - Guard the write with the cluster-wide service-id cache, skipping it only when another node is the recorded owner and that node is still a live TB_CORE service. An absent entry means ownership is unknown, not claimed elsewhere, so that case still persists the inactive state; and a node that died without evicting its claim cannot leave the edge marked active forever. - Publish the ownership claim before writing active=true in onEdgeConnect, so a disconnect callback on the node the edge just left cannot read a stale owner. - Only evict the service-id cache entry when it still points at this node. A stale callback would otherwise wipe the live owner's claim and defeat the guard above for any later disconnect. - Remove the session atomically in onEdgeDisconnect. get() and remove() were not atomic, so a session replaced between the two was dropped from the map, torn down and marked inactive by the stale callback even though it was the live one. LAST_DISCONNECT_TIME and the rule-engine DISCONNECT_EVENT are intentionally left unguarded - they are accurate statements about this session, and the timestamps are the main diagnostic signal for flapping edges. Backport of thingsboard/thingsboard#16155 to lts-4.2, which has no disconnect notification debounce and therefore none of the ownership helpers the 4.3 change builds on; they are introduced here. --- .../service/edge/rpc/EdgeGrpcService.java | 59 ++++- .../service/edge/rpc/EdgeGrpcServiceTest.java | 221 ++++++++++++++++++ 2 files changed, 275 insertions(+), 5 deletions(-) create mode 100644 application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java diff --git a/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java b/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java index e1211c53a7..9e18ed7e2f 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java @@ -37,6 +37,7 @@ import org.thingsboard.common.util.ThingsBoardExecutors; import org.thingsboard.rule.engine.api.AttributesSaveRequest; import org.thingsboard.rule.engine.api.TimeseriesSaveRequest; import org.thingsboard.server.cache.TbTransactionalCache; +import org.thingsboard.server.cache.TbCacheValueWrapper; import org.thingsboard.server.cluster.TbClusterService; import org.thingsboard.server.common.data.AttributeScope; import org.thingsboard.server.common.data.DataConstants; @@ -58,11 +59,13 @@ import org.thingsboard.server.common.msg.edge.EdgeHighPriorityMsg; import org.thingsboard.server.common.msg.edge.EdgeSessionMsg; import org.thingsboard.server.common.msg.edge.FromEdgeSyncResponse; import org.thingsboard.server.common.msg.edge.ToEdgeSyncRequest; +import org.thingsboard.server.common.msg.queue.ServiceType; import org.thingsboard.server.gen.edge.v1.EdgeRpcServiceGrpc; import org.thingsboard.server.gen.edge.v1.RequestMsg; import org.thingsboard.server.gen.edge.v1.ResponseMsg; import org.thingsboard.server.queue.discovery.TbServiceInfoProvider; import org.thingsboard.server.queue.discovery.TopicService; +import org.thingsboard.server.queue.discovery.PartitionService; import org.thingsboard.server.queue.kafka.KafkaAdmin; import org.thingsboard.server.queue.provider.TbCoreQueueFactory; import org.thingsboard.server.queue.util.AfterStartUp; @@ -152,6 +155,9 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i @Autowired private TbTransactionalCache edgeIdServiceIdCache; + @Autowired + private PartitionService partitionService; + @Autowired private TopicService topicService; @@ -382,10 +388,13 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i } finally { newEventLock.unlock(); } + // Claim ownership before writing the active state, not after: onEdgeDisconnect on the node this edge + // just left reads the cache to decide whether to clear the flag, so publishing the claim first keeps + // it from seeing a stale owner and clearing a state we have already set. + edgeIdServiceIdCache.put(edgeId, serviceInfoProvider.getServiceId()); save(tenantId, edgeId, ACTIVITY_STATE, true); long lastConnectTs = System.currentTimeMillis(); save(tenantId, edgeId, LAST_CONNECT_TIME, lastConnectTs); - edgeIdServiceIdCache.put(edgeId, serviceInfoProvider.getServiceId()); pushRuleEngineMessage(tenantId, edge, lastConnectTs, TbMsgType.CONNECT_EVENT); cancelScheduleEdgeEventsCheck(edgeId); edgeEventsMigrationProcessed.putIfAbsent(edgeId, Boolean.FALSE); @@ -533,8 +542,12 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i EdgeId edgeId = edge.getId(); log.info("[{}][{}] edge disconnected!", edgeId, sessionId); EdgeGrpcSession current = sessions.get(edgeId); - if (current != null && current.getSessionId().equals(sessionId)) { - EdgeGrpcSession toRemove = sessions.remove(edgeId); + // Claim-once removal: get() and remove() are not atomic, so a session that was replaced between the + // two would otherwise be dropped from the map, torn down and marked inactive by this stale callback + // even though it is the live one. Losing the race means this callback owns nothing - fall through to + // the stale-session branch below. + if (current != null && current.getSessionId().equals(sessionId) && sessions.remove(edgeId, current)) { + EdgeGrpcSession toRemove = current; final Lock newEventLock = sessionNewEventsLocks.computeIfAbsent(edgeId, id -> new ReentrantLock()); newEventLock.lock(); try { @@ -545,7 +558,13 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i destroySession(toRemove); sessionsById.remove(sessionId); TenantId tenantId = toRemove.getEdge().getTenantId(); - save(tenantId, edgeId, ACTIVITY_STATE, false); + // A newer session on another node may have already claimed this edge and set active=true. + // Clearing the flag here would leave the edge marked inactive while it is in fact connected, + // which silently drops every downlink event that is not queued for offline edges. + // When ownership is unknown (no cache entry) fall through and persist the inactive state. + if (!isOwnedByAnotherNode(edgeId)) { + save(tenantId, edgeId, ACTIVITY_STATE, false); + } long lastDisconnectTs = System.currentTimeMillis(); save(tenantId, edgeId, LAST_DISCONNECT_TIME, lastDisconnectTs); pushRuleEngineMessage(toRemove.getEdge().getTenantId(), edge, lastDisconnectTs, TbMsgType.DISCONNECT_EVENT); @@ -564,7 +583,37 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i log.debug("[{}] No session found by sessionId [{}] to destroy", edgeId, sessionId); } } - edgeIdServiceIdCache.evict(edgeId); + // Only evict if the cache still points at this node. If the edge already reconnected to another + // TB-Core node, that node has overwritten the entry and owns it - evicting here would wipe the live + // owner's claim and defeat the activity-state guard above. + if (isOwnedByThisNode(edgeId)) { + edgeIdServiceIdCache.evict(edgeId); + } + } + + // The edge's service-id cache entry points at a different node that is still a live TB-Core service. + // Two cases deliberately do NOT count as "owned by another node", so that the caller falls through and + // persists the inactive state: + // - no cache entry: ownership is unknown, not claimed by someone else; + // - entry naming a node that is no longer in the cluster: the edge sessions cache has no TTL by default + // (CACHE_SPECS_EDGE_SESSIONS_TTL=0) and is only ever evicted by the owning node, so a node that died + // without evicting would otherwise keep the edge marked active forever, with no reconciler to correct it. + private boolean isOwnedByAnotherNode(EdgeId edgeId) { + TbCacheValueWrapper wrapper = edgeIdServiceIdCache.get(edgeId); + if (wrapper == null) { + return false; + } + String ownerServiceId = wrapper.get(); + if (ownerServiceId == null || serviceInfoProvider.getServiceId().equals(ownerServiceId)) { + return false; + } + return partitionService.getAllServiceIds(ServiceType.TB_CORE).contains(ownerServiceId); + } + + // The edge's service-id cache entry still points at this node, i.e. this node is the recorded owner. + private boolean isOwnedByThisNode(EdgeId edgeId) { + TbCacheValueWrapper wrapper = edgeIdServiceIdCache.get(edgeId); + return wrapper != null && serviceInfoProvider.getServiceId().equals(wrapper.get()); } private void destroySession(EdgeGrpcSession session) { diff --git a/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java new file mode 100644 index 0000000000..7b71c65c9f --- /dev/null +++ b/application/src/test/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcServiceTest.java @@ -0,0 +1,221 @@ +/** + * Copyright © 2016-2026 The Thingsboard Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.thingsboard.server.service.edge.rpc; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.ArgumentMatcher; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.util.ReflectionTestUtils; +import org.thingsboard.rule.engine.api.AttributesSaveRequest; +import org.thingsboard.server.cache.SimpleTbCacheValueWrapper; +import org.thingsboard.server.cache.TbTransactionalCache; +import org.thingsboard.server.cluster.TbClusterService; +import org.thingsboard.server.common.data.edge.Edge; +import org.thingsboard.server.common.data.id.EdgeId; +import org.thingsboard.server.common.data.id.TenantId; +import org.thingsboard.server.common.msg.queue.ServiceType; +import org.thingsboard.server.queue.discovery.PartitionService; +import org.thingsboard.server.queue.discovery.TbServiceInfoProvider; +import org.thingsboard.server.service.edge.EdgeContextComponent; +import org.thingsboard.server.service.telemetry.TelemetrySubscriptionService; + +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.ConcurrentMap; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.thingsboard.server.service.state.DefaultDeviceStateService.ACTIVITY_STATE; + +@ExtendWith(MockitoExtension.class) +public class EdgeGrpcServiceTest { + + private static final String THIS_NODE = "tb-core-1"; + private static final String OTHER_NODE = "tb-core-2"; + + @Mock + private TbTransactionalCache edgeIdServiceIdCache; + + @Mock + private TbServiceInfoProvider serviceInfoProvider; + + @Mock + private PartitionService partitionService; + + @Mock + private TelemetrySubscriptionService tsSubService; + + @Mock + private TbClusterService clusterService; + + @Mock + private EdgeContextComponent ctx; + + @InjectMocks + private EdgeGrpcService edgeGrpcService; + + private EdgeId edgeId; + private Edge edge; + + @BeforeEach + public void setUp() { + edgeId = new EdgeId(UUID.randomUUID()); + edge = new Edge(edgeId); + edge.setTenantId(TenantId.fromUUID(UUID.randomUUID())); + edge.setName("test-edge"); + } + + // --- activity-state write guard on disconnect --- + + @Test + public void givenEdgeReconnectedToAnotherNode_whenDisconnect_thenInactiveStateNotPersisted() { + // A newer session on another node already set active=true. This stale session's disconnect must not + // clobber it - otherwise the edge stays marked inactive while connected, and the server silently + // drops every assignment event for it. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(OTHER_NODE)); + when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Set.of(THIS_NODE, OTHER_NODE)); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, never()).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenEdgeOwnedByThisNode_whenDisconnect_thenInactiveStateIsPersisted() { + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(THIS_NODE)); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, times(1)).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenNoCacheEntry_whenDisconnect_thenInactiveStateIsPersisted() { + // Ownership unknown (entry absent or expired): keep the pre-guard behaviour, otherwise a genuinely + // disconnected edge would stay marked active forever. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(null); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, times(1)).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenOwnerNodeNoLongerInCluster_whenDisconnect_thenInactiveStateIsPersisted() { + // The recorded owner died without evicting its claim. The edge sessions cache has no TTL by default + // and only the owner ever evicts, so honouring a dead claim would leave the edge active forever. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(OTHER_NODE)); + when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Set.of(THIS_NODE)); + + onEdgeDisconnect(sessionId); + + verify(tsSubService, times(1)).saveAttributes(argThat(inactiveStateWrite())); + } + + @Test + public void givenSessionReplacedDuringDisconnect_whenStaleCallbackRuns_thenLiveSessionKept() { + // Reproduces the get()/remove() interleaving on a single node: onEdgeConnect swaps in a new session + // right after the stale callback's id check passes. The stale callback must not evict or tear down + // the live session, nor clear the activity state. + UUID staleSessionId = UUID.randomUUID(); + EdgeGrpcSession live = mock(EdgeGrpcSession.class); + EdgeGrpcSession stale = mock(EdgeGrpcSession.class); + when(stale.getSessionId()).thenAnswer(invocation -> { + sessions().put(edgeId, live); + return staleSessionId; + }); + sessions().put(edgeId, stale); + + onEdgeDisconnect(staleSessionId); + + assertThat(sessions().get(edgeId)).isSameAs(live); + verify(tsSubService, never()).saveAttributes(argThat(inactiveStateWrite())); + } + + // --- service-id cache eviction guard --- + + @Test + public void givenCacheOwnedByThisNode_whenDisconnect_thenEntryIsEvicted() { + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(THIS_NODE)); + + onEdgeDisconnect(sessionId); + + verify(edgeIdServiceIdCache, times(1)).evict(edgeId); + } + + @Test + public void givenCacheOwnedByAnotherNode_whenDisconnect_thenEntryIsKept() { + // The edge already reconnected elsewhere: wiping the live owner's claim would defeat the + // activity-state guard for any later disconnect callback. + UUID sessionId = UUID.randomUUID(); + sessions().put(edgeId, sessionFor(sessionId)); + when(serviceInfoProvider.getServiceId()).thenReturn(THIS_NODE); + when(edgeIdServiceIdCache.get(edgeId)).thenReturn(SimpleTbCacheValueWrapper.wrap(OTHER_NODE)); + when(partitionService.getAllServiceIds(ServiceType.TB_CORE)).thenReturn(Set.of(THIS_NODE, OTHER_NODE)); + + onEdgeDisconnect(sessionId); + + verify(edgeIdServiceIdCache, never()).evict(edgeId); + } + + private void onEdgeDisconnect(UUID sessionId) { + ReflectionTestUtils.invokeMethod(edgeGrpcService, "onEdgeDisconnect", edge, sessionId); + } + + private EdgeGrpcSession sessionFor(UUID sessionId) { + EdgeGrpcSession session = mock(EdgeGrpcSession.class); + when(session.getSessionId()).thenReturn(sessionId); + when(session.getEdge()).thenReturn(edge); + return session; + } + + @SuppressWarnings("unchecked") + private ConcurrentMap sessions() { + return (ConcurrentMap) ReflectionTestUtils.getField(edgeGrpcService, "sessions"); + } + + private ArgumentMatcher inactiveStateWrite() { + return request -> request != null + && edgeId.equals(request.getEntityId()) + && request.getEntries().stream().anyMatch(entry -> + ACTIVITY_STATE.equals(entry.getKey()) + && Boolean.FALSE.equals(entry.getBooleanValue().orElse(null))); + } + +} From 191d7798143120f11e0c44e375d0c9d8099d7028 Mon Sep 17 00:00:00 2001 From: Dmytro Pinkevych <49400214+pinkevmladchy@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:39:14 +0300 Subject: [PATCH 09/10] Keep IoT Hub markdown table columns from overlapping (#16138) * Keep IoT Hub markdown table columns from overlapping Long unbreakable values in solution instruction tables (logins, e-mails, passwords) overflowed their own column and ran under the copy icon. Cells now break such tokens with overflow-wrap: anywhere, cells holding a copy button reserve room for the icon, and the table is sized by its content instead of splitting the width equally between all columns. * Let preformatted content in markdown table cells wrap With auto layout a cell holding a preformatted block keeps the whole line as its min-content width, which the table cannot shrink below: in a 396px host the table measured 701px and a host that hides horizontal overflow, such as the item detail dialog's .dlg-body, cut the overflow off with no way to scroll to it. Relaxing the block and the code inside it to pre-wrap lets the cell shrink with the table. * Derive the copy icon space in table cells from the icon geometry The 44px reserved on the right of a copy-code cell was derived by hand from the copy icon chip declared 45 lines above it, so nudging the chip's width or offset would silently put the cell text back under the icon. Both numbers now live in $copy-icon-width and $copy-icon-offset, used by the chip itself and by the reservation, which is written as width plus the gap on either side. --- .../iot-hub/iot-hub-markdown.component.scss | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss index 2a946348ad..c25c67e729 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss +++ b/ui-ngx/src/app/modules/home/components/iot-hub/iot-hub-markdown.component.scss @@ -3,6 +3,10 @@ $text-color: rgba(0,0,0,0.76); $link-color: #2a7dec; $copy-button-color: #2a7dec; +// Geometry of the copy icon chip, shared by the chip itself and by the space table +// cells reserve for it, so the two cannot drift apart. +$copy-icon-width: 38px; +$copy-icon-offset: 3px; $code-block-border-color: rgba(42, 125, 236, .2); $code-default-color: #212529; @@ -169,10 +173,10 @@ $gallery-border-hover-color: #2a7dec; div { background-color: #fff; position: absolute; - width: 38px; + width: $copy-icon-width; height: 28px; - top: 3px; - right: 3px; + top: $copy-icon-offset; + right: $copy-icon-offset; padding: 8px 10px 0; img { @@ -204,9 +208,30 @@ $gallery-border-hover-color: #2a7dec; } th, td { + // Long unbreakable tokens (logins, e-mails, passwords) must never overflow their + // own column. `anywhere` also drops the cell min-content width down to a single + // character, so auto layout can always squeeze the table into the available + // width instead of overflowing (and getting clipped by `overflow: hidden`). + overflow-wrap: break-word; // fallback for engines without `anywhere` + overflow-wrap: anywhere; + + // Text is not the only thing that can outgrow a column: a preformatted block keeps + // its whole line as min-content width, which auto layout cannot shrink, so the table + // would push past its container and get cut off by a host that hides horizontal + // overflow (iot-hub-item-detail-dialog's .dlg-body). Wrap it inside the cell instead. + // Prism sets `white-space: pre` on both the block and the code inside it, so both + // have to be relaxed for the cell to shrink. + pre, pre > code { + white-space: pre-wrap; + } + div.code-wrapper { display: inline-block; width: 100%; + // Reserve room for the absolutely positioned copy icon, plus the same gap on its + // far side, so the cell text does not run underneath it and the reservation + // follows the chip if its geometry ever changes. + padding-right: $copy-icon-width + 2 * $copy-icon-offset; button.clipboard-btn { top: -6px; @@ -275,11 +300,10 @@ $gallery-border-hover-color: #2a7dec; margin-top: 20px; margin-bottom: 20px; overflow: hidden; - table-layout: fixed; - - &.auto { - table-layout: auto; - } + // Columns are sized to their content: with fixed layout every column got the + // same width, so cells with long values (e-mails, logins, tokens) had to wrap + // mid-word while short columns kept a lot of unused space. + table-layout: auto; > thead { background-color: $table-header-background-color; From 89e2e086fb05980208b62d630e0737bce58c1263 Mon Sep 17 00:00:00 2001 From: Dmytro Pinkevych <49400214+pinkevmladchy@users.noreply.github.com> Date: Mon, 21 Sep 2026 18:39:29 +0300 Subject: [PATCH 10/10] Refresh the installed items count after an install, update or delete (#16139) * Refresh the installed items count after an install, update or delete The IoT Hub items page loaded its installed-items counter once, so installing, updating or deleting an item from the embedded browse list left the counter showing a stale number until the page was reloaded. The browse component now emits installedItemsChanged whenever it refreshes its own installed-items state, and the page reloads the counter on that event. * Refresh the installed items count from the device wizard and deep links too The device install wizard registers the install as soon as the entity steps finish, but closing it with the header X or with Cancel on a still-pending later step resolved to false, so the caller never reloaded. It now reports 'installed' once the server has the installed item, whichever way it is closed. The deep-linked item dialog is opened by the items page itself, so its outcome was discarded. It now refreshes the browse grid, which in turn announces the new count. --- .../device-install-dialog.component.ts | 9 ++++++++- .../iot-hub/iot-hub-browse.component.ts | 12 +++++++++++- .../iot-hub/iot-hub-items-page.component.html | 3 ++- .../pages/iot-hub/iot-hub-items-page.component.ts | 15 ++++++++++++--- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts index 676ad706b1..7f991316ee 100644 --- a/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/components/iot-hub/device-install-dialog/device-install-dialog.component.ts @@ -95,6 +95,12 @@ export class TbDeviceInstallDialogComponent extends DialogComponent = {}; @@ -357,7 +363,7 @@ export class TbDeviceInstallDialogComponent extends DialogComponent(); + /** + * Fired whenever an install, update or delete changed what this tenant has installed, so a host + * page showing its own installed-items counter can refresh it instead of waiting for a reload. + */ + @Output() installedItemsChanged = new EventEmitter(); @Input() set activeType(value: ItemType) { if (value && value !== this._activeType) { const wasInit = !!this._activeType; @@ -627,7 +632,11 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy }); } - private reloadInstalledItems(): void { + /** + * Re-reads what is installed for the active type and announces the change. Public so a host page + * that opens the item detail dialog itself can refresh this grid through the same path. + */ + reloadInstalledItems(): void { const config = {ignoreLoading: true}; const pageLink = new PageLink(10000, 0); if (this.activeType === ItemType.WIDGET) { @@ -643,6 +652,7 @@ export class TbIotHubBrowseComponent implements OnInit, AfterViewInit, OnDestroy this.installedItemCounts = counts; }); } + this.installedItemsChanged.emit(); } private loadFilterInfo(): void { diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html index 59a42eab29..5787b5ecf0 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.html @@ -35,7 +35,8 @@ + [hideTabs]="true" + (installedItemsChanged)="loadInstalledCount()"> diff --git a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts index b89448be3c..07beff5559 100644 --- a/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts +++ b/ui-ngx/src/app/modules/home/pages/iot-hub/iot-hub-items-page.component.ts @@ -1,12 +1,13 @@ // SPDX-FileCopyrightText: Copyright The Thingsboard Authors // SPDX-License-Identifier: Apache-2.0 -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { ActivatedRoute, Router } from '@angular/router'; import { map } from 'rxjs/operators'; import { Observable } from 'rxjs'; import { ItemType } from '@shared/models/iot-hub/iot-hub-item.models'; import { IotHubApiService } from '@core/http/iot-hub-api.service'; import { IotHubActionsService } from '@home/components/iot-hub/iot-hub-actions.service'; +import { TbIotHubBrowseComponent } from '@home/components/iot-hub/iot-hub-browse.component'; import { IotHubInstalledItem } from '@shared/models/iot-hub/iot-hub-installed-item.models'; import { MpItemVersionView } from '@shared/models/iot-hub/iot-hub-version.models'; import { PageLink } from '@shared/models/page/page-link'; @@ -83,6 +84,8 @@ export class TbIotHubItemsPageComponent implements OnInit { config: ItemTypePageConfig; installedItemsCount = 0; + @ViewChild(TbIotHubBrowseComponent) private browse: TbIotHubBrowseComponent; + constructor( private route: ActivatedRoute, private router: Router, @@ -109,7 +112,7 @@ export class TbIotHubItemsPageComponent implements OnInit { window.open(this.iotHubApiService.baseUrl + '/signup', '_blank'); } - private loadInstalledCount(): void { + loadInstalledCount(): void { this.iotHubApiService.getInstalledItemsCount(this.config.type, { ignoreLoading: true }).subscribe(count => { this.installedItemsCount = count; }); @@ -147,7 +150,13 @@ export class TbIotHubItemsPageComponent implements OnInit { 'default', true, openItem.preview - ).subscribe(); + ).subscribe(result => { + // The deep-linked dialog is opened by this page rather than by the grid, so its outcome + // has to be fed back in by hand — the grid then refreshes and announces the new count. + if (result === 'installed' || result === 'updated' || result === 'deleted') { + this.browse?.reloadInstalledItems(); + } + }); }); }