Realtime: ์ถฉ๋Œ: ๋ณต์ œ ์Šฌ๋กฏ์ด ์ด๋ฏธ ์žˆ์Šต๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2020๋…„ 03์›” 09์ผ  ยท  9์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: supabase/realtime

07:19:50.702 [info] Running RealtimeWeb.Endpoint with cowboy 2.6.3 at :::4000 (http)
07:19:50.703 [info] Access RealtimeWeb.Endpoint at http://localhost:4000
07:19:50.799 [info] Application realtime exited: Realtime.Application.start(:normal, []) returned an error: shutdown: failed to start child: Realtime.Replication
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:error, :error, "42710", :duplicate_object, "replication slot \"pid0_2356_0\" already exists", [file: "slot.c", line: "251", routine: "ReplicationSlotCreate", severity: "ERROR"]}}
            (realtime) lib/adapters/postgres/epgsql_implementation.ex:24: Realtime.Adapters.Postgres.EpgsqlImplementation.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Kernel pid terminated (application_controller) ({application_start_failure,realtime,{{shutdown,{failed_to_start_child,'Elixir.Realtime.Replication',{{badmatch,{error,{error,error,<<"42710">>,duplicate
{"Kernel pid terminated",application_controller,"{application_start_failure,realtime,{{shutdown,{failed_to_start_child,'Elixir.Realtime.Replication',{{badmatch,{error,{error,error,<<\"42710\">>,duplicate_object,<<\"replication slot \\"pid0_2356_0\\" already exists\">>,[{file,<<\"slot.c\">>},{line,<<\"251\">>},{routine,<<\"ReplicationSlotCreate\">>},{severity,<<\"ERROR\">>}]}}},[{'Elixir.Realtime.Adapters.Postgres.EpgsqlImplementation',init,1,[{file,\"lib/adapters/postgres/epgsql_implementation.ex\"},{line,24}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,374}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,249}]}]}}},{'Elixir.Realtime.Application',start,[normal,[]]}}}"}
Crash dump is being written to: erl_crash.dump...done
alpha released

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

๋†€๋ž์Šต๋‹ˆ๋‹ค. @kwakwaversal ๋ณต์ œ ๋‹จ๊ณ„์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ๋” ์‰ฝ๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” YC ๋ฐ๋ชจ ๋ฐ์ด๋ฅผ ๋ง‰ ํ†ต๊ณผํ•˜๊ณ  ์žˆ์ง€๋งŒ ๊ฐ€๋Šฅํ•œ ํ•œ ๋นจ๋ฆฌ ์ด ๋ฌธ์ œ์— ๋›ฐ์–ด๋“ค๊ฒ ์Šต๋‹ˆ๋‹ค.

๋ชจ๋“  9 ๋Œ“๊ธ€

๋ณต์ œ ์Šฌ๋กฏ์ด ์‹ค์ œ๋กœ ์ด๋ฏธ ์กด์žฌํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜๊ณ  ์˜ˆ์™ธ๋ฅผ ํฌ์ฐฉํ•˜๊ณ  ๋ฌด์‹œํ•ด์•ผ ํ•œ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Paul Copplestone 6๋ถ„ ์ „
https://github.com/supabase/realtime/blob/04d7c1e27d8b66e9c9e6e805b6d52a256ffb4011/server/lib/adapters/postgres/epgsql_implementation.ex#L56
์„œ๋ฒ„/lib/adapters/postgres/epgsql_implementation.ex:56
defp create_replication_slot(epgsql_pid, ์Šฌ๋กฏ) ์ˆ˜ํ–‰
https://github.com/supabase/realtime|supabase/realtime ์ˆ˜ํŒŒ๋ฒ ์ด์Šค/์‹ค์‹œ๊ฐ„ | GitHub์—์„œ ์ถ”๊ฐ€ํ•จ

Paul Copplestone 5๋ถ„ ์ „
์šฐ๋ฆฌ๋Š” ์‹ค์ œ๋กœ ๊ณ ์œ  ID https://github.com/supabase/realtime/blob/04d7c1e27d8b66e9c9e6e805b6d52a256ffb4011/server/lib/adapters/postgres/epgsql_implementation.ex#L25
์„œ๋ฒ„/lib/adapters/postgres/epgsql_implementation.ex:25
create_replication_slot(epgsql_pid, Keyword.get(config, :slot, :temporary))
https://github.com/supabase/realtime|supabase/realtime ์ˆ˜ํŒŒ๋ฒ ์ด์Šค/์‹ค์‹œ๊ฐ„ | GitHub์—์„œ ์ถ”๊ฐ€ํ•จ

@kiwicopple ์šฐ๋ฆฌ๊ฐ€ ์ด๊ฒƒ์„

ํ˜„์ง€์—์„œ๋งŒ ๋ณธ๊ฑฐ ๊ฐ™์€๋ฐ? ์‹ค์ œ๋กœ ์ˆ˜์ •ํ•œ ๊ธฐ์–ต์€ ์—†์ง€๋งŒ ๋ณธ ์ ์ด ์—†์œผ๋ฉฐ ๋ณต์ œํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ๋ชจ๋ฆ…๋‹ˆ๋‹ค.

์ฆ๊ฑฐ์šฐ๋ฉด ๋ฌธ์„ ๋‹ซ๊ณ  ๋‹ค์‹œ ๋ณด๊ฒŒ๋˜๋ฉด ๋‹ค์‹œ ๋ฐฉ๋ฌธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค

์ฐธ๊ณ ๋กœ ์ด ๋ฒ„๊ทธ๋Š” ์—ฌ์ „ํžˆ ์กด์žฌํ•˜๋ฉฐ ์‰ฝ๊ฒŒ ๋ณต์ œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ด ์ €์žฅ์†Œ์˜ ์ผ๋ถ€์ธ Dockerfile ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์ตœ์‹  Docker ์ด๋ฏธ์ง€๋ฅผ ๋นŒ๋“œํ•˜๊ณ  SLOT_NAME env ๋ณ€์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜์‹ญ์‹œ์˜ค.

docker run \
  -e DB_HOST='docker.for.mac.host.internal' \
  -e DB_NAME='postgres' \
  -e DB_USER='postgres' \
  -e DB_PASSWORD='postgres' \
  -e DB_PORT=5432 \
  -e PORT=4000 \
  -e HOSTNAME='localhost' \
  -e SECRET_KEY_BASE='SOMETHING_SUPER_SECRET' \
  -e SLOT_NAME='COOL' \
  -p 4000:4000 \
  supabase/realtime

์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ค‘์ง€ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ์œ„์˜ Docker ๋ช…๋ น์„ ๋‹ค์‹œ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

2020-08-25 22:41:59.295 [info] Running RealtimeWeb.Endpoint with cowboy 2.6.3 at :::4000 (http)
2020-08-25 22:41:59.295 [info] Access RealtimeWeb.Endpoint at http://localhost:4000
2020-08-25 22:41:59.317 [info] Application realtime exited: Realtime.Application.start(:normal, []) returned an error: shutdown: failed to start child: Realtime.Replication
    ** (EXIT) an exception was raised:
        ** (MatchError) no match of right hand side value: {:error, {:error, :error, "42710", :duplicate_object, "replication slot \"cool\" already exists", [file: "slot.c", line: "253", routine: "ReplicationSlotCreate", severity: "ERROR"]}}
            (realtime) lib/adapters/postgres/epgsql_implementation.ex:24: Realtime.Adapters.Postgres.EpgsqlImplementation.init/1
            (stdlib) gen_server.erl:374: :gen_server.init_it/2
            (stdlib) gen_server.erl:342: :gen_server.init_it/6
            (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
{"Kernel pid terminated",application_controller,"{application_start_failure,realtime,{{shutdown,{failed_to_start_child,'Elixir.Realtime.Replication',{{badmatch,{error,{error,error,<<\"42710\">>,duplicate_object,<<\"replication slot \\"cool\\" already exists\">>,[{file,<<\"slot.c\">>},{line,<<\"253\">>},{routine,<<\"ReplicationSlotCreate\">>},{severity,<<\"ERROR\">>}]}}},[{'Elixir.Realtime.Adapters.Postgres.EpgsqlImplementation',init,1,[{file,\"lib/adapters/postgres/epgsql_implementation.ex\"},{line,24}]},{gen_server,init_it,2,[{file,\"gen_server.erl\"},{line,374}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,342}]},{proc_lib,init_p_do_apply,3,[{file,\"proc_lib.erl\"},{line,249}]}]}}},{'Elixir.Realtime.Application',start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,realtime,{{shutdown,{failed_to_start_child,'Elixir.Realtime.Replication',{{badmatch,{error,{error,error,<<"42710">>,duplicate

https://github.com/supabase/realtime/blob/master/server/lib/adapters/postgres/epgsql_implementation.ex#L75 ์˜ ์ค„์„ {name, "SELECT 1"} _after_ ์ด๋ฆ„์ด ์ง€์ •๋œ ๋ณต์ œ ์Šฌ๋กฏ "COOL"๋กœ ๋ณ€๊ฒฝํ•˜๋ฉด ์ƒ์„ฑ ๋œ. ์˜ˆ์ƒ๋Œ€๋กœ ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. ๋‚ด ์ƒ๊ฐ์—๋Š” ์ด ์„น์…˜์˜ ๋…ผ๋ฆฌ๊ฐ€ ์ž˜๋ชป๋˜์—ˆ์ง€๋งŒ ํŒจ์น˜๋ฅผ ์ œ๊ณตํ•  ๋งŒํผ Elixir๋ฅผ ์ดํ•ดํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.

๋†€๋ž์Šต๋‹ˆ๋‹ค. @kwakwaversal ๋ณต์ œ ๋‹จ๊ณ„์— ๊ฐ์‚ฌ๋“œ๋ฆฝ๋‹ˆ๋‹ค. ์ด ๋ฌธ์ œ๋ฅผ ๋” ์‰ฝ๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์šฐ๋ฆฌ๋Š” YC ๋ฐ๋ชจ ๋ฐ์ด๋ฅผ ๋ง‰ ํ†ต๊ณผํ•˜๊ณ  ์žˆ์ง€๋งŒ ๊ฐ€๋Šฅํ•œ ํ•œ ๋นจ๋ฆฌ ์ด ๋ฌธ์ œ์— ๋›ฐ์–ด๋“ค๊ฒ ์Šต๋‹ˆ๋‹ค.

@kiwicopple ์ด๊ฒƒ์€ ์˜ˆ๋ฅผ ๋“ค์–ด AWS์˜ ECS ์ž‘์—…์—์„œ ๊ณ„์† ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ์ƒˆ ์ž‘์—…์ด ์ด์ „ ์ž‘์—…์ด ์ข…๋ฃŒ๋˜๊ธฐ ์ „์— ์‹œ์ž‘๋œ ๊ฒฝ์šฐ์ž…๋‹ˆ๋‹ค. ์ด์ „ ์Šฌ๋กฏ์€ ๋ณต์ œ ์Šฌ๋กฏ ID๋ฅผ ํ•ด์ œํ•˜์ง€ ์•Š์€ ๋ฐ˜๋ฉด ์ƒˆ ์Šฌ๋กฏ์€ ์š”์ฒญํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

:tada: ์ด ๋ฌธ์ œ๋Š” ๋ฒ„์ „ 0.7.9์—์„œ ํ•ด๊ฒฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋ฆด๋ฆฌ์Šค๋Š” GitHub ๋ฆด๋ฆฌ์Šค์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์‹œ๋งจํ‹ฑ ๋ฆด๋ฆฌ์Šค ๋ด‡ :package::rocket:

@kwakwaversal ๋‹˜ ์˜ ๋ฉ”์‹œ์ง€ ๋•๋ถ„์— ์ด ๋ฌธ์ œ๊ฐ€ ํ•ด๊ฒฐ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๋ฌธ์ œ๋Š” Postgres๊ฐ€ ์Šฌ๋กฏ์„ ์†Œ๋ฌธ์ž๋กœ ์ €์žฅํ•œ๋‹ค๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

image

๊ธฐ์กด ์Šฌ๋กฏ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•˜๊ธฐ ์ „์— SLOT_NAME var๋ฅผ ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜ํ•˜๋„๋ก ์ตœ์‹  ๋ฆด๋ฆฌ์Šค๋ฅผ ์—…๋ฐ์ดํŠธํ–ˆ์Šต๋‹ˆ๋‹ค.

๋ฒ„์ „ 0.7.9์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

docker pull supabase/realtime:v0.7.9

docker run \
  -e DB_HOST='docker.for.mac.host.internal' \
  -e DB_NAME='postgres' \
  -e DB_USER='postgres' \
  -e DB_PASSWORD='postgres' \
  -e DB_PORT=5432 \
  -e PORT=4000 \
  -e HOSTNAME='localhost' \
  -e SECRET_KEY_BASE='SOMETHING_SUPER_SECRET' \
  -e SLOT_NAME='COOL' \
  -p 4000:4000 \
  supabase/realtime:v0.7.9

๋‹น์‹ ์„ ์œ„ํ•ด ์ž‘๋™ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์ž์œ ๋กญ๊ฒŒ ๋‹ค์‹œ ์—ฝ๋‹ˆ๋‹ค!

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰