Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wal_decoder: add rate limited log for unexpected rm ids #9592

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/postgres_ffi/src/pg_constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
1 change: 1 addition & 0 deletions libs/wal_decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion libs/wal_decoder/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Loading