Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(spanner): add the final pieces for the RouteToLeaderOption #11112

Merged
merged 4 commits into from
Mar 28, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make ${GOOGLE_CLOUD_CPP_SPANNER_ROUTE_TO_LEADER} override any user
setting for the `RouteToLeaderOption`, rather than giving the default
value when there is no user setting.
devbww committed Mar 27, 2023
commit ad184a3491416e192b3f63649fd70e9897bdbffe
25 changes: 15 additions & 10 deletions google/cloud/spanner/internal/defaults.cc
Original file line number Diff line number Diff line change
@@ -104,17 +104,22 @@ Options DefaultOptions(Options opts) {
min_sessions =
(std::min)(min_sessions, max_sessions_per_channel * num_channels);

// TODO(#11111): Restore on-by-default behavior.
if (!opts.has<spanner::RouteToLeaderOption>()) {
// TODO(#11111): Restore on-by-default behavior.
opts.set<spanner::RouteToLeaderOption>(false);
if (auto e = internal::GetEnv("GOOGLE_CLOUD_CPP_SPANNER_ROUTE_TO_LEADER")) {
for (auto const* enable : {"Y", "y", "T", "t", "1", "on"}) {
if (*e == enable) {
// Change the default to "for RW/PartitionedDml transactions"
// from "never".
opts.unset<spanner::RouteToLeaderOption>(); // == true
break;
}
opts.set<spanner::RouteToLeaderOption>(false); // off by default
}
// ${GOOGLE_CLOUD_CPP_SPANNER_ROUTE_TO_LEADER} overrides option setting.
if (auto e = internal::GetEnv("GOOGLE_CLOUD_CPP_SPANNER_ROUTE_TO_LEADER")) {
for (auto const* disable : {"N", "n", "F", "f", "0", "off"}) {
if (*e == disable) {
// Never route to leader.
opts.set<spanner::RouteToLeaderOption>(false);
}
}
for (auto const* enable : {"Y", "y", "T", "t", "1", "on"}) {
if (*e == enable) {
// Route to leader for RW/PartitionedDml transactions.
opts.unset<spanner::RouteToLeaderOption>();
}
}
}