trilogy-libraries / trilogy

Trilogy is a client library for MySQL-compatible database servers, designed for performance, flexibility, and ease of embedding.
MIT License
700 stars 69 forks source link

Call `getaddrinfo` from Ruby #139

Open casperisfine opened 10 months ago

casperisfine commented 10 months ago

Ref: https://bugs.ruby-lang.org/issues/19965

getaddrinfo is notorious for not having a timeout, which can make it hang for a very long time. Since Trilogy releases the GVL before calling it, that can cause the whole VM to be unresponsive and no longer respond to ctrl+c etc.

In 3.3.0, Ruby is now doing name resolution from a background thread, making Socket.getaddrinfo interruptible. So by doing the name resolution on the Ruby side, we should avoid such scenarios.

@jhawthorn @matthewd @composerinteralia @adrianna-chang-shopify what do you think?

jhawthorn commented 10 months ago

I think it's a good idea to use Ruby as much as we can, but I'm also a bit unsure about the IP sorting

casperisfine commented 10 months ago

I'm also a bit unsure about the IP sorting

Yeah me too, I think I need to dig a bit more on how this works