supabase / realtime

Broadcast, Presence, and Postgres Changes via WebSockets
https://supabase.com/realtime
Apache License 2.0
6.56k stars 289 forks source link

Startup error running migrations: table identifier does not refer to an existing ETS table #738

Open chetan opened 7 months ago

chetan commented 7 months ago

Bug report

Migrations fail to run properly. Appears to be due to the use of Mix.env() introduced in #736.

supabase-realtime  | Setting RLIMIT_NOFILE to 100000
supabase-realtime  | 13:58:43.351 [info] Migrations already up
supabase-realtime  | ** (ArgumentError) errors were found at the given arguments:
supabase-realtime  |
supabase-realtime  |   * 1st argument: the table identifier does not refer to an existing ETS table
supabase-realtime  |
supabase-realtime  |     (stdlib 4.3) :ets.lookup(Mix.State, :env)
supabase-realtime  |     lib/mix/state.ex:31: Mix.State.get/2
supabase-realtime  |     /app/lib/realtime-2.25.32/priv/repo/seeds.exs:5: (file)
supabase-realtime  |     nofile:1: (file)
supabase-realtime  |     (stdlib 4.3) erl_eval.erl:748: :erl_eval.do_apply/7
supabase-realtime  |     (stdlib 4.3) erl_eval.erl:492: :erl_eval.expr/6
supabase-realtime  |     (stdlib 4.3) erl_eval.erl:136: :erl_eval.exprs/6
supabase-realtime  | erl_child_setup: failed with error 32 on line 281

I took a look at fixing this but don't know elixir at all. According to the docs, Mix.env() shouldn't be used in production code (i.e., outside the build system), but I do see it being used in other places in the codebase. Not sure why it's throwing here and not elsewhere.

To Reproduce

Run the latest realtime image supabase/realtime:v2.25.32 on an existing instance (likely throws on fresh data as well)

chetan commented 7 months ago

/cc: @filipecabaco

filipecabaco commented 7 months ago

opening PR πŸ‘€ thank you again for flagging this issues

filipecabaco commented 7 months ago

@chetan where are you running the image? supabase docker compose or cli?

filipecabaco commented 7 months ago

ok was able to replicate in the supabase/docker πŸ‘ will test the fix

filipecabaco commented 7 months ago

https://github.com/supabase/realtime/pull/739

filipecabaco commented 7 months ago

Merged πŸŽ‰

chetan commented 7 months ago

Verified!

filipecabaco commented 7 months ago

thank you so much for reporting and patience πŸ™

Silur commented 1 month ago

still encountering this on CLI version 1.165.0 and realtime v2.28.32

Silur commented 1 week ago

still present on CLI 1.176.10 and realtime v2.28.32

filipecabaco commented 1 week ago

@Silur could you share the command and logs so I can try to replicate it?