-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce adapter for Trilogy, a MySQL-compatible DB client #47880
Introduce adapter for Trilogy, a MySQL-compatible DB client #47880
Conversation
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it.
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it.
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it.
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it.
Ok the trilogy build is working now, and I fixed some Railties tests. We're green here but locally I noticed a couple flakey tests in mysql2 and trilogy (same ones) regarding closed connections. If I get a chance I'll take a deeper look but I'm not sure they are flaky on CI - might just be locally. |
I can't reproduce this now so it must have been something else wrong. So I think other then the encoding work this is good to go. I asked the rest of core to take a look to make sure I'm not missing anything. Great work @adrianna-chang-shopify! |
Encoding work is shipped! We should also ship the changes to the SyscallErrors in the client to make sure all of the client errors can be rescued as |
13604c6
to
224d03e
Compare
The [Trilogy database client][trilogy-client] and corresponding [Active Record adapter][ar-adapter] were both open sourced by GitHub last year. Shopify has recently taken the plunge and successfully adopted Trilogy in their Rails monolith. With two major Rails applications running Trilogy successfully, we'd like to propose upstreaming the adapter to Rails as a MySQL-compatible alternative to Mysql2Adapter. [trilogy-client]: https://github.com/github/trilogy [ar-adapter]: https://github.com/github/activerecord-trilogy-adapter Co-authored-by: Aaron Patterson <tenderlove@github.com> Co-authored-by: Adam Roben <adam@roben.org> Co-authored-by: Ali Ibrahim <aibrahim2k2@gmail.com> Co-authored-by: Aman Gupta <aman@tmm1.net> Co-authored-by: Arthur Nogueira Neves <github@arthurnn.com> Co-authored-by: Arthur Schreiber <arthurschreiber@github.com> Co-authored-by: Ashe Connor <kivikakk@github.com> Co-authored-by: Brandon Keepers <brandon@opensoul.org> Co-authored-by: Brian Lopez <seniorlopez@gmail.com> Co-authored-by: Brooke Kuhlmann <brooke@testdouble.com> Co-authored-by: Bryana Knight <bryanaknight@github.com> Co-authored-by: Carl Brasic <brasic@github.com> Co-authored-by: Chris Bloom <chrisbloom7@github.com> Co-authored-by: Cliff Pruitt <cliff.pruitt@cliffpruitt.com> Co-authored-by: Daniel Colson <composerinteralia@github.com> Co-authored-by: David Calavera <david.calavera@gmail.com> Co-authored-by: David Celis <davidcelis@github.com> Co-authored-by: David Ratajczak <david@mockra.com> Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: Eileen Uchitelle <eileencodes@gmail.com> Co-authored-by: Enrique Gonzalez <enriikke@gmail.com> Co-authored-by: Garrett Bjerkhoel <garrett@github.com> Co-authored-by: Georgi Knox <georgicodes@github.com> Co-authored-by: HParker <HParker@github.com> Co-authored-by: Hailey Somerville <hailey@hailey.lol> Co-authored-by: James Dennes <jdennes@gmail.com> Co-authored-by: Jane Sternbach <janester@github.com> Co-authored-by: Jess Bees <toomanybees@github.com> Co-authored-by: Jesse Toth <jesse.toth@github.com> Co-authored-by: Joel Hawksley <joelhawksley@github.com> Co-authored-by: John Barnette <jbarnette@github.com> Co-authored-by: John Crepezzi <john.crepezzi@gmail.com> Co-authored-by: John Hawthorn <john@hawthorn.email> Co-authored-by: John Nunemaker <nunemaker@gmail.com> Co-authored-by: Jonathan Hoyt <hoyt@github.com> Co-authored-by: Katrina Owen <kytrinyx@github.com> Co-authored-by: Keeran Raj Hawoldar <keeran@gmail.com> Co-authored-by: Kevin Solorio <soloriok@gmail.com> Co-authored-by: Leo Correa <lcorr005@gmail.com> Co-authored-by: Lizz Hale <lizzhale@github.com> Co-authored-by: Lorin Thwaits <lorint@gmail.com> Co-authored-by: Matt Jones <al2o3cr@gmail.com> Co-authored-by: Matthew Draper <matthewd@github.com> Co-authored-by: Max Veytsman <mveytsman@github.com> Co-authored-by: Nathan Witmer <nathan@zerowidth.com> Co-authored-by: Nick Holden <nick.r.holden@gmail.com> Co-authored-by: Paarth Madan <paarth.madan@shopify.com> Co-authored-by: Patrick Reynolds <patrick.reynolds@github.com> Co-authored-by: Rob Sanheim <rsanheim@gmail.com> Co-authored-by: Rocio Delgado <rocio@github.com> Co-authored-by: Sam Lambert <sam.lambert@github.com> Co-authored-by: Shay Frendt <shay@github.com> Co-authored-by: Shlomi Noach <shlomi-noach@github.com> Co-authored-by: Sophie Haskins <sophaskins@github.com> Co-authored-by: Thomas Maurer <tma@github.com> Co-authored-by: Tim Pease <tim.pease@gmail.com> Co-authored-by: Yossef Mendelssohn <ymendel@pobox.com> Co-authored-by: Zack Koppert <zkoppert@github.com> Co-authored-by: Zhongying Qiao <cryptoque@users.noreply.github.com>
224d03e
to
5ed3f60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🙌🏻
We can DRY some of the code up between Trilogy and the existing Mysql2 adapter, but I'm proposing we copy everything verbatim for now to ensure full test coverage, and clean things up in a subsequent PR.
👍🏻
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it. The build is scoped to Rails 7.1 and above since we will not support Trilogy for older versions of Rails.
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it. The build is scoped to Rails 7.1 and above since we will not support Trilogy for older versions of Rails.
…ngly Trilogy has been in production use for quite some time and will see official Rails support soon: rails/rails#47880 This makes sure we detect the usage of trilogy and adapt the output accordingly. We also skip installing the libmysql-dev headers, since they're not needed with trilogy.
In rails/rails#47880 we're adding Trilogy as an additional mysql client for Rails. This change adds a new build for it. The build is scoped to Rails 7.1 and above since we will not support Trilogy for older versions of Rails.
Motivation / Background
The Trilogy database client and corresponding Active Record adapter were both open sourced by GitHub last year. Shopify adopted Trilogy successfully in our Rails monolith several weeks ago.
With two major Rails applications running Trilogy successfully, we'd like to propose upstreaming the adapter to Rails as a MySQL-compatible alternative to
Mysql2Adapter
.This effort is a collaboration between @adrianna-chang-shopify and @eileencodes (Shopify) and @matthewd (GitHub). Original authors of the adapter library are credited.
Detail
This PR ports over the adapter code and all of the test cases from https://github.com/github/activerecord-trilogy-adapter. We can DRY some of the code up between
Trilogy
and the existingMysql2
adapter, but I'm proposing we copy everything verbatim for now to ensure full test coverage, and clean things up in a subsequent PR.Additional changes made:
#explain
on theTrilogyAdapter
for parity with Mysql2trilogy
option for applicationsTrilogyAdapter#select_all
updated to ensure connection returned to a good state afterMULTI_RESULT
queryAdditional information
This is blocked by trilogy-libraries/trilogy#64 on the client side. Once that ships, we should release a new version of the client and update the Gemfile to match.
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]