Skip to content
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

Pass along with_raw_connection params in PG adapter #49970

Conversation

composerinteralia
Copy link
Member

Prior to this commit we were passing allow_retry and materialize_transactions through from execute_and_clear to exec_cache/exec_no_cache, but then doing nothing with them.

We've got a few internal queries using execute_and_clear (mostly via internal_exec_query) that are passing allow_retry: true and materialize_transactions: false. These calls will fail on connection errors that might have been retryable. It's also possible they are materializing transactions earlier than expected (although probably not—most of the methods look like they would be called only by us, always outside a transaction).

This commit forwards the arguments through to with_raw_connection so the callers get the behavior they likely expect.

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one change. Changes that are unrelated should be opened in separate PRs.
  • Commit message has a detailed description of what changed and why. If this PR fixes a related issue include it in the commit message. Ex: [Fix #issue-number]
  • Tests are added or updated if you fix a bug or add a feature.
  • CHANGELOG files are updated for the changed libraries if there is a behavior change or additional feature. Minor bug fixes and documentation changes should not be included.

Prior to this commit we were passing `allow_retry` and
`materialize_transactions` through from `execute_and_clear` to
`exec_cache`/`exec_no_cache`, but then doing nothing with them.

We've got a few internal queries using `execute_and_clear` (mostly via
`internal_exec_query`) that are passing `allow_retry: true` and
`materialize_transactions: false`. These calls will fail on connection
errors that might have been retryable. It's also possible they are
materializing transactions earlier than expected (although probably
not—most of the methods look like they would be called only by us,
always outside a transaction).

This commit forwards the arguments through to `with_raw_connection` so
the callers get the behavior they likely expect.
@composerinteralia
Copy link
Member Author

I didn't add a test because this is more of an optimization than a bug fix, but I could probably test that one of the internal postgres queries retries after a disconnect if we'd like coverage.

@rafaelfranca rafaelfranca merged commit b6fb508 into rails:main Nov 8, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants