You can set OBProxy to first read from a follower by controlling the routing policy through the setting of the proxy_route_policy variable. This setting takes effect in the weak consistency read mode. When it is effective, data is first read from a follower instead of a replica selected by the load balancer.
Log on to the sys tenant as the root user from OceanBase Client (OBClient). Execute the following statement to set the proxy_route_policy variable:
obclient> SET @proxy_route_policy='[policy]';
You can set the [policy] parameter to one of the three following values:
follower_first: reads first from a follower, even if the cluster is undergoing a major compaction. Priority order:Follower not in a major compaction in the same data center > Follower not in a major compaction in a different data center in the same region > Follower in a major compaction in the same data center > Follower in a major compaction in a different data center in the same region > Leader not in a major compaction in the same data center > Leader not in a major compaction in a different data center 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: reads first from a follower that is not in a major compaction. Priority order:Follower not in a major compaction in the same data center > Follower not in a major compaction in a different data center in the same region > Leader not in a major compaction in the same data center > Leader not in a major compaction in a different data center in the same region > Follower in a major compaction in the same data center > Follower in a major compaction in a different data center 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
When the parameter is set to another value, the normal load-balancing route logic of weak consistency read mode is adopted. Priority order:
Leader or follower not in a major compaction in the same data center > Leader or follower not in a major compaction in a different data center in the same region > Leader or follower in a major compaction in the same data center > Leader or follower in a major compaction in a different data center 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