thingsboard / thingsboard-edge

Apache License 2.0
93 stars 71 forks source link

[Bug] The Edge rule chain in Device Profile will be reset to default after restart tb-edge service #79

Closed xunyuw closed 9 months ago

xunyuw commented 9 months ago

Describe the bug The Edge rule chain in Device Profile will be reset to default after restart tb-edge service

Your Server Environment

Thingsboard CE v3.6.0 Thingsboard Edge 3.6

Both running on Ubuntu 22.04

Your Client Environment

Desktop (please complete the following information): Windows 11 Chrome

To Reproduce Steps to reproduce the behavior:

  1. Go to Thingsboard CE -> Profiles -> Device profiles
  2. Set any edge rule chain in 'Default edge rule chain'
  3. Go to Thingsboard CE -> Edge management -> instances
  4. Click Sync Edge
  5. See Thingsboard Edge -> decvie profile -> device -> rule chain is change
  6. run 'service tb-edge restart'
  7. check Thingsboard Edge -> decvie profile -> device -> rule chain again, it is set to null

Expected behavior Device profile rule chain will be loaded after restart the service

AndriiLandiak commented 9 months ago

Hello, @xunyuw. Thank you for bringing the issue to our attention. Unfortunately, we were unable to reproduce it.

It's worth noting that on ThingsBoard CE, the device profile has two rule chains: the Default Rule chain for processing CE's devices and the Default Edge Rule chain for Edge for processing Edge devices' incoming messages and events). Edge's device/asset profile knows only about its Root Rule chain, so on Edge UI "Default Rule chain" is the "Default Edge Rule chain" on CE.

Here is my flow: I've created a new Device Profile and set the recently created Rule Chain "Test" into it (look at the screen) image

Then I clicked Sync Edge (it's redundant, profiles should sync up in every change detected, no need to press the full sync-up button) and restarted Edge service, and after I had everything as expected: Thingsboard CE: image Thingsboard Edge: image

If this response doesn't address your concern and the problem still exists, please feel free to reach out again with additional details.

xunyuw commented 9 months ago

Hi @AndriiLandiak, Thanks for your reply, I paste tb-edge.log under and set DEBUG level for details.

The defaultRuleChainId "b6add140-669c-11ee-8881-ed8f66d9a9ca" can be found in line SQL cmd select deviceprof0_.id as id1_160, deviceprof0_.created_time as created_2_160, deviceprof0_.default_dashboard_id as default_3_160, deviceprof0_.default_edge_rule_chain_id as default_4_160, deviceprof0_.default_queue_name as default_5_160, deviceprof0_.default_rule_chain_id as default_6_160, deviceprof0_.description as descript7_160, deviceprof0_.external_id as external8_160, deviceprof0_.firmware_id as firmware9_160, deviceprof0_.image as image10_160, deviceprof0_.is_default as is_defa11_160, deviceprof0_.name as name12_160, deviceprof0_.profile_data as profile13_160, deviceprof0_.provision_device_key as provisi14_160, deviceprof0_.provision_type as provisi15_160, deviceprof0_.software_id as softwar16_160, deviceprof0_.tenant_id as tenant_17_160, deviceprof0_.transport_type as transpo18_160, deviceprof0_.type as type19_160 from deviceprofile deviceprof0 where deviceprof0_.id=? (This rule chain I set on TB CE and id is right I double checked already )

defaultRuleChainId : value = b6add140-669c-11ee-8881-ed8f66d9a9ca

However there is a function set the defaultRuleChainId to NULL, after it the bug appeared. Thanks for you support again.

2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.t.server.dao.sql.JpaAbstractDao - Saving entity DeviceProfileEntity(tenantId=458a3e50-249c-11ee-8db7-b1700d0264d7, name=Edge-BMS_GAOTE_20220627-v1, type=DEFAULT, image=null, transportType=DEFAULT, provisionType=DISABLED, description=, isDefault=false, defaultRuleChainId=null, defaultDashboardId=null, defaultQueueName=null, profileData={"configuration":{"type":"DEFAULT"},"transportConfiguration":{"type":"DEFAULT"},"provisionConfiguration":{"type":"DISABLED","provisionDeviceSecret":null},"alarms":null}, provisionDeviceKey=null, firmwareId=null, softwareId=null, defaultEdgeRuleChainId=null, externalId=null)

2023-10-11 02:23:08,392 [rule-dispatcher-22-6] DEBUG o.t.s.a.service.ContextAwareActor - Processing msg: RuleNodeToSelfMsg() 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Creating new transaction with name [org.springframework.data.jpa.repository.support.SimpleJpaRepository.findById]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Opened new EntityManager [SessionImpl(656177357)] for JPA transaction 2023-10-11 02:23:08,392 [rule-dispatcher-22-6] DEBUG o.t.s.actors.ruleChain.RuleNodeActor - [45bbd5a0-249c-11ee-8db7-b1700d0264d7][45bc98f0-249c-11ee-8db7-b1700d0264d7][Device Profile Node] Going to process rule msg: TbMsg(queueName=null, id=36a267bd-79b3-46ae-9553-5016dfe9ac77, ts=1696990988379, type=DEVICE_PROFILE_UPDATE_SELF_MSG, internalType=DEVICE_PROFILE_UPDATE_SELFMSG, originator=458a3e50-249c-11ee-8db7-b1700d0264d7, customerId=null, metaData=TbMsgMetaData(data={}), dataType=JSON, data=a4dc99d0-2531-11ee-8185-852671b86080, ruleChainId=null, ruleNodeId=null, ctx=org.thingsboard.server.common.msg.TbMsgProcessingCtx@5f99fb93, callback=org.thingsboard.server.common.msg.queue.TbMsgCallback$1@71ee9fa0) 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG o.s.jdbc.datasource.DataSourceUtils - Setting JDBC Connection [HikariProxyConnection@1954474495 wrapping org.postgresql.jdbc.PgConnection@5362d11c] read-only 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG o.h.e.t.internal.TransactionImpl - On TransactionImpl creation, JpaCompliance#isJpaTransactionComplianceEnabled == false 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG o.h.e.t.internal.TransactionImpl - begin 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@39a54bf3] 2023-10-11 02:23:08,392 [rule-dispatcher-22-6] DEBUG o.t.r.e.profile.TbDeviceProfileNode - [45bc98f0-249c-11ee-8db7-b1700d0264d7] Received device profile update notification: DeviceProfile(tenantId=458a3e50-249c-11ee-8db7-b1700d0264d7, name=gateway, description=Default device profile, isDefault=false, type=DEFAULT, transportType=DEFAULT, provisionType=DISABLED, defaultRuleChainId=null, defaultDashboardId=null, defaultQueueName=null, profileData=DeviceProfileData(configuration=DefaultDeviceProfileConfiguration(), transportConfiguration=DefaultDeviceProfileTransportConfiguration(), provisionConfiguration=DisabledDeviceProfileProvisionConfiguration(provisionDeviceSecret=null), alarms=null), provisionDeviceKey=null, firmwareId=null, softwareId=null, defaultEdgeRuleChainId=null, externalId=null) 2023-10-11 02:23:08,392 [grpc-default-executor-2] DEBUG org.hibernate.SQL - select deviceprof0.id as id1_160, deviceprof0_.created_time as created_2_160, deviceprof0_.default_dashboard_id as default_3_160, deviceprof0_.default_edge_rule_chain_id as default_4_160, deviceprof0_.default_queue_name as default_5_160, deviceprof0_.default_rule_chain_id as default_6_160, deviceprof0_.description as descript7_160, deviceprof0_.external_id as external8_160, deviceprof0_.firmware_id as firmware9_160, deviceprof0_.image as image10_160, deviceprof0_.is_default as is_defa11_160, deviceprof0_.name as name12_160, deviceprof0_.profile_data as profile13_160, deviceprof0_.provision_device_key as provisi14_160, deviceprof0_.provision_type as provisi15_160, deviceprof0_.software_id as softwar16_160, deviceprof0_.tenant_id as tenant_17_160, deviceprof0_.transport_type as transpo18_160, deviceprof0_.type as type19_160 from deviceprofile deviceprof0 where deviceprof0_.id=? 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.l.p.e.p.i.EntityReferenceInitializerImpl - On call to EntityIdentifierReaderImpl#resolve, EntityKey was already known; should only happen on root returns with an optional identifier specified 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Resolving attributes for [org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca] 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute createdTime : value = 1696855507826 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (createdTime) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultDashboardId : value = null 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultDashboardId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultEdgeRuleChainId : value = null 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultEdgeRuleChainId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultQueueName : value = null 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultQueueName) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultRuleChainId : value = b6add140-669c-11ee-8881-ed8f66d9a9ca 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultRuleChainId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute description : value = 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (description) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute externalId : value = null 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (externalId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute firmwareId : value = null 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (firmwareId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute image : value = null 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (image) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute isDefault : value = false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (isDefault) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute name : value = Edge-BMS_GAOTE_20220627-v1 2023-10-11 02:23:08,393 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (name) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute profileData : value = {"alarms":null,"configuration":{"type":"DEFAULT"},"provisionConfiguration":{"type":"DISABLED","provisionDeviceSecret":null},"transportConfiguration":{"type":"DEFAULT"}} 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (profileData) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute provisionDeviceKey : value = null 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (provisionDeviceKey) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute provisionType : value = DISABLED 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (provisionType) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute softwareId : value = null 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (softwareId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute tenantId : value = 458a3e50-249c-11ee-8db7-b1700d0264d7 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (tenantId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute transportType : value = DEFAULT 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (transportType) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute type : value = DEFAULT 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (type) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Done materializing entity [org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca] 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.l.e.p.AbstractLoadPlanBasedEntityLoader - Done entity load : org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Initiating transaction commit 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Committing JPA transaction on EntityManager [SessionImpl(656177357)] 2023-10-11 02:23:08,394 [grpc-default-executor-2] DEBUG o.h.e.t.internal.TransactionImpl - committing 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.s.jdbc.datasource.DataSourceUtils - Resetting read-only flag of JDBC Connection [HikariProxyConnection@1954474495 wrapping org.postgresql.jdbc.PgConnection@5362d11c] 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Closing JPA EntityManager [SessionImpl(656177357)] after transaction 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Creating new transaction with name [org.thingsboard.server.dao.sql.device.JpaDeviceProfileDao.saveAndFlush]: PROPAGATION_REQUIRED,ISOLATION_DEFAULT 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Opened new EntityManager [SessionImpl(534896530)] for JPA transaction 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.h.e.t.internal.TransactionImpl - On TransactionImpl creation, JpaCompliance#isJpaTransactionComplianceEnabled == false 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.h.e.t.internal.TransactionImpl - begin 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Exposing JPA transaction as JDBC [org.springframework.orm.jpa.vendor.HibernateJpaDialect$HibernateConnectionHandle@7482d960] 2023-10-11 02:23:08,395 [grpc-default-executor-2] DEBUG o.t.server.dao.sql.JpaAbstractDao - Saving entity DeviceProfileEntity(tenantId=458a3e50-249c-11ee-8db7-b1700d0264d7, name=Edge-BMS_GAOTE20220627-v1, type=DEFAULT, image=null, transportType=DEFAULT, provisionType=DISABLED, description=, isDefault=false, defaultRuleChainId=null, defaultDashboardId=null, defaultQueueName=null, profileData={"configuration":{"type":"DEFAULT"},"transportConfiguration":{"type":"DEFAULT"},"provisionConfiguration":{"type":"DISABLED","provisionDeviceSecret":null},"alarms":null}, provisionDeviceKey=null, firmwareId=null, softwareId=null, defaultEdgeRuleChainId=null, externalId=null) 2023-10-11 02:23:08,396 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [SessionImpl(534896530)] for JPA transaction 2023-10-11 02:23:08,396 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Participating in existing transaction 2023-10-11 02:23:08,396 [grpc-default-executor-2] DEBUG org.hibernate.loader.Loader - Loading entity: [org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca] 2023-10-11 02:23:08,396 [grpc-default-executor-2] DEBUG org.hibernate.SQL - select deviceprof0.id as id1_160, deviceprof0_.created_time as created_2_160, deviceprof0_.default_dashboard_id as default_3_160, deviceprof0_.default_edge_rule_chain_id as default_4_160, deviceprof0_.default_queue_name as default_5_160, deviceprof0_.default_rule_chain_id as default_6_160, deviceprof0_.description as descript7_160, deviceprof0_.external_id as external8_160, deviceprof0_.firmware_id as firmware9_160, deviceprof0_.image as image10_160, deviceprof0_.is_default as is_defa11_160, deviceprof0_.name as name12_160, deviceprof0_.profile_data as profile13_160, deviceprof0_.provision_device_key as provisi14_160, deviceprof0_.provision_type as provisi15_160, deviceprof0_.software_id as softwar16_160, deviceprof0_.tenant_id as tenant_17_160, deviceprof0_.transport_type as transpo18_160, deviceprof0_.type as type19_160 from deviceprofile deviceprof0 where deviceprof0_.id=? 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG org.hibernate.loader.Loader - Result set row: 0 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG org.hibernate.loader.Loader - Result row: EntityKey[org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca] 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Resolving attributes for [org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca] 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute createdTime : value = 1696855507826 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (createdTime) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultDashboardId : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultDashboardId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultEdgeRuleChainId : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultEdgeRuleChainId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultQueueName : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultQueueName) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute defaultRuleChainId : value = b6add140-669c-11ee-8881-ed8f66d9a9ca 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (defaultRuleChainId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute description : value = 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (description) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute externalId : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (externalId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute firmwareId : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (firmwareId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute image : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (image) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute isDefault : value = false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (isDefault) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute name : value = Edge-BMS_GAOTE_20220627-v1 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (name) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute profileData : value = {"alarms":null,"configuration":{"type":"DEFAULT"},"provisionConfiguration":{"type":"DISABLED","provisionDeviceSecret":null},"transportConfiguration":{"type":"DEFAULT"}} 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (profileData) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute provisionDeviceKey : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (provisionDeviceKey) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute provisionType : value = DISABLED 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (provisionType) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute softwareId : value = null 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (softwareId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute tenantId : value = 458a3e50-249c-11ee-8db7-b1700d0264d7 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (tenantId) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute transportType : value = DEFAULT 2023-10-11 02:23:08,397 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (transportType) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Processing attribute type : value = DEFAULT 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Attribute (type) - enhanced for lazy-loading? - false 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG o.h.engine.internal.TwoPhaseLoad - Done materializing entity [org.thingsboard.server.dao.model.sql.DeviceProfileEntity#ad4bd520-66a1-11ee-8881-ed8f66d9a9ca] 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG org.hibernate.loader.Loader - Done entity load 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Found thread-bound EntityManager [SessionImpl(534896530)] for JPA transaction 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Participating in existing transaction 2023-10-11 02:23:08,398 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Processing flush-time cascades 2023-10-11 02:23:08,399 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Dirty checking collections 2023-10-11 02:23:08,408 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Flushed: 0 insertions, 1 updates, 0 deletions to 1 objects 2023-10-11 02:23:08,413 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections 2023-10-11 02:23:08,413 [grpc-default-executor-2] DEBUG o.h.internal.util.EntityPrinter - Listing entities: 2023-10-11 02:23:08,413 [grpc-default-executor-2] DEBUG o.h.internal.util.EntityPrinter - org.thingsboard.server.dao.model.sql.DeviceProfileEntity{image=null, provisionDeviceKey=null, defaultDashboardId=null, firmwareId=null, description=, externalId=null, type=DEFAULT, defaultEdgeRuleChainId=null, defaultRuleChainId=null, isDefault=false, softwareId=null, provisionType=DISABLED, defaultQueueName=null, name=Edge-BMS_GAOTE_20220627-v1, tenantId=458a3e50-249c-11ee-8db7-b1700d0264d7, createdTime=1696855507826, transportType=DEFAULT, id=ad4bd520-66a1-11ee-8881-ed8f66d9a9ca, profileData={"configuration":{"type":"DEFAULT"},"transportConfiguration":{"type":"DEFAULT"},"provisionConfiguration":{"type":"DISABLED","provisionDeviceSecret":null},"alarms":null}} 2023-10-11 02:23:08,474 [grpc-default-executor-2] DEBUG org.hibernate.SQL - update device_profile set default_dashboard_id=?, default_edge_rule_chain_id=?, default_queue_name=?, default_rule_chain_id=?, description=?, external_id=?, firmware_id=?, image=?, is_default=?, name=?, profile_data=?, provision_device_key=?, provision_type=?, software_id=?, tenant_id=?, transport_type=?, type=? where id=? 2023-10-11 02:23:08,486 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Initiating transaction commit 2023-10-11 02:23:08,486 [grpc-default-executor-2] DEBUG o.s.orm.jpa.JpaTransactionManager - Committing JPA transaction on EntityManager [SessionImpl(534896530)] 2023-10-11 02:23:08,487 [grpc-default-executor-2] DEBUG o.h.e.t.internal.TransactionImpl - committing 2023-10-11 02:23:08,487 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Processing flush-time cascades 2023-10-11 02:23:08,487 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Dirty checking collections 2023-10-11 02:23:08,487 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Flushed: 0 insertions, 0 updates, 0 deletions to 1 objects 2023-10-11 02:23:08,487 [grpc-default-executor-2] DEBUG o.h.e.i.AbstractFlushingEventListener - Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections

AndriiLandiak commented 9 months ago

Hello, @xunyuw. Thanks for your additional info. I've thoroughly reviewed the logs and the information you provided. However, I'm still unable to fully comprehend the underlying cause of the issue.

To enable TRACE logging for the specified components in Thingsboard CE and Thingsboard Edge, please follow these steps:

Once you've made these changes, please follow the steps to reproduce the issue as requested. The logs generated at the TRACE level during this process will provide valuable insights into the communication between Thingsboard CE and Thingsboard Edge. Additionally, capturing screenshots of the relevant steps would be beneficial for diagnosing the issue.

Looking forward to your prompt response to help you as soon as possible.

xunyuw commented 9 months ago

Hi @AndriiLandiak ,I upload the screenshots to explain how to reproduce this bug.

  1. set the Edge Rule Chain on Thingsboard CE image

  2. refresh the Device profile on Thingsboard Edge, the default rule Chain value is changed. image

  3. reboot the service on Edge by "service tb-edge restart".

  4. the default rule chain value is empty. image

The Rule Chain ID is b6add140-669c-11ee-8881-ed8f66d9a9ca The log with TRACE is below, thanks for your help!

tb-edge.zip

AndriiLandiak commented 9 months ago

Hello, @xunyuw. Glad to see hear from you again. Could you please provide some additional info?

Is the default rule chain set to null for Device Profile only on Edge? If yes, what is the value of the "default edge rule chain" on Thingsboard CE for Device Profile Edge-BMS-GAOTE-20220627-v1 after restarting Edge?

When Edge is restarting (disconnected from ThingsBoard CE), during the reconnection process, it performs a 'sync' from CE to Edge. This synchronization involves sending all related entities, including Device Profiles. To facilitate this process, it's essential to enable logging, specifically for the Edge: <logger name="org.thingsboard.server.service.cloud" level="TRACE"/>. It's even better to enable logging for both ThingsBoard CE and Edge, as mentioned in my previous comment. This approach ensures that the output logs during Sync Up or when there are changes to the Device Profile will contain messages similar to those displayed in the screenshot below: (If we update Device Profile on CE, Edge should receive deviceProfileUpdateMsg)._ image

These logs will help to investigate the communication during synchronization process. Please, attach both logs before restarting (when you update Device Profile) and on Edge starting - when 'Sync Up' is performing.

Thanks a lot!

xunyuw commented 9 months ago

Hello @AndriiLandiak, Thanks for your kindly support. I check the default value of "edge rule chain" of Device Profile in Thingsbaord CE and find it is always become null after set value. I think it is not a TB Edge bug. I will post to Thingsboard CE issues. Please close this bug now.

Thanks

volodymyr-babak commented 9 months ago

@xunyuw

thanks for updates. closing ticket.