Rename use_replica_if_possible to fallback_to_replicas_for_ambiguous_queries
What does this MR do?
The first part of https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/1005. Originally, use_replica_if_possible was introduced in !56476 (merged).
This MR is to rename use_replica_if_possible to fallback_to_replicas_for_ambiguous_queries. This is straight-forward, just renaming, no logic changing.
After the change, the name fallback_to_replicas_for_ambigiuos_queries reflects the indication that the ambiguous SQL statements from anywhere inside this block should use a replica. The ambiguous statements include:
- Transactions.
- Custom queries (via exec_query, execute, etc.)
- In-flight connection configuration change (SET LOCAL statement_timeout = 5000)
This is a weak enforcement. This helper incorporates well with primary stickiness:
- If the queries are about to write
- The current session already performed writes
- It prefers to use primary, aka, use_primary or use_primary! were called
Screenshots (strongly suggested)
This is an internal change only. No need to attach a screenshot.
Does this MR meet the acceptance criteria?
Conformity
📋 Does this MR need a changelog?- [-] I have included a changelog entry.
- I have not included a changelog entry because this MR is to rename an internal change at DB load balancing layer.
- [-] Documentation (if required)
- Code review guidelines
- Merge request performance guidelines
- [-] Style guides
- Database guides
- [-] Separation of EE specific content
Availability and Testing
- Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process.
- [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Edited by Quang-Minh Nguyen (Ex-GitLab)