arduino-cli icon indicating copy to clipboard operation
arduino-cli copied to clipboard

[breaking] daemon: Fix concurrency and streamline access to PackageManager

Open cmaglie opened this issue 3 years ago • 2 comments
trafficstars

Please check if the PR fulfills these requirements

  • [x] The PR has no duplicates (please search among the Pull Requests before creating one)
  • [x] The PR follows our contributing guidelines
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)
  • [ ] UPGRADING.md has been updated with a migration guide (for breaking changes)
  • What kind of change does this PR introduce? Makes access to PackageManger thread-safe and transactional allowing multiple thread concurrent access. This is not a problem when the arduino-cli is run from the command line (since there is no concurrency in this case), but it can be problematic in daemon mode, when a thread may read the package manager status while another one is writing on it (for example a thread may do a BoardSearch while another one is doing a PlatformsInstall or an Init).
  • What is the current behavior? The CLI daemon may crash in some specific circumstances.
  • What is the new behavior? The CLI daemon should handle gracefully any combination of gRPC requests.
  • Does this PR introduce a breaking change, and is titled accordingly? Yes, docs are not yet updated.
  • Other information: This PR is built on top of #1804 and must be merged together with it.

cmaglie avatar Aug 09 '22 09:08 cmaglie

Codecov Report

Merging #1828 (009dc94) into daemon-fixes (9c334ed) will decrease coverage by 0.13%. The diff coverage is 36.86%.

:exclamation: Current head 009dc94 differs from pull request most recent head df28c7c. Consider uploading reports for the commit df28c7c to get more accurate results

@@               Coverage Diff                @@
##           daemon-fixes    #1828      +/-   ##
================================================
- Coverage         36.47%   36.33%   -0.14%     
================================================
  Files               232      231       -1     
  Lines             19401    19550     +149     
================================================
+ Hits               7076     7103      +27     
- Misses            11500    11617     +117     
- Partials            825      830       +5     
Flag Coverage Δ
unit 36.33% <36.86%> (-0.14%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
arduino/cores/packagemanager/profiles.go 0.00% <0.00%> (ø)
arduino/cores/status.go 56.07% <ø> (ø)
cli/arguments/completion.go 0.00% <0.00%> (ø)
cli/arguments/port.go 0.00% <0.00%> (ø)
cli/board/list.go 0.00% <0.00%> (ø)
cli/compile/compile.go 0.00% <0.00%> (ø)
cli/lib/upgrade.go 0.00% <0.00%> (ø)
cli/upload/upload.go 0.00% <0.00%> (ø)
commands/board/attach.go 0.00% <0.00%> (ø)
commands/board/details.go 0.00% <0.00%> (ø)
... and 55 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 09 '22 09:08 codecov[bot]

This PR now targets arduino:daemon-fixes branch, the docs will be updated later or in another PR.

cmaglie avatar Aug 10 '22 13:08 cmaglie