Validate that a PUT request is routed to the correct shard. Returns `Ok(())` when routing is correct or when `prefix_bits == 0` (which means the request predates Hilbert routing and skips validation). Returns `Err(ClusterError::WrongOwner)` when the coordinator used a stale routing table; the coordinator should refresh and retry.
(req: &ArrayShardPutReq, local_vshard_id: u32)
| 177 | /// Returns `Err(ClusterError::WrongOwner)` when the coordinator used a stale |
| 178 | /// routing table; the coordinator should refresh and retry. |
| 179 | fn validate_put_routing(req: &ArrayShardPutReq, local_vshard_id: u32) -> Result<()> { |
| 180 | if req.prefix_bits == 0 { |
| 181 | return Ok(()); |
| 182 | } |
| 183 | let expected = array_vshard_for_tile(req.representative_hilbert_prefix, req.prefix_bits)?; |
| 184 | if expected != local_vshard_id { |
| 185 | return Err(ClusterError::WrongOwner { |
| 186 | vshard_id: local_vshard_id, |
| 187 | expected_owner_node: None, |
| 188 | }); |
| 189 | } |
| 190 | Ok(()) |
| 191 | } |
| 192 | |
| 193 | /// Validate that a SLICE request is routed to the correct shard. |
| 194 | /// |
no test coverage detected