Skip to content

Commit

Permalink
Merge pull request #10087 from neondatabase/vlad/cherry-pick-multixac…
Browse files Browse the repository at this point in the history
…t-truncation-fix

storage: cherry-pick SLRU, metrics and sharded ingest fixes into the release branch
  • Loading branch information
VladLazar authored Dec 11, 2024
2 parents 2455dca + c4ce4ac commit 5525abd
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 72 deletions.
2 changes: 1 addition & 1 deletion libs/pageserver_api/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Key {

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

/// The storage key size.
Expand Down
4 changes: 2 additions & 2 deletions libs/wal_decoder/proto/interpreted_wal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ message ValueMeta {
}

message CompactKey {
int64 high = 1;
int64 low = 2;
uint64 high = 1;
uint64 low = 2;
}

65 changes: 63 additions & 2 deletions libs/wal_decoder/src/wire_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ impl From<ValueMeta> for proto::ValueMeta {
impl From<CompactKey> for proto::CompactKey {
fn from(value: CompactKey) -> Self {
proto::CompactKey {
high: (value.raw() >> 64) as i64,
low: value.raw() as i64,
high: (value.raw() >> 64) as u64,
low: value.raw() as u64,
}
}
}
Expand Down Expand Up @@ -354,3 +354,64 @@ impl From<proto::CompactKey> for CompactKey {
(((value.high as i128) << 64) | (value.low as i128)).into()
}
}

#[test]
fn test_compact_key_with_large_relnode() {
use pageserver_api::key::Key;

let inputs = vec![
Key {
field1: 0,
field2: 0x100,
field3: 0x200,
field4: 0,
field5: 0x10,
field6: 0x5,
},
Key {
field1: 0,
field2: 0x100,
field3: 0x200,
field4: 0x007FFFFF,
field5: 0x10,
field6: 0x5,
},
Key {
field1: 0,
field2: 0x100,
field3: 0x200,
field4: 0x00800000,
field5: 0x10,
field6: 0x5,
},
Key {
field1: 0,
field2: 0x100,
field3: 0x200,
field4: 0x00800001,
field5: 0x10,
field6: 0x5,
},
Key {
field1: 0,
field2: 0xFFFFFFFF,
field3: 0xFFFFFFFF,
field4: 0xFFFFFFFF,
field5: 0x0,
field6: 0x0,
},
];

for input in inputs {
assert!(input.is_valid_key_on_write_path());
let compact = input.to_compact();
let proto: proto::CompactKey = compact.into();
let from_proto: CompactKey = proto.into();

assert_eq!(
compact, from_proto,
"Round trip failed for key with relnode={:#x}",
input.field4
);
}
}
Loading

1 comment on commit 5525abd

@github-actions
Copy link

@github-actions github-actions bot commented on 5525abd Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6410 tests run: 6124 passed, 0 failed, 286 skipped (full report)


Flaky tests (3)

Postgres 16

Postgres 15

Postgres 14

Test coverage report is not available

The comment gets automatically updated with the latest test results
5525abd at 2024-12-13T00:11:31.255Z :recycle:

Please sign in to comment.