mirror of
https://github.com/neondatabase/neon.git
synced 2026-05-20 06:30:43 +00:00
move more stuff around
This commit is contained in:
@@ -24,7 +24,6 @@ use bytes::{Bytes, BytesMut};
|
|||||||
|
|
||||||
use pageserver_api::models::WalRedoManagerStatus;
|
use pageserver_api::models::WalRedoManagerStatus;
|
||||||
use pageserver_api::shard::TenantShardId;
|
use pageserver_api::shard::TenantShardId;
|
||||||
use serde::Serialize;
|
|
||||||
|
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@@ -44,7 +43,7 @@ use crate::repository::Key;
|
|||||||
use crate::walrecord::NeonWalRecord;
|
use crate::walrecord::NeonWalRecord;
|
||||||
|
|
||||||
use pageserver_api::key::{key_to_rel_block, key_to_slru_block};
|
use pageserver_api::key::{key_to_rel_block, key_to_slru_block};
|
||||||
use pageserver_api::reltag::{RelTag, SlruKind};
|
use pageserver_api::reltag::SlruKind;
|
||||||
use postgres_ffi::pg_constants;
|
use postgres_ffi::pg_constants;
|
||||||
use postgres_ffi::relfile_utils::VISIBILITYMAP_FORKNUM;
|
use postgres_ffi::relfile_utils::VISIBILITYMAP_FORKNUM;
|
||||||
use postgres_ffi::v14::nonrelfile_utils::{
|
use postgres_ffi::v14::nonrelfile_utils::{
|
||||||
@@ -54,20 +53,9 @@ use postgres_ffi::v14::nonrelfile_utils::{
|
|||||||
use postgres_ffi::BLCKSZ;
|
use postgres_ffi::BLCKSZ;
|
||||||
|
|
||||||
mod process;
|
mod process;
|
||||||
|
mod protocol;
|
||||||
use process::WalRedoProcess;
|
use process::WalRedoProcess;
|
||||||
|
|
||||||
///
|
|
||||||
/// `RelTag` + block number (`blknum`) gives us a unique id of the page in the cluster.
|
|
||||||
///
|
|
||||||
/// In Postgres `BufferTag` structure is used for exactly the same purpose.
|
|
||||||
/// [See more related comments here](https://github.com/postgres/postgres/blob/99c5852e20a0987eca1c38ba0c09329d4076b6a0/src/include/storage/buf_internals.h#L91).
|
|
||||||
///
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Serialize)]
|
|
||||||
pub(crate) struct BufferTag {
|
|
||||||
pub rel: RelTag,
|
|
||||||
pub blknum: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// This is the real implementation that uses a Postgres process to
|
/// This is the real implementation that uses a Postgres process to
|
||||||
/// perform WAL replay. Only one thread can use the process at a time,
|
/// perform WAL replay. Only one thread can use the process at a time,
|
||||||
@@ -272,7 +260,7 @@ impl PostgresRedoManager {
|
|||||||
let started_at = std::time::Instant::now();
|
let started_at = std::time::Instant::now();
|
||||||
|
|
||||||
// Relational WAL records are applied using wal-redo-postgres
|
// Relational WAL records are applied using wal-redo-postgres
|
||||||
let buf_tag = BufferTag { rel, blknum };
|
let buf_tag = protocol::BufferTag { rel, blknum };
|
||||||
let result = proc
|
let result = proc
|
||||||
.apply_wal_records(buf_tag, &base_img, records, wal_redo_timeout)
|
.apply_wal_records(buf_tag, &base_img, records, wal_redo_timeout)
|
||||||
.context("apply_wal_records");
|
.context("apply_wal_records");
|
||||||
|
|||||||
@@ -23,12 +23,11 @@ use self::no_leak_child::NoLeakChild;
|
|||||||
|
|
||||||
use utils::{lsn::Lsn, nonblock::set_nonblock};
|
use utils::{lsn::Lsn, nonblock::set_nonblock};
|
||||||
|
|
||||||
use super::BufferTag;
|
|
||||||
|
|
||||||
use std::os::fd::AsRawFd;
|
use std::os::fd::AsRawFd;
|
||||||
|
|
||||||
|
use super::protocol;
|
||||||
|
|
||||||
mod no_leak_child;
|
mod no_leak_child;
|
||||||
mod protocol;
|
|
||||||
|
|
||||||
pub struct WalRedoProcess {
|
pub struct WalRedoProcess {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@@ -184,7 +183,7 @@ impl WalRedoProcess {
|
|||||||
#[instrument(skip_all, fields(tenant_id=%self.tenant_shard_id.tenant_id, shard_id=%self.tenant_shard_id.shard_slug(), pid=%self.id()))]
|
#[instrument(skip_all, fields(tenant_id=%self.tenant_shard_id.tenant_id, shard_id=%self.tenant_shard_id.shard_slug(), pid=%self.id()))]
|
||||||
pub(crate) fn apply_wal_records(
|
pub(crate) fn apply_wal_records(
|
||||||
&self,
|
&self,
|
||||||
tag: BufferTag,
|
tag: protocol::BufferTag,
|
||||||
base_img: &Option<Bytes>,
|
base_img: &Option<Bytes>,
|
||||||
records: &[(Lsn, NeonWalRecord)],
|
records: &[(Lsn, NeonWalRecord)],
|
||||||
wal_redo_timeout: Duration,
|
wal_redo_timeout: Duration,
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
use bytes::BufMut;
|
use bytes::BufMut;
|
||||||
|
use pageserver_api::reltag::RelTag;
|
||||||
|
use serde::Serialize;
|
||||||
|
use utils::bin_ser::BeSer;
|
||||||
use utils::lsn::Lsn;
|
use utils::lsn::Lsn;
|
||||||
|
|
||||||
use super::BufferTag;
|
///
|
||||||
use utils::bin_ser::BeSer;
|
/// `RelTag` + block number (`blknum`) gives us a unique id of the page in the cluster.
|
||||||
|
///
|
||||||
|
/// In Postgres `BufferTag` structure is used for exactly the same purpose.
|
||||||
|
/// [See more related comments here](https://github.com/postgres/postgres/blob/99c5852e20a0987eca1c38ba0c09329d4076b6a0/src/include/storage/buf_internals.h#L91).
|
||||||
|
///
|
||||||
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Serialize)]
|
||||||
|
pub(crate) struct BufferTag {
|
||||||
|
pub rel: RelTag,
|
||||||
|
pub blknum: u32,
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn build_begin_redo_for_block_msg(tag: BufferTag, buf: &mut Vec<u8>) {
|
pub(crate) fn build_begin_redo_for_block_msg(tag: BufferTag, buf: &mut Vec<u8>) {
|
||||||
let len = 4 + 1 + 4 * 4;
|
let len = 4 + 1 + 4 * 4;
|
||||||
Reference in New Issue
Block a user