🔄 Sync with upstream changes - #17
Open
h0lybyte wants to merge 739 commits into
Open
Conversation
* chore: update @supabase/supabase-js to v2.108.2 * chore: update nix node_modules hash --------- Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com> Co-authored-by: supabase-autofix-bot <noreply@supabase.com>
To support the recommended client-id
Instead of always deleting the subscriptions table when SubscriptionManager starts we: * warm restarts now re-adopt ETS and re-monitor subscribers * cold start cleans up the DB Orphan processes are not a problem because ReplicationPoller simply broadcasts if it can't find the pid related to the subscription row
Increase default ReplicationConnection timeout from 30 seconds to 4 minutes to give more times for really busy databases to establish a replication slot. Also move creating the replication slot to happen after the publication is there.
* Connect status * ReplicationConnection status * CdcRls status * users per region
We now handle special chars closer to what PostgRest does so we have a clear direction on how we want to support filters going forward
Adds new configuration on `phx_join` payload that will send back a message to the user when the replication connection is ready to be used.
* Chore: Move benchmarks and scripts into `dev` Suggestion from Leandro over here: supabase#2106 (comment) * Make formatter check dev directory and format files * Add a README explaining the purpose of the `dev` folder
Some time to find that a package had been compromised or faulty, some stability we'd like to have. 7 days seems common/normal across the org.
If for some reason the slot is not there anymore the Watchdog should restart replication
Automatic version updates via dependabot to help us stay up to date. Choice fell on dependabot over renovate as renovate at least seemed unable to deal with the way our phoenix dependency is declared (that said, wasn't able to verify if dependabot _can_). It's also slightly lower friction to set it up and easy to change, should we want to. The setup also has a cooldown specified, this works together with our configured hex cool down (as hex applies it to all deps operations, such as manual updates or transitive dependency updates). Otherwise, also chose to limit the number of open PRs so we're not flooded by PRs all at once and so also keep the release/accumulated changes risk a bit lower.
Connection isn't yet ready, wait for it.
Flakey:
```
1) test delete tenant deletes chosen tenant (RealtimeWeb.TenantControllerTest)
Error: test/realtime_web/controllers/tenant_controller_test.exs:306
Expected truthy, got false
code: assert Realtime.Tenants.ReplicationConnection.ready?(tenant.external_id)
arguments:
# 1
"irb4ctg3354st4kggyhu5emkfc4vruth"
stacktrace:
test/realtime_web/controllers/tenant_controller_test.exs:310: (test)
The following output was logged:
06:16:01.594 [info] Exporter :otel_exporter_pid successfully initialized
06:16:01.595 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
06:16:01.607 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
06:16:01.611 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
06:16:01.780 [info] Creating partitions for realtime.messages
06:16:01.794 [info] Starting Elixir.Realtime.RateCounter for: {:database, :connect, "irb4ctg3354st4kggyhu5emkfc4vruth"}
06:16:01.795 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Connection process starting up
06:16:01.795 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Realtime.Tenants.Connect.GetTenant executed in 0 ms
06:16:01.795 error_code=DatabaseIpVersionIsIpv4 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
06:16:01.800 error_code=DatabaseIpVersionIsIpv4 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
06:16:01.800 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Realtime.Tenants.Connect.CheckConnection executed in 4 ms
06:16:01.800 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Realtime.Tenants.Connect.ReconcileMigrations executed in 0 ms
06:16:01.800 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Realtime.Tenants.Connect.RegisterProcess executed in 0 ms
06:16:01.800 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Tenant irb4ctg3354st4kggyhu5emkfc4vruth is initializing: :"main2@127.0.0.1"
06:16:01.800 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Creating partitions for realtime.messages
06:16:01.805 [info] Starting replication for Broadcast Changes
06:16:01.805 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
06:16:01.805 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Initializing connection with the status: %Realtime.Tenants.ReplicationConnection{
tenant_id: "irb4ctg3354st4kggyhu5emkfc4vruth",
opts: [],
step: :disconnected,
publication_name: "supabase_realtime_messages_publication",
replication_slot_name: "supabase_realtime_messages_replication_slot_",
output_plugin: "pgoutput",
proto_version: 2,
relations: %{},
buffer: [],
monitored_pid: #PID<0.79401.0>,
latency_committed_at: nil,
query_timeout: 240000
}
06:16:01.807 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Checking if replication slot supabase_realtime_messages_replication_slot_ exists
06:16:01.808 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Check publication supabase_realtime_messages_publication for table realtime.messages exists
06:16:01.808 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Create publication supabase_realtime_messages_publication for table realtime.messages
06:16:01.809 project=irb4ctg3354st4kggyhu5emkfc4vruth external_id=irb4ctg3354st4kggyhu5emkfc4vruth [info] Create replication slot supabase_realtime_messages_replication_slot_ using plugin pgoutput
06:16:04.556 [info] nonode@nohost: replica down from :"peer-152547-5472@127.0.0.1"
```
The error stems from `econnrefused` vs. `:noproc` which, best as I could tell, stems from the warming of clients that `Clustered` does as the processes are cleaned up async from the registry which may lead to this `:noproc`.
Hence, avoid this issue by instructing Clustered not to warm the TCP connections.
```
1) test multicall/4 partial results with bad tcp error (Realtime.GenRpcBadTcpTest)
Error: test/realtime/gen_rpc_bad_tcp_test.exs:108
Assertion with == failed
code: assert GenRpc.multicall(Map, :fetch, [%{a: 1}, :a], tenant_id: 123) == [
{node(), {:ok, 1}},
{node, {:error, :rpc_error, :econnrefused}}
]
left: [
"main4@127.0.0.1": {:ok, 1},
"peer-571426-5497@127.0.0.1": {:error, :rpc_error,
:noproc}
]
right: [
"main4@127.0.0.1": {:ok, 1},
"peer-571426-5497@127.0.0.1": {:error, :rpc_error,
:econnrefused}
]
stacktrace:
(ex_unit 1.19.5) lib/ex_unit/capture_log.ex:121: ExUnit.CaptureLog.with_log/2
(ex_unit 1.19.5) lib/ex_unit/capture_log.ex:83: ExUnit.CaptureLog.capture_log/2
test/realtime/gen_rpc_bad_tcp_test.exs:112: (test)
```
In the logs below notice how there are 2 `** (stop) :slot_lag_too_high` - so the theory is that one was intermittently active, the watchdog killed it again and hence the tests failed the way they did.
Workaround is to wait for the same condition the Watchdog waits for to make sure it doesn't kill the one we're testing again.
```
1) test WAL bloat handling track PID changes during WAL bloat creation (Realtime.Integration.RtChannel.WalBloatTest)
Error: test/integration/rt_channel/wal_bloat_test.exs:75
Assertion failed, no matching message after 5000ms
The following variables were pinned:
full_topic = "realtime:xexxgwza2culyfjbpk5sw2bzo2vwnjqj"
The process mailbox is empty.
code: assert_receive %Message{
event: "broadcast",
payload: %{"event" => "test", "payload" => %{"value" => "test"}, "type" => "broadcast"},
join_ref: nil,
09:27:08.951 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] #PID<0.49568.0> Starting stream replication for slot supabase_realtime_messages_replication_slot_ using publication supabase_realtime_messages_publication and protocol version 2
09:27:08.954 [info] Starting Elixir.Realtime.RateCounter for: {:channel, :joins, "vz25y4mz427vc65r6ph6eennz2ddu2ua"}
09:27:08.957 [info] Starting Elixir.Realtime.RateCounter for: {:channel, :events, "vz25y4mz427vc65r6ph6eennz2ddu2ua"}
09:27:08.957 [info] Starting Elixir.Realtime.RateCounter for: {:channel, :presence_events, "vz25y4mz427vc65r6ph6eennz2ddu2ua"}
09:27:08.959 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
09:27:08.959 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
09:27:08.959 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
09:27:08.959 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
09:27:08.959 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
09:27:09.045 error_code=ReplicationSlotLagTooHigh project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [error] ReplicationSlotLagTooHigh: Replication slot lag exceeds 50% of max_slot_wal_keep_size, shutting down
09:27:09.045 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [error] GenServer #PID<0.49570.0> terminating
** (stop) :slot_lag_too_high
Last message: :health_check
09:27:09.045 error_code=ReplicationConnectionDown project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [warning] ReplicationConnectionDown: Replication connection has been terminated, recovery window opened
09:27:11.741 project=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Billing metrics: [:realtime, :connections]
09:27:16.223 [info] Starting replication for Broadcast Changes
09:27:16.223 error_code=DatabaseIpVersionIsIpv4 [warning] DatabaseIpVersionIsIpv4: Tenant database host 127.0.0.1 resolved to an IPv4 address
09:27:16.224 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Initializing connection with the status: %Realtime.Tenants.ReplicationConnection{
tenant_id: "vz25y4mz427vc65r6ph6eennz2ddu2ua",
opts: [],
step: :disconnected,
publication_name: "supabase_realtime_messages_publication",
replication_slot_name: "supabase_realtime_messages_replication_slot_",
output_plugin: "pgoutput",
proto_version: 2,
relations: %{},
buffer: [],
monitored_pid: #PID<0.49548.0>,
latency_committed_at: nil,
query_timeout: 240000
}
09:27:16.227 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Checking if replication slot supabase_realtime_messages_replication_slot_ exists
09:27:16.229 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Check publication supabase_realtime_messages_publication for table realtime.messages exists
09:27:16.230 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Publication supabase_realtime_messages_publication exists, validating contents
09:27:16.233 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Create replication slot supabase_realtime_messages_replication_slot_ using plugin pgoutput
09:27:16.742 project=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Billing metrics: [:realtime, :connections]
09:27:17.231 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] #PID<0.49621.0> Starting stream replication for slot supabase_realtime_messages_replication_slot_ using publication supabase_realtime_messages_publication and protocol version 2
09:27:17.233 error_code=ReplicationSlotLagTooHigh project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [error] ReplicationSlotLagTooHigh: Replication slot lag exceeds 50% of max_slot_wal_keep_size, shutting down
09:27:17.233 project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [error] GenServer #PID<0.49622.0> terminating
** (stop) :slot_lag_too_high
Last message: :health_check
09:27:17.233 error_code=ReplicationConnectionDown project=vz25y4mz427vc65r6ph6eennz2ddu2ua external_id=vz25y4mz427vc65r6ph6eennz2ddu2ua [warning] ReplicationConnectionDown: Replication connection has been terminated, recovery window opened
09:27:18.961 project=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Billing metrics: [:realtime, :rate_counter, :channel, :events]
09:27:21.743 project=vz25y4mz427vc65r6ph6eennz2ddu2ua [info] Billing metrics: [:realtime, :connections]
```
* chore: update @supabase/supabase-js to v2.112.4 * chore: update nix node_modules hash --------- Co-authored-by: supabase-workflow-trigger[bot] <266661614+supabase-workflow-trigger[bot]@users.noreply.github.com> Co-authored-by: supabase-autofix-bot <noreply@supabase.com>
No fix released yet and also shouldn't apply to us.
* chore: dependabot versioning strategy odd one, docs say the option is supported but it fails and says only this one is supported: ``` The property '#/updates/0/versioning-strategy' value "increase-if-necessary" did not match one of the following values: lockfile-only, auto ``` * Remove versioning strategy to get the strategy we want, thanks Leandro!
Accumulating multiple TCP ports stats would reset Prometheus counters when a TCP port reconnected
Override Joken's time adapter so time can freeze
* dependabot upgrades shouldn't influence the schemas, and if they did we should probably upgrade them manually * don't wanna duplicate the secrets we have here into a separate dependabot store
Replace a sleep with a forced synchronization point, so we know the message has been processed.
…7 updates (supabase#2132) * chore(deps-dev): bump the dev-and-test group across 1 directory with 7 updates Bumps the dev-and-test group with 7 updates in the / directory: | Package | From | To | | --- | --- | --- | | [benchee](https://github.com/bencheeorg/benchee) | `1.1.0` | `1.5.1` | | [credo](https://github.com/rrrene/credo) | `1.7.13` | `1.7.19` | | [mimic](https://github.com/edgurgel/mimic) | `2.3.0` | `2.3.1` | | [mint_web_socket](https://github.com/elixir-mint/mint_web_socket) | `1.0.4` | `1.0.6` | | [mix_test_watch](https://github.com/lpil/mix-test.watch) | `1.3.0` | `1.4.0` | | [phoenix_live_reload](https://github.com/phoenixframework/phoenix_live_reload) | `1.6.1` | `1.7.0` | | [sobelow](https://github.com/sobelow/sobelow) | `0.14.1` | `0.15.0` | Updates `benchee` from 1.1.0 to 1.5.1 - [Release notes](https://github.com/bencheeorg/benchee/releases) - [Changelog](https://github.com/bencheeorg/benchee/blob/main/CHANGELOG.md) - [Commits](bencheeorg/benchee@1.1.0...1.5.1) Updates `credo` from 1.7.13 to 1.7.19 - [Release notes](https://github.com/rrrene/credo/releases) - [Changelog](https://github.com/rrrene/credo/blob/master/CHANGELOG.md) - [Commits](rrrene/credo@v1.7.13...v1.7.19) Updates `mimic` from 2.3.0 to 2.3.1 - [Release notes](https://github.com/edgurgel/mimic/releases) - [Changelog](https://github.com/edgurgel/mimic/blob/main/CHANGELOG.md) - [Commits](edgurgel/mimic@v2.3.0...v2.3.1) Updates `mint_web_socket` from 1.0.4 to 1.0.6 - [Release notes](https://github.com/elixir-mint/mint_web_socket/releases) - [Changelog](https://github.com/elixir-mint/mint_web_socket/blob/main/CHANGELOG.md) - [Commits](elixir-mint/mint_web_socket@v1.0.4...v1.0.6) Updates `mix_test_watch` from 1.3.0 to 1.4.0 - [Changelog](https://github.com/lpil/mix-test.watch/blob/master/CHANGELOG.md) - [Commits](lpil/mix-test.watch@v1.3.0...v1.4.0) Updates `phoenix_live_reload` from 1.6.1 to 1.7.0 - [Changelog](https://github.com/phoenixframework/phoenix_live_reload/blob/main/CHANGELOG.md) - [Commits](phoenixframework/phoenix_live_reload@v1.6.1...v1.7.0) Updates `sobelow` from 0.14.1 to 0.15.0 - [Release notes](https://github.com/sobelow/sobelow/releases) - [Changelog](https://github.com/sobelow/sobelow/blob/main/CHANGELOG.md) - [Commits](sobelow/sobelow@v0.14.1...v0.15.0) --- updated-dependencies: - dependency-name: benchee dependency-version: 1.5.1 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-and-test - dependency-name: credo dependency-version: 1.7.19 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-and-test - dependency-name: mimic dependency-version: 2.3.1 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-and-test - dependency-name: mint_web_socket dependency-version: 1.0.6 dependency-type: direct:development update-type: version-update:semver-patch dependency-group: dev-and-test - dependency-name: mix_test_watch dependency-version: 1.4.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-and-test - dependency-name: phoenix_live_reload dependency-version: 1.7.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-and-test - dependency-name: sobelow dependency-version: 0.15.0 dependency-type: direct:development update-type: version-update:semver-minor dependency-group: dev-and-test ... Signed-off-by: dependabot[bot] <support@github.com> * chore: Use `not Enum.empty?` over `length() > 0` new credo picked this up, * chore: yes, you are right credo no negation in if/else --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tobias Pfeiffer <tobias.pfeiffer@supabase.io>
…2133) Bumps [phoenix_live_dashboard](https://github.com/phoenixframework/phoenix_live_dashboard) from 0.8.7 to 0.9.0. - [Release notes](https://github.com/phoenixframework/phoenix_live_dashboard/releases) - [Changelog](https://github.com/phoenixframework/phoenix_live_dashboard/blob/main/CHANGELOG.md) - [Commits](phoenixframework/phoenix_live_dashboard@v0.8.7...v0.9.0) --- updated-dependencies: - dependency-name: phoenix_live_dashboard dependency-version: 0.9.0 dependency-type: direct:production update-type: version-update:semver-minor ... There's a bunch of transitive changes here that dependabot didn't tell us about (but all minor/patch level) I went through the changelogs and they seem good _to me_: * [ecto](https://github.com/elixir-ecto/ecto/blob/master/CHANGELOG.md) - tons of bug fixes * [ecto_sql](https://github.com/elixir-ecto/ecto_sql/blob/master/CHANGELOG.md) - nice new features and PG 18 support * [live view](https://github.com/phoenixframework/phoenix_live_view/blob/main/CHANGELOG.md#v1210-2026-08-20) - tons of bug fixes and nice features * [telemetry_metrics](https://github.com/beam-telemetry/telemetry_metrics/blob/main/CHANGELOG.md#120) - Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…se#2134) Bumps [logflare_logger_backend](https://github.com/Logflare/logflare_logger_backend) from 0.11.4 to 0.11.7. - [Release notes](https://github.com/Logflare/logflare_logger_backend/releases) - [Commits](Logflare/logflare_logger_backend@v0.11.4...v0.11.7) --- updated-dependencies: - dependency-name: logflare_logger_backend dependency-version: 0.11.7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
adds a new opt in wait for pg changes to accept the connection.
```
channel.join({
config: {
postgres_changes: [],
postgres_changes_options: {
wait: true,
timeout: 15000 // optional, ms; clamped server-side to `postgres_changes_wait_max_timeout`
}
}
})
```
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upstream Sync
This PR contains the latest changes from the upstream repository.
Changes included:
Review checklist:
This PR was automatically created by the upstream sync workflow