Skip to content

Commit 5525abd

Browse files
authored
Merge pull request #10087 from neondatabase/vlad/cherry-pick-multixact-truncation-fix
storage: cherry-pick SLRU, metrics and sharded ingest fixes into the release branch
2 parents 2455dca + c4ce4ac commit 5525abd

File tree

8 files changed

+220
-72
lines changed

8 files changed

+220
-72
lines changed

libs/pageserver_api/src/key.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Key {
2424

2525
/// When working with large numbers of Keys in-memory, it is more efficient to handle them as i128 than as
2626
/// a struct of fields.
27-
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize)]
27+
#[derive(Clone, Copy, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize, Deserialize, Debug)]
2828
pub struct CompactKey(i128);
2929

3030
/// The storage key size.

libs/wal_decoder/proto/interpreted_wal.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ message ValueMeta {
3737
}
3838

3939
message CompactKey {
40-
int64 high = 1;
41-
int64 low = 2;
40+
uint64 high = 1;
41+
uint64 low = 2;
4242
}
4343

libs/wal_decoder/src/wire_format.rs

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ impl From<ValueMeta> for proto::ValueMeta {
236236
impl From<CompactKey> for proto::CompactKey {
237237
fn from(value: CompactKey) -> Self {
238238
proto::CompactKey {
239-
high: (value.raw() >> 64) as i64,
240-
low: value.raw() as i64,
239+
high: (value.raw() >> 64) as u64,
240+
low: value.raw() as u64,
241241
}
242242
}
243243
}
@@ -354,3 +354,64 @@ impl From<proto::CompactKey> for CompactKey {
354354
(((value.high as i128) << 64) | (value.low as i128)).into()
355355
}
356356
}
357+
358+
#[test]
359+
fn test_compact_key_with_large_relnode() {
360+
use pageserver_api::key::Key;
361+
362+
let inputs = vec![
363+
Key {
364+
field1: 0,
365+
field2: 0x100,
366+
field3: 0x200,
367+
field4: 0,
368+
field5: 0x10,
369+
field6: 0x5,
370+
},
371+
Key {
372+
field1: 0,
373+
field2: 0x100,
374+
field3: 0x200,
375+
field4: 0x007FFFFF,
376+
field5: 0x10,
377+
field6: 0x5,
378+
},
379+
Key {
380+
field1: 0,
381+
field2: 0x100,
382+
field3: 0x200,
383+
field4: 0x00800000,
384+
field5: 0x10,
385+
field6: 0x5,
386+
},
387+
Key {
388+
field1: 0,
389+
field2: 0x100,
390+
field3: 0x200,
391+
field4: 0x00800001,
392+
field5: 0x10,
393+
field6: 0x5,
394+
},
395+
Key {
396+
field1: 0,
397+
field2: 0xFFFFFFFF,
398+
field3: 0xFFFFFFFF,
399+
field4: 0xFFFFFFFF,
400+
field5: 0x0,
401+
field6: 0x0,
402+
},
403+
];
404+
405+
for input in inputs {
406+
assert!(input.is_valid_key_on_write_path());
407+
let compact = input.to_compact();
408+
let proto: proto::CompactKey = compact.into();
409+
let from_proto: CompactKey = proto.into();
410+
411+
assert_eq!(
412+
compact, from_proto,
413+
"Round trip failed for key with relnode={:#x}",
414+
input.field4
415+
);
416+
}
417+
}

0 commit comments

Comments
 (0)