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

fix: decoder error preventing succesfull app subprocess restart #34858

Merged
merged 4 commits into from
Jan 2, 2025

Conversation

d-gubert
Copy link
Member

@d-gubert d-gubert commented Dec 31, 2024

Proposed changes (including videos or screenshots)

If msgpack's decodeStream throws an error, the internal state of the decoder becomes "invalid" (the encoded malformed message stays cached) and the engine was not capable of reestabilishing communications with any other subprocesses as the decoder instance never disposes of the malformed data. This essentially rendered the whole apps-engine incapable of communication, as the decoder instance was shared among apps.

To solve this, now the engine will instantiate a new decoder every time it spawns a subprocess. This guarantees that the internal state of the decoder for a subprocess will never impact the communication of other subprocesses, and also allows the engine to reestablish communication with a new subprocess of an app after a Decode error.

Another side effect of this problem could be observed on the subprocess side. Since the engine stopped reading data from the subprocess' stdout pipe, the operation system was blocking the write syscall that the subprocess made and essentially made it stuck with an ever growing queue of ougoing messages.

Note: I've also tried reestablishing the communication over the same pipe that we had with the subprocess - since the state of the subprocess wasn't invalid, it made sense to try that. However, the msgpack decoder left the stdout stream of the ChildProcess in an unrecoverable error state, so I was left with restarting the whole subprocess.

Issue(s)

CONN-448

Steps to test or reproduce

Further comments

Copy link
Contributor

dionisio-bot bot commented Dec 31, 2024

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is targeting the wrong base branch. It should target 7.3.0, but it targets 7.2.0

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

Copy link

changeset-bot bot commented Dec 31, 2024

🦋 Changeset detected

Latest commit: db60bc1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 40 packages
Name Type
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/authorization-service Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/presence-service Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/account-service Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-theming Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/queue-worker Patch
@rocket.chat/apps-engine Patch
@rocket.chat/ui-composer Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-client Patch
@rocket.chat/models Patch
@rocket.chat/sha256 Patch
@rocket.chat/meteor Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/gazzodown Patch
@rocket.chat/livechat Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/cron Patch
@rocket.chat/instance-status Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/network-broker Patch
@rocket.chat/api-client Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/model-typings Patch
@rocket.chat/license Patch
@rocket.chat/pdf-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Dec 31, 2024

PR Preview Action v1.4.8
🚀 Deployed preview to https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-34858/
on branch gh-pages at 2025-01-02 18:22 UTC

Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 59.19%. Comparing base (ee5756a) to head (db60bc1).
Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop   #34858   +/-   ##
========================================
  Coverage    59.19%   59.19%           
========================================
  Files         2821     2821           
  Lines        67633    67633           
  Branches     15048    15048           
========================================
  Hits         40033    40033           
  Misses       24784    24784           
  Partials      2816     2816           
Flag Coverage Δ
unit 74.99% <ø> (ø)

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

@d-gubert d-gubert added this to the 7.3.0 milestone Dec 31, 2024
@d-gubert d-gubert changed the title fix: decoder error preventing succesfull app restart fix: decoder error preventing succesfull app subprocess restart Dec 31, 2024
@d-gubert d-gubert force-pushed the fix/apps-restart-on-stdout-error branch from f43b821 to fcce702 Compare January 2, 2025 13:24
@d-gubert d-gubert marked this pull request as ready for review January 2, 2025 15:00
@d-gubert d-gubert requested a review from a team as a code owner January 2, 2025 15:00
@d-gubert d-gubert added the stat: QA assured Means it has been tested and approved by a company insider label Jan 2, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Jan 2, 2025
@kodiakhq kodiakhq bot merged commit 5506c40 into develop Jan 2, 2025
54 checks passed
@kodiakhq kodiakhq bot deleted the fix/apps-restart-on-stdout-error branch January 2, 2025 19:37
@scuciatto
Copy link
Member

/patch

Copy link
Contributor

dionisio-bot bot commented Jan 3, 2025

    Sorry, I couldn't do that backport because of conflicts. Could you please solve them?
    
    you can do so by running the following commands:
git fetch
git checkout backport-7.1.1-34858
git cherry-pick 5506c406f4a22145ece065ad2b797225e94423ca
// solve the conflict
git push

after that just run /patch again

@d-gubert
Copy link
Member Author

d-gubert commented Jan 3, 2025

/patch

Copy link
Contributor

dionisio-bot bot commented Jan 3, 2025

    Sorry, I couldn't do that backport because of conflicts. Could you please solve them?
    
    you can do so by running the following commands:
git fetch
git checkout backport-7.1.1-34858
git cherry-pick 5506c406f4a22145ece065ad2b797225e94423ca
// solve the conflict
git push

after that just run /patch again

@d-gubert d-gubert modified the milestones: 7.3.0, 7.2.0 Jan 3, 2025
@d-gubert
Copy link
Member Author

d-gubert commented Jan 3, 2025

/patch

@d-gubert
Copy link
Member Author

d-gubert commented Jan 3, 2025

/bark

Copy link
Contributor

dionisio-bot bot commented Jan 3, 2025

AU AU

@d-gubert
Copy link
Member Author

d-gubert commented Jan 3, 2025

/patch

Copy link
Contributor

dionisio-bot bot commented Jan 3, 2025

Pull request #34879 added to Project: "Patch 7.1.1"

@d-gubert
Copy link
Member Author

d-gubert commented Jan 3, 2025

/backport 7.0.4

Copy link
Contributor

dionisio-bot bot commented Jan 3, 2025

Sorry, I couldn't do that backport because of conflicts. Could you please solve them?

you can do so by running the following commands:

git fetch
git checkout backport-7.0.4-34858
git cherry-pick 5506c406f4a22145ece065ad2b797225e94423ca
// solve the conflict
git push

after that just run /backport 7.0.4 again

@d-gubert
Copy link
Member Author

d-gubert commented Jan 3, 2025

/backport 7.0.4

Copy link
Contributor

dionisio-bot bot commented Jan 3, 2025

Pull request #34880 added to Project: "Patch 7.0.4"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants