Compare commits

...

3 Commits

Author SHA1 Message Date
Vlad Lazar
fd5aa06e28 wal_decoder: add a comment to clarify the intention 2024-10-31 18:14:33 +01:00
Vlad Lazar
1cdebae470 wal_decoder: no-op on RM_BTREE_ID 2024-10-31 18:01:09 +01:00
Vlad Lazar
dc7004ec10 wal_decoder: add rate limited log for unexpecte rm ids
Problem

We would like to handle the tightening of unexpected WAL record
types, but don't know if this happens in the field.

Summary of Changes

Add a rate-limited WAL log on such events. The rate limiting is to
play it safe and guard against spewing in prod.
2024-10-31 13:49:48 +01:00
4 changed files with 24 additions and 1 deletions

1
Cargo.lock generated
View File

@@ -6962,6 +6962,7 @@ version = "0.1.0"
dependencies = [
"anyhow",
"bytes",
"once_cell",
"pageserver_api",
"postgres_ffi",
"serde",

View File

@@ -170,6 +170,7 @@ pub const RM_RELMAP_ID: u8 = 7;
pub const RM_STANDBY_ID: u8 = 8;
pub const RM_HEAP2_ID: u8 = 9;
pub const RM_HEAP_ID: u8 = 10;
pub const RM_BTREE_ID: u8 = 11;
pub const RM_REPLORIGIN_ID: u8 = 19;
pub const RM_LOGICALMSG_ID: u8 = 21;

View File

@@ -10,6 +10,7 @@ testing = []
[dependencies]
anyhow.workspace = true
bytes.workspace = true
once_cell.workspace = true
pageserver_api.workspace = true
postgres_ffi.workspace = true
serde.workspace = true

View File

@@ -169,9 +169,29 @@ impl MetadataRecord {
}
pg_constants::RM_STANDBY_ID => Self::decode_standby_record(&mut buf, decoded),
pg_constants::RM_REPLORIGIN_ID => Self::decode_replorigin_record(&mut buf, decoded),
_unexpected => {
pg_constants::RM_BTREE_ID => {
// No special handling required for these record types.
// We just ingest the blocks that come with it.
Ok(None)
}
unexpected => {
// TODO: consider failing here instead of blindly doing something without
// understanding the protocol
use once_cell::sync::Lazy;
use std::sync::Mutex;
use std::time::Duration;
use utils::rate_limit::RateLimit;
static LOGGED: Lazy<Mutex<RateLimit>> =
Lazy::new(|| Mutex::new(RateLimit::new(Duration::from_secs(10))));
let mut rate_limit = LOGGED.try_lock().unwrap();
rate_limit.call(|| {
tracing::warn!(
"Unexpected resource manager id in PG WAL record at LSN {}: {}",
lsn,
unexpected
);
});
Ok(None)
}
}