You can specify the user-level session variable proxy_route_policy to make the OceanBase Database Proxy (ODP) first read data from a follower. This setting takes effect in weak consistency read mode. When the setting is in effect, data is first read from a follower instead of a replica selected by the load balancer. To enable follower-first read, perform the following steps:
Log on to the business tenant from a supported client tool. Execute the following statement to set the proxy_route_policy variable:
obclient> SET @proxy_route_policy='[policy]';
Valid values of the [policy] parameter:
follower_first: ODP reads data first from a follower, even if the cluster is in a major compaction. The priority order is as follows:Follower not in a major compaction in the same IDC > Follower not in a major compaction in a different IDC in the same region > Follower in a major compaction in the same IDC > Follower in a major compaction in a different IDC in the same region > Leader not in a major compaction in the same IDC > Leader not in a major compaction in a different IDC in the same region > Follower not in a major compaction in a different region > Follower in a major compaction in a different region > Leader not in a major compaction in a different region > Leader in a major compaction in a different region
unmerge_follower_first: ODP reads data first from a follower that is not in a major compaction. The priority order is as follows:Follower not in a major compaction in the same IDC > Follower not in a major compaction in a different IDC in the same region > Leader not in a major compaction in the same IDC > Leader not in a major compaction in a different IDC in the same region > Follower in a major compaction in the same IDC > Follower in a major compaction in a different IDC in the same region > Follower not in a major compaction in a different region > Leader not in a major compaction in a different region > Follower in a major compaction in a different region > Leader in a major compaction in a different region
Other values: The normal load-balanced routing logic in weak consistency read mode is adopted. The priority order is as follows:
Leader or follower not in a major compaction in the same IDC > Leader or follower not in a major compaction in a different IDC in the same region > Leader or follower in a major compaction in the same IDC > Leader or follower in a major compaction in a different IDC in the same region –> Leader or follower not in a major compaction in a different region > Leader or follower in a major compaction in a different region