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

Reuse catalyst stream pull node if pull is locked #2168

Merged
merged 10 commits into from
May 8, 2024

Conversation

leszko
Copy link
Contributor

@leszko leszko commented May 6, 2024

This is a fix for the following scenario that happens from time to time on prod:

  1. We get /pull request which is successful
  2. A few seconds after (without getting /terminate) we receive another /pull request for the same stream
  3. If it's redirected to a different catalyst node, then the pull fails, because we lock stream pull to one node

The workaround for this is to check if the given stream is currently locked (read: it's being pulled atm) and if yes, then trigger pulling from the same catalyst node. If we redirect to the same node, then Mist handles this.

Sample logs: https://eu-metrics-monitoring.livepeer.live/grafana/goto/wDCuqDYSg?orgId=1

fix https://linear.app/livepeer/issue/PS-518/more-pull-failuress

@leszko leszko requested a review from victorges May 6, 2024 14:53
@leszko leszko requested a review from a team as a code owner May 6, 2024 14:53
Copy link

vercel bot commented May 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
livepeer-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 7, 2024 2:13pm

Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM

Such race condition. I'd imagine that the second /pull request would simply be redirected to the node currently pulling it. Does this only happen when the second /pull arrives after the stream started but before the load balancer gets its state to redirect to the right node?

packages/api/src/controllers/stream.ts Outdated Show resolved Hide resolved
@leszko
Copy link
Contributor Author

leszko commented May 7, 2024

Such race condition. I'd imagine that the second /pull request would simply be redirected to the node currently pulling it. Does this only happen when the second /pull arrives after the stream started but before the load balancer gets its state to redirect to the right node?

Yeah, from our perspective it happens, when Load Balancer redirects to a different node AND the stream is not available (so, Mist load balancer does not see it active). I believe that for Trovo it happens when a streamer starts streaming, stops streaming, and then suddenly starts again (maybe some retry from OBS). So, Trovo does not send /terminate properly.

Copy link

linear bot commented May 7, 2024

Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM either way

packages/api/src/controllers/stream.ts Outdated Show resolved Hide resolved
packages/api/src/controllers/stream.ts Outdated Show resolved Hide resolved
Co-authored-by: Victor Elias <victor@livepeer.org>
@emranemran
Copy link
Contributor

How do we test this to ensure no regressions?

@leszko
Copy link
Contributor Author

leszko commented May 8, 2024

How do we test this to ensure no regressions?

I think the same way as with other changes => Test pull stream in staging (with the stream stopped and started). And then monitor the prod. Any other thoughts how we could test it?

@leszko leszko merged commit d34e2e1 into master May 8, 2024
8 checks passed
@leszko leszko deleted the rafal/stream-pull-failures-reuse-locked-node branch May 8, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants