Dont change shard unless you know (#195)

This commit is contained in:
Lev Kokotov
2022-10-26 00:14:08 -07:00
committed by GitHub
parent 0524787d31
commit 9fe8d5e76f

View File

@@ -335,12 +335,18 @@ impl QueryRouter {
// or discard shard selection. If they point to the same shard though, // or discard shard selection. If they point to the same shard though,
// we can let them through as-is. // we can let them through as-is.
// This is basically building a database now :) // This is basically building a database now :)
self.active_shard = self.infer_shard(query); match self.infer_shard(query) {
Some(shard) => {
self.active_shard = Some(shard);
debug!("Automatically using shard: {:?}", self.active_shard); debug!("Automatically using shard: {:?}", self.active_shard);
} }
None => (), None => (),
}; };
}
None => (),
};
self.active_role = match self.primary_reads_enabled() { self.active_role = match self.primary_reads_enabled() {
false => Some(Role::Replica), // If primary should not be receiving reads, use a replica. false => Some(Role::Replica), // If primary should not be receiving reads, use a replica.