You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently swapped my company's database adapter over from mysql2 to trilogy and noticed that we were no longer rescuing ActiveRecord::ReadOnlyError exceptions because we started receiving ActiveRecord::StatementInvalid instead. Is it intended that Trilogy overwrites ActiveRecord::ReadOnlyError with ActiveRecord::StatementInvalid and, if so, may I ask why?
Further context:
My company uses Doorkeeper for Oauth2 in our Rails app. Doorkeeper utilizes oauth application credentials to create Doorkeeper::AccessToken objects with a token value users/APIs use when making requests to our own API. These token objects have a previous_refresh_token field that is "" by default and becomes populated with the previously used refresh token when you refresh your token.
On any given request, Doorkeeper will reset the previous_refresh_token column to "" if it is not currently "". So if you make a GET request with a token that was refreshed Doorkeeper will update the token and cause a write to the DB. This becomes a problem when all GET requests get routed to a reader connection. Previously we were capturing this case by rescuing ActiveRecord::ReadOnlyError but that changed and we were no longer handling these exceptions. I fixed it by additionally rescuing ActiveRecord::StatementInvalid but could've also fixed by simply executing all doorkeeper_token calls within a writer connection. However I am curious why this changed to begin with.
Edit: for more context, we're using Rails 6.1; not Rails 7+.
The text was updated successfully, but these errors were encountered:
(which doesn't include the check at least on Rails 6.1).
So we might might need to add a similar readonly check to this gem to get the behavior to match. The easiest way to do that is probably to implement this method:
I recently swapped my company's database adapter over from
mysql2
totrilogy
and noticed that we were no longer rescuingActiveRecord::ReadOnlyError
exceptions because we started receivingActiveRecord::StatementInvalid
instead. Is it intended that Trilogy overwritesActiveRecord::ReadOnlyError
withActiveRecord::StatementInvalid
and, if so, may I ask why?Further context:
My company uses Doorkeeper for Oauth2 in our Rails app. Doorkeeper utilizes oauth application credentials to create
Doorkeeper::AccessToken
objects with a token value users/APIs use when making requests to our own API. These token objects have aprevious_refresh_token
field that is""
by default and becomes populated with the previously used refresh token when you refresh your token.On any given request, Doorkeeper will reset the
previous_refresh_token
column to""
if it is not currently""
. So if you make a GET request with a token that was refreshed Doorkeeper will update the token and cause a write to the DB. This becomes a problem when all GET requests get routed to a reader connection. Previously we were capturing this case by rescuingActiveRecord::ReadOnlyError
but that changed and we were no longer handling these exceptions. I fixed it by additionally rescuingActiveRecord::StatementInvalid
but could've also fixed by simply executing alldoorkeeper_token
calls within a writer connection. However I am curious why this changed to begin with.Edit: for more context, we're using Rails 6.1; not Rails 7+.
The text was updated successfully, but these errors were encountered: