mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-30 19:40:39 +00:00
wal_service: fix NodeId order/endian issues
Add fixes suggested in code review. In a previous commit, I changed the NodeId field order and types to try to preserve the exact serialization that was happening. Unfortunately, that serialization was incorrect and the original struct was mostly correct. Change uuid to be a [u8; 16] as it was intended to be a byte array; that will clearly indicate to serde serializers that no endian swaps will ever be needed.
This commit is contained in:
@@ -80,8 +80,8 @@ fn read_into(r: &mut impl Read, buf: &mut BytesMut) -> io::Result<usize> {
|
||||
/// Unique node identifier used by Paxos
|
||||
#[derive(Debug, Clone, Copy, Ord, PartialOrd, PartialEq, Eq, Serialize, Deserialize)]
|
||||
struct NodeId {
|
||||
uuid: u128,
|
||||
term: [u8; 8],
|
||||
term: u64,
|
||||
uuid: [u8; 16],
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
|
||||
@@ -227,8 +227,8 @@ impl SafeKeeperInfo {
|
||||
protocol_version: SK_PROTOCOL_VERSION, /* proxy-safekeeper protocol version */
|
||||
pg_version: UNKNOWN_SERVER_VERSION, /* Postgres server version */
|
||||
node_id: NodeId {
|
||||
term: [0; 8],
|
||||
uuid: 0,
|
||||
term: 0,
|
||||
uuid: [0; 16],
|
||||
},
|
||||
system_id: 0, /* Postgres system identifier */
|
||||
timeline_id: ZTimelineId::from([0u8; 16]),
|
||||
@@ -555,8 +555,8 @@ impl Connection {
|
||||
self.send()?;
|
||||
bail!(
|
||||
"Reject connection attempt with term {} because my term is {}",
|
||||
hex::encode(prop.node_id.term),
|
||||
hex::encode(my_info.server.node_id.term)
|
||||
prop.node_id.term,
|
||||
my_info.server.node_id.term,
|
||||
);
|
||||
}
|
||||
my_info.server.node_id = prop.node_id;
|
||||
|
||||
Reference in New Issue
Block a user