Skip to content

Conversation

@Th3-M4jor
Copy link
Contributor

We were testing out YugabyteDB with nodes in Australia, France, and the Eastern US and found that Postgrex connections were consistently failing to startup when connecting to nodes in France or Australia if we wanted to have a pool size greater than one.

The root cause is that the bootstrap queries Postgrex makes are taking a lot longer than the 60 seconds the TypeServer allows while a connection is waiting to get the lock.

This is because the first query of a connection forces the node to cache cluster information from the leader node, which can take a long time when the leader is on the opposite side of the world.

Yugabyte has "smart" drivers that are able to work around this issue, but there isn't one in Elixir so the simplest solution would be us being able to raise this timeout to a much higher number.

@Th3-M4jor Th3-M4jor force-pushed the make-typeserver-timeout-configurable branch from 893e733 to 9ca8a08 Compare November 28, 2025 19:39
defstruct [:types, :connections, :lock, :waiting]

@timeout 60_000
@timeout Application.compile_env(:postgrex, :type_server_timeout, 60_000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it needs to be a compile time setting. Let's move it to runtime. Also, move the default value to the def application section in the mix.exs, this way we can use fetch_env! here. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback.

@Th3-M4jor Th3-M4jor force-pushed the make-typeserver-timeout-configurable branch from 9ca8a08 to e39bac0 Compare November 28, 2025 21:03
@josevalim josevalim merged commit f20274a into elixir-ecto:master Nov 28, 2025
13 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

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.

2 participants