-
Notifications
You must be signed in to change notification settings - Fork 66
checkpoint: fix empty map become nil after unmarshall #237
Conversation
log.L().Error("checkpoint file is broken", zap.String("path", path), zap.Error(err2)) | ||
} | ||
// FIXME: patch for empty map may need initialize manually, because currently | ||
// FIXME: a map of zero size -> marshall -> unmarshall -> become nil, see checkpoint_test.go |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why using FIXME for these comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an unexpected behaviour of gogo/protobuf
's marshall and unmarshall. There's logic to recover a empty map(but didn't execute) in
tidb-lightning/lightning/checkpoints/file_checkpoints.pb.go
Lines 877 to 878 in d49fec6
if m.Engines == nil { | |
m.Engines = make(map[int32]*EngineCheckpointModel) |
If gogo/protobuf
fixed this bug, we won't bother to initiate. So I added a FIXME to remind to report bug and check if fixed from gogo/protobuf
.
Rest LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM
/run-all-tests |
LGTM |
* checkpoint: fix empty map become nil after unmarshall * checkpoint: unify code style * checkpoint: remove hard-coded path
What problem does this PR solve?
fix empty map become nil after marshall and unmarshall
What is changed and how it works?
manually init these map. Seems it's a bug of marshall function provided by gogoproto.
Check List
Tests
Side effects
Related changes