Commit c75015a
committed
vtctld: guard ev.ShardInfo before overwriting response keyspace/shard in reparent RPCs
PlannedReparentShard and EmergencyReparentShard both initialize the
response with req.Keyspace/req.Shard, then overwrite from ev.ShardInfo
inside an `if ev != nil` block. ev itself is always non-nil (allocated
before the reparent call), but ev.ShardInfo is zero-valued whenever
reparentShardLocked returns before populating it — for example when no
valid reparent target exists in the same cell as the current primary.
Calling .Keyspace() / .ShardName() on a zero-valued topo.ShardInfo
dereferences an internal nil pointer, crashing vtctld.
Fix: check whether ev.ShardInfo.Keyspace() is non-empty before
overwriting the response fields. When it is empty the response already
holds the correct values from the req initialization, so the fallback
is safe.
Signed-off-by: Lucas Morduchowicz <lmorduch@gmail.com>1 parent cff3492 commit c75015a
2 files changed
Lines changed: 57 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1332 | 1332 | | |
1333 | 1333 | | |
1334 | 1334 | | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
1335 | 1338 | | |
1336 | | - | |
1337 | | - | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
1338 | 1343 | | |
1339 | 1344 | | |
1340 | 1345 | | |
| |||
3333 | 3338 | | |
3334 | 3339 | | |
3335 | 3340 | | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
3336 | 3344 | | |
3337 | | - | |
3338 | | - | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
3339 | 3349 | | |
3340 | 3350 | | |
3341 | 3351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9011 | 9011 | | |
9012 | 9012 | | |
9013 | 9013 | | |
| 9014 | + | |
| 9015 | + | |
| 9016 | + | |
| 9017 | + | |
| 9018 | + | |
| 9019 | + | |
| 9020 | + | |
| 9021 | + | |
| 9022 | + | |
| 9023 | + | |
| 9024 | + | |
| 9025 | + | |
| 9026 | + | |
| 9027 | + | |
| 9028 | + | |
| 9029 | + | |
| 9030 | + | |
| 9031 | + | |
| 9032 | + | |
| 9033 | + | |
| 9034 | + | |
| 9035 | + | |
| 9036 | + | |
| 9037 | + | |
| 9038 | + | |
| 9039 | + | |
| 9040 | + | |
| 9041 | + | |
| 9042 | + | |
| 9043 | + | |
| 9044 | + | |
| 9045 | + | |
| 9046 | + | |
| 9047 | + | |
| 9048 | + | |
| 9049 | + | |
| 9050 | + | |
| 9051 | + | |
| 9052 | + | |
| 9053 | + | |
9014 | 9054 | | |
9015 | 9055 | | |
9016 | 9056 | | |
| |||
9041 | 9081 | | |
9042 | 9082 | | |
9043 | 9083 | | |
| 9084 | + | |
| 9085 | + | |
| 9086 | + | |
9044 | 9087 | | |
9045 | 9088 | | |
9046 | 9089 | | |
| |||
0 commit comments