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条评论

我猜我们只需要捕获异常并忽略,假设复制槽实际上已经存在?

保罗·科普斯通 6 分钟前
https://github.com/supabase/realtime/blob/04d7c1e27d8b66e9c9e6e805b6d52a256ffb4011/server/lib/adapters/postgres/epgsql_implementation.ex#L56
服务器/lib/适配器/postgres/epgsql_implementation.ex:56
defp create_replication_slot(epgsql_pid, slot) 做
https://github.com/supabase/realtime|supabase/realtime supabase/realtime | 由 GitHub 添加

保罗·科普斯通 5 分钟前
我们实际上可以传入一个唯一的 ID https://github.com/supabase/realtime/blob/04d7c1e27d8b66e9c9e6e805b6d52a256ffb4011/server/lib/adapters/postgres/epgsql_implementation.ex#L25
服务器/lib/适配器/postgres/epgsql_implementation.ex:25
create_replication_slot(epgsql_pid, Keyword.get(config, :slot, :temporary))
https://github.com/supabase/realtime|supabase/realtime supabase/realtime | 由 GitHub 添加

@kiwicopple我想我们解决了这个问题?

我想这是你只在本地看到的吗? 我不记得实际修复它,但我也没有看到它,也不知道如何复制它。

如果你高兴,如果我们再次看到它,我们可以关闭并再次访问它

作为参考,此错误仍然存​​在,并且可以轻松复制。

使用Dockerfile构建最新的 Docker 镜像,它是这个 repo 的一部分,并向它添加一个SLOT_NAME变量。

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 版本中解决了:tada:

该版本可在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 等级

相关问题

retendo picture retendo  ·  12评论

awalias picture awalias  ·  6评论

kiwicopple picture kiwicopple  ·  14评论

lacoprof picture lacoprof  ·  4评论

kwakwaversal picture kwakwaversal  ·  6评论