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

Supavisor V2 #408

Open
wants to merge 78 commits into
base: main
Choose a base branch
from
Open

Supavisor V2 #408

wants to merge 78 commits into from

Conversation

abc3
Copy link
Member

@abc3 abc3 commented Jul 31, 2024

In this PR, Supavisor has been adapted for Erlang 27 and Elixir 1.17. The metrics backend has been changed from PromEx to Peep, and the most significant change is the introduction of ProxyHandler for processing transaction mode.

The ProxyHandler first authenticates the incoming connection through auth_query. If there is no connection pool, it creates one and also launches a Ranch on a free port, saving the port and host in the corresponding Syn record.

If the pool is on the same node as the client connection, we locally change the owner of the TCP socket for each transaction to the direct connection with the database. After the transaction is completed, the client process returns ownership of the TCP socket to the DbHandler.

If the pool is on a different node, the client process connects to the Ranch of the corresponding pool on the other node, switches to session mode, and forwards everything (works like proxy). The local Ranch operates the same way as when the client connection is on the same node as the connection pool.

With this handler, erldist is used only for synchronizing Syn. Forwarding query data between nodes is done via TCP sockets (Ranch)

hauleth and others added 29 commits July 2, 2024 09:30
Reason for that is that `a || b` will expand to:

```
case a do
  val when val in [false, nil] -> b
  val -> val
end
```

Which is harder to optimise by the compiler. `or/2` works only with
booleans, so in places where we do not care about returned value or
`nil` cases, it is better to use `or/2`.
* ft: improve socket metrics gathering

As we are only interested in just 2 of the values from the socket stats, fetch
only these. This should reduce time required for processing data sent between
port and application. It also simplifies pattern matching and data extraction.

* ft: gather metrics from other nodes with low priority
* chore: update Benchee

* chore: unlock telemetry_metrics

* chore: remove unused libraries from lockfile

* chore: update Rustler and Rust dependencies

* chore: update direct dependencies

* chore: upddate Phoenix.LiveView
Supavisor is not using any HTML views, it do not offer any HTML-based
UI, etc. so these functionalities aren't needed for anything.
I have used [`typos`][typos] tool to find all typos in source code over
the codebase.

[typos]: https://github.com/crate-ci/typos
* chore: add Nix Flake to project

Currently it defines only development environment for Supavisor. In the
future the plan is to add package definition as well as NixOS module to
the Flake. This will simplify deployment on NixOS platforms as well as
should help with spawning virtual machines with Supavisor running on
them.

* ft: add derivation for Supavisor
All changes required by our code are merged to mainline, so we do not
need to use custom fork anymore.
@abc3 abc3 changed the title Supavisor V2 [WIP] Supavisor V2 Jul 31, 2024
@abc3 abc3 marked this pull request as ready for review August 30, 2024 13:43
@abc3 abc3 requested a review from a team as a code owner August 30, 2024 13:43
@abc3 abc3 changed the title [WIP] Supavisor V2 Supavisor V2 Aug 30, 2024
abc3 and others added 24 commits September 16, 2024 12:57
Update mailmap with a Supabase email for me.
feat: shorter retry connect timeout for proxy mode
This will raise if there are some pending changes to the `mix.lock`.
This is to ensure, that `mix.lock` was uploaded after dependency
changes.
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.

3 participants