Configurable pgpool/pgDog backends (multi-emit)#3
Open
raivil wants to merge 9 commits into
Open
Conversation
QueryCache#select_all compiles the arel to SQL (adding the backend comment), then hands that SQL string to DatabaseStatements#select_all, so to_sql_and_binds runs twice. Under PgpoolNoLoadBalance.force the thread-local stays true across both passes, so the marker was prepended twice (e.g. inside Sidekiq jobs / web requests where the query cache is on). Make prepending idempotent via a shared prepend_comment helper. Bump to 1.3.1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Generalizes the single primary-pinning comment into a configurable, multi-valued
PgpoolNoLoadBalance.backends. The gem can now emit the pgpool hint, the pgDog hint, or both at once during a migration.:pgpool(default)/*NO LOAD BALANCE*/:pgdog/* pgdog_role: primary */Emission order is always pgpool-first regardless of input order. Unknown/empty backends raise
ArgumentError. Default[:pgpool]keeps existing behavior identical.Why both comments work behind either router (verified against source)
allow_sql_commentsdefaults tooff;is_select_query()routes any SELECT not starting withs/(/w/tto the primary, so any leading comment qualifies.parse_edge_commentmerges all consecutive leading block comments into one slice before regex-scanning forpgdog_role:(proven by its owntest_remove_comment_multiple_leading), so the directive in the second comment is still found.Compatibility
no_load_balance;pgpool_nlbremains a full alias (method,execute:keyword, unscope symbol).PgpoolNoLoadBalance.forceand the Rails 8 4-argto_sql_and_binds(the abandonedfeature/pgdog-backend-supportbranch dropped both — this branch is built oncminstead).ExplainSubscriberstrips every known backend comment.Tests
bundle exec rspec→ 39 examples, 0 failures.Deployment prerequisites (not code-enforced)
allow_sql_commentsoff (default).