[VOL-4479] openonu panic in periodic-voltha-multi-uni-multiple-olts-test-bbsim-2.8 +
Onu adapter reconcilement may stuck on VLAN processing, especially in TT traffic scenarios

Signed-off-by: mpagenko <michael.pagenkopf@adtran.com>
Change-Id: I806f97c85e09bc2c741e40569a67ab3ce21300ab
diff --git a/internal/pkg/onuadaptercore/device_handler.go b/internal/pkg/onuadaptercore/device_handler.go
index c737e74..77b1dbd 100644
--- a/internal/pkg/onuadaptercore/device_handler.go
+++ b/internal/pkg/onuadaptercore/device_handler.go
@@ -3753,6 +3753,7 @@
 						logger.Errorw(ctx, "No valid OnuDevice - aborting Core DeviceStateUpdate",
 							log.Fields{"device-id": dh.deviceID})
 					} else {
+						onuDevEntry.mutexPersOnuConfig.RLock()
 						if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
 							connectStatus = voltha.ConnectStatus_REACHABLE
 							if !onuDevEntry.sOnuPersistentData.PersUniDisableDone {
@@ -3767,7 +3768,7 @@
 							onuDevEntry.sOnuPersistentData.PersOperState == "" {
 							operState = voltha.OperStatus_DISCOVERED
 						}
-
+						onuDevEntry.mutexPersOnuConfig.RUnlock()
 						logger.Debugw(ctx, "Core DeviceStateUpdate", log.Fields{"connectStatus": connectStatus, "operState": operState})
 					}
 					logger.Debugw(ctx, "reconciling has been finished in time",
@@ -3783,8 +3784,12 @@
 					if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
 						logger.Errorw(ctx, "No valid OnuDevice",
 							log.Fields{"device-id": dh.deviceID})
-					} else if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
-						connectStatus = voltha.ConnectStatus_REACHABLE
+					} else {
+						onuDevEntry.mutexPersOnuConfig.RLock()
+						if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+							connectStatus = voltha.ConnectStatus_REACHABLE
+						}
+						onuDevEntry.mutexPersOnuConfig.RUnlock()
 					}
 
 					dh.deviceReconcileFailedUpdate(ctx, drReconcileCanceled, connectStatus)
@@ -3796,12 +3801,14 @@
 				if onuDevEntry := dh.getOnuDeviceEntry(ctx, true); onuDevEntry == nil {
 					logger.Errorw(ctx, "No valid OnuDevice",
 						log.Fields{"device-id": dh.deviceID})
-				} else if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
-					connectStatus = voltha.ConnectStatus_REACHABLE
+				} else {
+					onuDevEntry.mutexPersOnuConfig.RLock()
+					if onuDevEntry.sOnuPersistentData.PersOperState == "up" {
+						connectStatus = voltha.ConnectStatus_REACHABLE
+					}
+					onuDevEntry.mutexPersOnuConfig.RUnlock()
 				}
-
 				dh.deviceReconcileFailedUpdate(ctx, drReconcileMaxTimeout, connectStatus)
-
 			}
 			dh.mutexReconcilingFlag.Lock()
 			dh.reconciling = cNoReconciling