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

feat: reintroduce DuplexStream #327

Merged
merged 30 commits into from
May 7, 2024
Merged

Conversation

nyannyacha
Copy link
Collaborator

@nyannyacha nyannyacha commented Apr 23, 2024

What kind of change does this PR introduce?

Bug fix, Enhancement

Description

This PR is a continuation of PR-320. Please see PR-320 for background on the PR.

Major changes compared by PR-320

Makes the timing of pipe closure is adjustable within a separately created tokio task, so that the stream is not closed in the middle of a response.

In the case of DuplexStream, if either pair is dropped, the stream immediately goes into an unwritable state.

These streams must remain writable for outside responses, but the previous PR did not. So this issue was immediately exposed by the flush behavior of libraries like hyper.

With the current implementation, which requires a Tokio task to be created every time a stream is dropped, I get a small performance hit compared to PR-320, but I believe we can replace it with an efficient implementation in the next iteration.

Notes on Minor changes

ConnSync has been removed and replaced with CancellationToken.

This was a refactoring to simplify the structure, and while the performance impact of the replacement has not been carefully evaluated, it does not appear to have changed much.

Stream of request body must be cancelable from errors or exceptions by the worker.

Sometimes the request body is not fully consumed by the worker due to circumstances such as worker resource limit due to a multipart request.

Previously, sb_workers did not handle these circumstances properly, leaving the end requestor in a situation where they would receive no response indefinitely. (Runtime also had resource leaks due to unresolved promises)

This PR introduces a routine that tries to cancel the request body stream after checking for a response or exception from the worker.

Graceful shutdown by SIGWINCH is now behind the base/termination-signal-ext feature flag.

Given the nature of devs frequently changing the terminal size, SIGWINCH has been gated to only be enabled behind a specific feature flag.

@nyannyacha nyannyacha changed the title fix: adjust timing of pipe closure of duplex stream feat: reintroduce DuplexStream Apr 25, 2024
@nyannyacha nyannyacha force-pushed the fix-conn-lt branch 3 times, most recently from 9aea940 to 6bd3efc Compare May 2, 2024 06:01
@nyannyacha nyannyacha marked this pull request as ready for review May 6, 2024 05:37
@nyannyacha nyannyacha merged commit 2800bac into supabase:main May 7, 2024
3 checks passed
@nyannyacha nyannyacha deleted the fix-conn-lt branch May 7, 2024 01:57
Copy link

github-actions bot commented May 7, 2024

🎉 This PR is included in version 1.48.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants