mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-15 01:12:56 +00:00
We wish to have high level WAL decoding logic in `wal_decoder::decoder` module. For this we need the `Value` and `NeonWalRecord` types accessible there, so: 1. Move `Value` and `NeonWalRecord` to `pageserver_api::value` and `pageserver_api::record` respectively. I had to add a testing feature to `pageserver_api` to get this working due to `NeonWalRecord` test directives. 2. Get rid of `pageserver::repository` (follow up from (1)) 3. Move PG specific WAL record types to `postgres_ffi::record`. In theory they could live in `wal_decoder`, but it would create a circular dependency between `wal_decoder` and `postgres_ffi`. Long term it makes sennse for those types to be PG version specific, so that will work out nicely. 4. Move higher level WAL record types (to be ingested by pageserver) into `wal_decoder::models`
145 lines
2.7 KiB
Rust
145 lines
2.7 KiB
Rust
//! This module houses types which represent decoded PG WAL records
|
|
//! ready for the pageserver to interpret. They are higher level
|
|
//! than their counterparts in [`postgres_ffi::record`].
|
|
|
|
use bytes::Bytes;
|
|
use pageserver_api::reltag::{RelTag, SlruKind};
|
|
use postgres_ffi::record::{
|
|
XlMultiXactCreate, XlMultiXactTruncate, XlRelmapUpdate, XlReploriginDrop, XlReploriginSet, XlSmgrTruncate, XlXactParsedRecord
|
|
};
|
|
use postgres_ffi::{Oid, TransactionId};
|
|
use utils::lsn::Lsn;
|
|
|
|
pub enum HeapamRecord {
|
|
ClearVmBits(ClearVmBits),
|
|
}
|
|
|
|
pub struct ClearVmBits {
|
|
pub new_heap_blkno: Option<u32>,
|
|
pub old_heap_blkno: Option<u32>,
|
|
pub vm_rel: RelTag,
|
|
pub flags: u8,
|
|
}
|
|
|
|
pub enum NeonrmgrRecord {
|
|
ClearVmBits(ClearVmBits),
|
|
}
|
|
|
|
pub enum SmgrRecord {
|
|
Create(SmgrCreate),
|
|
Truncate(XlSmgrTruncate),
|
|
}
|
|
|
|
pub struct SmgrCreate {
|
|
pub rel: RelTag,
|
|
}
|
|
|
|
pub enum DbaseRecord {
|
|
Create(DbaseCreate),
|
|
Drop(DbaseDrop),
|
|
}
|
|
|
|
pub struct DbaseCreate {
|
|
pub db_id: Oid,
|
|
pub tablespace_id: Oid,
|
|
pub src_db_id: Oid,
|
|
pub src_tablespace_id: Oid,
|
|
}
|
|
|
|
pub struct DbaseDrop {
|
|
pub db_id: Oid,
|
|
pub tablespace_ids: Vec<Oid>,
|
|
}
|
|
|
|
pub enum ClogRecord {
|
|
ZeroPage(ClogZeroPage),
|
|
Truncate(ClogTruncate),
|
|
}
|
|
|
|
pub struct ClogZeroPage {
|
|
pub segno: u32,
|
|
pub rpageno: u32,
|
|
}
|
|
|
|
pub struct ClogTruncate {
|
|
pub pageno: u32,
|
|
pub oldest_xid: TransactionId,
|
|
pub oldest_xid_db: Oid,
|
|
}
|
|
|
|
pub enum XactRecord {
|
|
Commit(XactCommon),
|
|
Abort(XactCommon),
|
|
CommitPrepared(XactCommon),
|
|
AbortPrepared(XactCommon),
|
|
Prepare(XactPrepare),
|
|
}
|
|
|
|
pub struct XactCommon {
|
|
pub parsed: XlXactParsedRecord,
|
|
pub origin_id: u16,
|
|
// Fields below are only used for logging
|
|
pub xl_xid: TransactionId,
|
|
pub lsn: Lsn,
|
|
}
|
|
|
|
pub struct XactPrepare {
|
|
pub xl_xid: TransactionId,
|
|
pub data: Bytes,
|
|
}
|
|
|
|
pub enum MultiXactRecord {
|
|
ZeroPage(MultiXactZeroPage),
|
|
Create(XlMultiXactCreate),
|
|
Truncate(XlMultiXactTruncate),
|
|
}
|
|
|
|
pub struct MultiXactZeroPage {
|
|
pub slru_kind: SlruKind,
|
|
pub segno: u32,
|
|
pub rpageno: u32,
|
|
}
|
|
|
|
pub enum RelmapRecord {
|
|
Update(RelmapUpdate),
|
|
}
|
|
|
|
pub struct RelmapUpdate {
|
|
pub update: XlRelmapUpdate,
|
|
pub buf: Bytes,
|
|
}
|
|
|
|
pub enum XlogRecord {
|
|
Raw(RawXlogRecord),
|
|
}
|
|
|
|
pub struct RawXlogRecord {
|
|
pub info: u8,
|
|
pub lsn: Lsn,
|
|
pub buf: Bytes,
|
|
}
|
|
|
|
pub enum LogicalMessageRecord {
|
|
Put(PutLogicalMessage),
|
|
#[cfg(feature = "testing")]
|
|
Failpoint,
|
|
}
|
|
|
|
pub struct PutLogicalMessage {
|
|
pub path: String,
|
|
pub buf: Bytes,
|
|
}
|
|
|
|
pub enum StandbyRecord {
|
|
RunningXacts(StandbyRunningXacts),
|
|
}
|
|
|
|
pub struct StandbyRunningXacts {
|
|
pub oldest_running_xid: TransactionId,
|
|
}
|
|
|
|
pub enum ReploriginRecord {
|
|
Set(XlReploriginSet),
|
|
Drop(XlReploriginDrop),
|
|
}
|