mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raftpb: atomic access alignment
The Entry struct has misaligned fields that are accessed atomically. The misalignment is caused by the EntryType enum which the Protocol Buffers spec forces to be a 32bit int. Moving the order of the fields without renumbering them in the .proto file seems to align the go structure without changing the wire format.
This commit is contained in:
parent
dc5d5c6ac8
commit
198ccb8b7b
@ -183,9 +183,9 @@ func (x *ConfChangeType) UnmarshalJSON(data []byte) error {
|
||||
func (ConfChangeType) EnumDescriptor() ([]byte, []int) { return fileDescriptorRaft, []int{2} }
|
||||
|
||||
type Entry struct {
|
||||
Type EntryType `protobuf:"varint,1,opt,name=Type,json=type,enum=raftpb.EntryType" json:"Type"`
|
||||
Term uint64 `protobuf:"varint,2,opt,name=Term,json=term" json:"Term"`
|
||||
Index uint64 `protobuf:"varint,3,opt,name=Index,json=index" json:"Index"`
|
||||
Type EntryType `protobuf:"varint,1,opt,name=Type,json=type,enum=raftpb.EntryType" json:"Type"`
|
||||
Data []byte `protobuf:"bytes,4,opt,name=Data,json=data" json:"Data,omitempty"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
}
|
||||
|
@ -15,9 +15,9 @@ enum EntryType {
|
||||
}
|
||||
|
||||
message Entry {
|
||||
optional uint64 Term = 2 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
|
||||
optional uint64 Index = 3 [(gogoproto.nullable) = false]; // must be 64-bit aligned for atomic operations
|
||||
optional EntryType Type = 1 [(gogoproto.nullable) = false];
|
||||
optional uint64 Term = 2 [(gogoproto.nullable) = false];
|
||||
optional uint64 Index = 3 [(gogoproto.nullable) = false];
|
||||
optional bytes Data = 4;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user