Skip to content

Rename use_replica_if_possible to fallback_to_replicas_for_ambiguous_queries

What does this MR do?

The first part of gitlab-com/gl-infra/scalability#1005 (closed). 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

Availability and Testing

Edited by Quang-Minh Nguyen

Merge request reports