Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DATA-1419 | DATA-861 - Check sync config in reconfigure #2309

Merged

Conversation

alexis-wei
Copy link
Contributor

@alexis-wei alexis-wei commented May 1, 2023

Fix:

  • sync ticker was being reset on every reconfigure which causes data manager to not sync when the sync interval is long
  • updated now to ensure that the syncer is only reset when the sync config is changed

Test:

  • tested locally on robot and everything is working as expected
  • current tests act as unit tests for the service, further tests will be added in larger data reconfiguration integration testing

@alexis-wei alexis-wei requested a review from agreenb May 1, 2023 21:15
@viambot viambot added the safe to test This pull request is marked safe to test from a trusted zone label May 1, 2023
@alexis-wei alexis-wei changed the title DATA-1419 - Check sync config in reconfigure DATA-1419 | DATA-861 - Check sync config in reconfigure May 1, 2023
@agreenb agreenb requested a review from AaronCasas May 1, 2023 21:21
@@ -426,12 +428,16 @@ func (svc *builtIn) Reconfigure(
}
svc.collectors = newCollectors

if svc.syncDisabled == svcConfig.ScheduledSyncDisabled &&
svc.syncIntervalMins == svcConfig.SyncIntervalMins &&
reflect.DeepEqual(svc.additionalSyncPaths, svcConfig.AdditionalSyncPaths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only use reflection when necessary because it's incredibly slow, should use a string slice method here

@@ -98,6 +99,7 @@ type builtIn struct {
syncerConstructor datasync.ManagerConstructor
cloudConnSvc cloud.ConnectionService
cloudConn rpc.ClientConn
ticker *clk.Ticker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include use/purpose in name, syncTicker or something

@@ -447,6 +453,10 @@ func (svc *builtIn) Reconfigure(
svc.startSyncScheduler(svc.syncIntervalMins)
} else {
svc.closeSyncer()
if svc.ticker != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be done before closing the syncer? If this ticks between these two lines, would there be a risk of a NPE?

svc.backgroundWorkers.Add(1)
goutils.PanicCapturingGo(func() {
defer svc.backgroundWorkers.Done()
defer ticker.Stop()
defer svc.ticker.Stop()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is calling svc.ticker.Stop() safe? Just making sure since this is being deferred and also called explicitly elsewhere

@@ -426,12 +428,16 @@ func (svc *builtIn) Reconfigure(
}
svc.collectors = newCollectors

if svc.syncDisabled == svcConfig.ScheduledSyncDisabled &&
svc.syncIntervalMins == svcConfig.SyncIntervalMins &&
reflect.DeepEqual(svc.additionalSyncPaths, svcConfig.AdditionalSyncPaths) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the additional paths changing needs to impact the sync ticker. More of a product question ig but I'd lean towards removing this part of the check

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 1, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 1, 2023
Copy link
Contributor

@AaronCasas AaronCasas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 1, 2023
@viambot viambot added safe to test This pull request is marked safe to test from a trusted zone and removed safe to test This pull request is marked safe to test from a trusted zone labels May 1, 2023
Copy link
Contributor

@agreenb agreenb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Talked through everything offline and have done tons of manual testing, thank you! Really amazing work on catching the various bugs, troubleshooting, and fixing quickly 🚀

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

Code Coverage

Package Line Rate Delta Health
go.viam.com/rdk/components/arm 63% 0.00%
go.viam.com/rdk/components/arm/fake 29% 0.00%
go.viam.com/rdk/components/arm/universalrobots 41% 0.00%
go.viam.com/rdk/components/arm/wrapper 21% 0.00%
go.viam.com/rdk/components/arm/xarm 23% 0.00%
go.viam.com/rdk/components/arm/yahboom 6% 0.00%
go.viam.com/rdk/components/audioinput 44% 0.00%
go.viam.com/rdk/components/base 41% 0.00%
go.viam.com/rdk/components/base/agilex 63% 0.00%
go.viam.com/rdk/components/base/boat 40% 0.00%
go.viam.com/rdk/components/base/fake 52% 0.00%
go.viam.com/rdk/components/base/wheeled 75% 0.00%
go.viam.com/rdk/components/board 60% 0.00%
go.viam.com/rdk/components/board/fake 40% 0.00%
go.viam.com/rdk/components/board/genericlinux 19% 0.00%
go.viam.com/rdk/components/board/numato 19% 0.00%
go.viam.com/rdk/components/board/pi 50% 0.00%
go.viam.com/rdk/components/camera 57% 0.00%
go.viam.com/rdk/components/camera/align 58% 0.00%
go.viam.com/rdk/components/camera/fake 74% 0.00%
go.viam.com/rdk/components/camera/ffmpeg 82% 0.00%
go.viam.com/rdk/components/camera/rtsp 46% 0.00%
go.viam.com/rdk/components/camera/transformpipeline 77% 0.00%
go.viam.com/rdk/components/camera/videosource 33% 0.00%
go.viam.com/rdk/components/encoder 57% 0.00%
go.viam.com/rdk/components/encoder/ams 64% 0.00%
go.viam.com/rdk/components/encoder/fake 83% 0.00%
go.viam.com/rdk/components/encoder/incremental 80% 0.00%
go.viam.com/rdk/components/encoder/single 86% 0.00%
go.viam.com/rdk/components/gantry 56% 0.00%
go.viam.com/rdk/components/gantry/multiaxis 87% 0.00%
go.viam.com/rdk/components/gantry/oneaxis 87% 0.00%
go.viam.com/rdk/components/generic 79% 0.00%
go.viam.com/rdk/components/gripper 69% 0.00%
go.viam.com/rdk/components/input 88% 0.00%
go.viam.com/rdk/components/input/fake 94% +1.49%
go.viam.com/rdk/components/input/gpio 85% 0.00%
go.viam.com/rdk/components/motor 71% 0.00%
go.viam.com/rdk/components/motor/dimensionengineering 66% 0.00%
go.viam.com/rdk/components/motor/dmc4000 70% 0.00%
go.viam.com/rdk/components/motor/fake 55% 0.00%
go.viam.com/rdk/components/motor/gpio 59% +1.60%
go.viam.com/rdk/components/motor/gpiostepper 52% 0.00%
go.viam.com/rdk/components/motor/tmcstepper 64% 0.00%
go.viam.com/rdk/components/motor/ulnstepper 53% 0.00%
go.viam.com/rdk/components/movementsensor 76% 0.00%
go.viam.com/rdk/components/movementsensor/adxl345 66% 0.00%
go.viam.com/rdk/components/movementsensor/cameramono 41% 0.00%
go.viam.com/rdk/components/movementsensor/gpsnmea 51% 0.00%
go.viam.com/rdk/components/movementsensor/gpsrtk 28% 0.00%
go.viam.com/rdk/components/movementsensor/mpu6050 84% 0.00%
go.viam.com/rdk/components/posetracker 71% 0.00%
go.viam.com/rdk/components/sensor 52% 0.00%
go.viam.com/rdk/components/sensor/ultrasonic 43% 0.00%
go.viam.com/rdk/components/servo 62% 0.00%
go.viam.com/rdk/components/servo/gpio 72% 0.00%
go.viam.com/rdk/config 79% 0.00%
go.viam.com/rdk/control 57% 0.00%
go.viam.com/rdk/data 77% 0.00%
go.viam.com/rdk/examples/customresources/demos/remoteserver 0% 0.00%
go.viam.com/rdk/grpc 25% 0.00%
go.viam.com/rdk/internal/cloud 100% 0.00%
go.viam.com/rdk/ml 67% 0.00%
go.viam.com/rdk/ml/inference 71% 0.00%
go.viam.com/rdk/module 76% 0.00%
go.viam.com/rdk/module/modmanager 80% 0.00%
go.viam.com/rdk/motionplan 71% +0.29%
go.viam.com/rdk/operation 82% 0.00%
go.viam.com/rdk/pointcloud 69% -0.07%
go.viam.com/rdk/protoutils 49% 0.00%
go.viam.com/rdk/referenceframe 73% 0.00%
go.viam.com/rdk/resource 75% 0.00%
go.viam.com/rdk/rimage 77% 0.00%
go.viam.com/rdk/rimage/depthadapter 94% 0.00%
go.viam.com/rdk/rimage/transform 75% 0.00%
go.viam.com/rdk/rimage/transform/cmd/extrinsic_calibration 67% 0.00%
go.viam.com/rdk/robot 86% 0.00%
go.viam.com/rdk/robot/client 82% 0.00%
go.viam.com/rdk/robot/framesystem 66% 0.00%
go.viam.com/rdk/robot/impl 83% 0.00%
go.viam.com/rdk/robot/packages 80% 0.00%
go.viam.com/rdk/robot/server 53% 0.00%
go.viam.com/rdk/robot/web 64% 0.00%
go.viam.com/rdk/robot/web/stream 87% 0.00%
go.viam.com/rdk/services/baseremotecontrol 50% 0.00%
go.viam.com/rdk/services/baseremotecontrol/builtin 82% 0.00%
go.viam.com/rdk/services/datamanager 65% 0.00%
go.viam.com/rdk/services/datamanager/builtin 85% -0.20%
go.viam.com/rdk/services/datamanager/datacapture 73% 0.00%
go.viam.com/rdk/services/datamanager/datasync 0% 0.00%
go.viam.com/rdk/services/mlmodel 83% 0.00%
go.viam.com/rdk/services/mlmodel/tflitecpu 82% 0.00%
go.viam.com/rdk/services/motion 51% 0.00%
go.viam.com/rdk/services/motion/builtin 85% 0.00%
go.viam.com/rdk/services/navigation 53% 0.00%
go.viam.com/rdk/services/sensors 81% 0.00%
go.viam.com/rdk/services/sensors/builtin 95% 0.00%
go.viam.com/rdk/services/shell 11% 0.00%
go.viam.com/rdk/services/slam 93% 0.00%
go.viam.com/rdk/services/slam/fake 90% 0.00%
go.viam.com/rdk/services/vision 35% 0.00%
go.viam.com/rdk/services/vision/colordetector 56% 0.00%
go.viam.com/rdk/services/vision/detectionstosegments 67% 0.00%
go.viam.com/rdk/services/vision/mlvision 68% 0.00%
go.viam.com/rdk/services/vision/radiusclustering 59% 0.00%
go.viam.com/rdk/session 97% 0.00%
go.viam.com/rdk/spatialmath 84% 0.00%
go.viam.com/rdk/utils 71% -0.14%
go.viam.com/rdk/vision 26% 0.00%
go.viam.com/rdk/vision/chess 80% 0.00%
go.viam.com/rdk/vision/delaunay 87% 0.00%
go.viam.com/rdk/vision/keypoints 92% 0.00%
go.viam.com/rdk/vision/objectdetection 82% 0.00%
go.viam.com/rdk/vision/odometry 60% 0.00%
go.viam.com/rdk/vision/odometry/cmd 0% 0.00%
go.viam.com/rdk/vision/segmentation 49% 0.00%
go.viam.com/rdk/web/server 26% 0.00%
Summary 65% (21543 / 33027) +0.04%

@alexis-wei alexis-wei merged commit d81ee66 into viamrobotics:main May 1, 2023
@alexis-wei alexis-wei deleted the data-1419-capture-sync-check branch May 1, 2023 22:15
bazile-clyde pushed a commit to bazile-clyde/rdk that referenced this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
safe to test This pull request is marked safe to test from a trusted zone
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants