Skip to content

Commit

Permalink
Initialize list correctly! Add additional validation to prevent panic…
Browse files Browse the repository at this point in the history
…s due to bugs

Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed Feb 7, 2025
1 parent 10a6916 commit 5d936af
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions go/vt/vttablet/tabletmanager/vreplication/replicator_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ func (tp *TablePlan) appendFromRow(buf *bytes2.Buffer, row *querypb.Row) error {
return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "wrong number of fields: got %d fields for %d bind locations",
len(tp.Fields), len(bindLocations))
}
if len(row.Lengths) < len(tp.Fields) {
return vterrors.Errorf(vtrpcpb.Code_INTERNAL, "wrong number of lengths: got %d lengths for %d fields",
len(row.Lengths), len(tp.Fields))
}

// Bind field values to locations.
var (
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vttablet/tabletmanager/vreplication/vcopier_atomic.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ func (vc *vcopier) copyAll(ctx context.Context, settings binlogplayer.VRSettings
lastpk = nil
// pkfields are only used for logging, so that we can monitor progress.
pkfields = make([]*querypb.Field, len(resp.Pkfields))
for _, f := range resp.Pkfields {
pkfields = append(pkfields, f.CloneVT())
for i, f := range resp.Pkfields {
pkfields[i] = f.CloneVT()
}

fieldEvent := &binlogdatapb.FieldEvent{
Expand Down

0 comments on commit 5d936af

Please sign in to comment.