diff --git a/README.md b/README.md index 38379b176b..4cc4c2e032 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Zenith storage engine consists of two major components: - WAL service. The service that receives WAL from compute node and ensures that it is stored durably. Pageserver consists of: -- Page cache repository - Zenith storage implementation. -- WAL receiver - service that recieves WAL from WAL service and stores it in the page cache repository. +- Repository - Zenith storage implementation. +- WAL receiver - service that receives WAL from WAL service and stores it in the repository. - Page service - service that communicates with compute nodes and responds with pages from the repository. - WAL redo - service that builds pages from base images and WAL records on Page service request. diff --git a/docs/glossary.md b/docs/glossary.md index 43c6329ea2..c8c43e46fa 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -62,11 +62,7 @@ This is the unit of data exchange between compute node and pageserver. ### Pageserver -Zenith storage engine: page cache repositories + wal receiver + page service + wal redo. - -### Page cache - -This module acts as a switchboard to access different repositories managed by this pageserver. +Zenith storage engine: repositories + wal receiver + page service + wal redo. ### Page service @@ -133,8 +129,10 @@ See `docs/multitenancy.md` for more. ### Timeline -Timeline is a page cache workhorse that accepts page changes -and serves get_page_at_lsn() and get_rel_size() requests. +Timeline accepts page changes and serves get_page_at_lsn() and +get_rel_size() requests. The term "timeline" is used internally +in the system, but to users they are exposed as "branches", with +human-friendly names. NOTE: this has nothing to do with PostgreSQL WAL timelines. @@ -157,7 +155,7 @@ as the acceptor. Those are the standard terms in the Paxos algorithm. The WAL receiver connects to the external WAL safekeeping service (or directly to the primary) using PostgreSQL physical streaming replication, and continuously receives WAL. It decodes the WAL records, -and stores them to the page cache repository. +and stores them to the repository. We keep one WAL receiver active per timeline. diff --git a/pageserver/src/bin/pageserver.rs b/pageserver/src/bin/pageserver.rs index 45e385f362..f9852a3276 100644 --- a/pageserver/src/bin/pageserver.rs +++ b/pageserver/src/bin/pageserver.rs @@ -19,7 +19,7 @@ use anyhow::{ensure, Result}; use clap::{App, Arg, ArgMatches}; use daemonize::Daemonize; -use pageserver::{branches, http, logger, page_cache, page_service, PageServerConf}; +use pageserver::{branches, http, logger, page_service, tenant_mgr, PageServerConf}; use zenith_utils::http::endpoint; const DEFAULT_LISTEN_ADDR: &str = "127.0.0.1:64000"; @@ -326,8 +326,8 @@ fn start_pageserver(conf: &'static PageServerConf) -> Result<()> { info!("Starting pageserver on {}", conf.listen_addr); let pageserver_listener = TcpListener::bind(conf.listen_addr.clone())?; - // Initialize page cache, this will spawn walredo_thread - page_cache::init(conf); + // Initialize tenant manager. + tenant_mgr::init(conf); // Spawn a thread to listen for connections. It will spawn further threads // for each connection. diff --git a/pageserver/src/branches.rs b/pageserver/src/branches.rs index 5c98fb5a93..1896ee47a6 100644 --- a/pageserver/src/branches.rs +++ b/pageserver/src/branches.rs @@ -20,8 +20,8 @@ use log::*; use zenith_utils::lsn::Lsn; use crate::logger; -use crate::page_cache; use crate::restore_local_repo; +use crate::tenant_mgr; use crate::walredo::WalRedoManager; use crate::{repository::Repository, PageServerConf}; @@ -87,7 +87,7 @@ pub fn create_repo( let tli = create_timeline(conf, None, &tenantid)?; - // We don't use page_cache here, because we don't want to spawn the WAL redo thread during + // We don't use tenant manager, because we don't want to spawn the WAL redo thread during // repository initialization. // // FIXME: That caused trouble, because the WAL redo thread launched initdb in the background, @@ -203,7 +203,7 @@ pub(crate) fn get_tenants(conf: &PageServerConf) -> Result> { } pub(crate) fn get_branches(conf: &PageServerConf, tenantid: &ZTenantId) -> Result> { - let repo = page_cache::get_repository_for_tenant(tenantid)?; + let repo = tenant_mgr::get_repository_for_tenant(tenantid)?; // Each branch has a corresponding record (text file) in the refs/branches // with timeline_id. @@ -259,7 +259,7 @@ pub(crate) fn create_branch( startpoint_str: &str, tenantid: &ZTenantId, ) -> Result { - let repo = page_cache::get_repository_for_tenant(tenantid)?; + let repo = tenant_mgr::get_repository_for_tenant(tenantid)?; if conf.branch_path(branchname, tenantid).exists() { anyhow::bail!("branch {} already exists", branchname); diff --git a/pageserver/src/http/routes.rs b/pageserver/src/http/routes.rs index d4deeb84a3..ea81e1a8a3 100644 --- a/pageserver/src/http/routes.rs +++ b/pageserver/src/http/routes.rs @@ -18,10 +18,9 @@ use zenith_utils::http::{ use super::models::BranchCreateRequest; use super::models::TenantCreateRequest; -use crate::page_cache; use crate::{ branches::{self}, - PageServerConf, ZTenantId, + tenant_mgr, PageServerConf, ZTenantId, }; #[derive(Debug)] @@ -125,7 +124,7 @@ async fn tenant_create_handler(mut request: Request) -> Result anyhow::Result<()> { // Check that the timeline exists - let repository = page_cache::get_repository_for_tenant(&tenantid)?; + let repository = tenant_mgr::get_repository_for_tenant(&tenantid)?; let timeline = repository .get_timeline(timelineid) .context(format!("error fetching timeline {}", timelineid))?; @@ -338,7 +338,7 @@ impl PageServerHandler { tenantid: ZTenantId, ) -> anyhow::Result<()> { // check that the timeline exists - let repository = page_cache::get_repository_for_tenant(&tenantid)?; + let repository = tenant_mgr::get_repository_for_tenant(&tenantid)?; let timeline = repository .get_timeline(timelineid) .context(format!("error fetching timeline {}", timelineid))?; @@ -486,7 +486,7 @@ impl postgres_backend::Handler for PageServerHandler { self.check_permission(Some(tenantid))?; // Check that the timeline exists - let repository = page_cache::get_repository_for_tenant(&tenantid)?; + let repository = tenant_mgr::get_repository_for_tenant(&tenantid)?; repository .get_timeline(timelineid) .context(format!("error fetching timeline {}", timelineid))?; @@ -550,7 +550,7 @@ impl postgres_backend::Handler for PageServerHandler { let tenantid = ZTenantId::from_str(caps.get(1).unwrap().as_str())?; - page_cache::create_repository_for_tenant(&self.conf, tenantid)?; + tenant_mgr::create_repository_for_tenant(&self.conf, tenantid)?; pgb.write_message_noflush(&SINGLE_COL_ROWDESC)? .write_message_noflush(&BeMessage::CommandComplete(b"SELECT 1"))?; @@ -584,7 +584,7 @@ impl postgres_backend::Handler for PageServerHandler { .map(|h| h.as_str().parse()) .unwrap_or(Ok(self.conf.gc_horizon))?; - let repo = page_cache::get_repository_for_tenant(&tenantid)?; + let repo = tenant_mgr::get_repository_for_tenant(&tenantid)?; let result = repo.gc_iteration(Some(timelineid), gc_horizon, true)?; diff --git a/pageserver/src/page_cache.rs b/pageserver/src/tenant_mgr.rs similarity index 100% rename from pageserver/src/page_cache.rs rename to pageserver/src/tenant_mgr.rs diff --git a/pageserver/src/waldecoder.rs b/pageserver/src/waldecoder.rs index 140c361396..bad93e9587 100644 --- a/pageserver/src/waldecoder.rs +++ b/pageserver/src/waldecoder.rs @@ -1,6 +1,6 @@ //! //! WAL decoder. For each WAL record, it decodes the record to figure out which data blocks -//! the record affects, to add the records to the page cache. +//! the record affects, so that they can be stored in repository. //! use bytes::{Buf, BufMut, Bytes, BytesMut}; use crc32c::*; diff --git a/pageserver/src/walreceiver.rs b/pageserver/src/walreceiver.rs index e9008a415e..9936e2569d 100644 --- a/pageserver/src/walreceiver.rs +++ b/pageserver/src/walreceiver.rs @@ -1,12 +1,13 @@ //! -//! WAL receiver connects to the WAL safekeeper service, -//! streams WAL, decodes records and saves them in page cache. +//! WAL receiver connects to the WAL safekeeper service, streams WAL, +//! decodes records and saves them in the repository for the correct +//! timeline. //! //! We keep one WAL receiver active per timeline. -use crate::page_cache; use crate::relish::*; use crate::restore_local_repo; +use crate::tenant_mgr; use crate::waldecoder::*; use crate::PageServerConf; use anyhow::{Error, Result}; @@ -145,7 +146,7 @@ fn walreceiver_main( let end_of_wal = Lsn::from(u64::from(identify.xlogpos)); let mut caught_up = false; - let repository = page_cache::get_repository_for_tenant(tenantid)?; + let repository = tenant_mgr::get_repository_for_tenant(tenantid)?; let timeline = repository.get_timeline(timelineid).unwrap(); // @@ -232,9 +233,9 @@ fn walreceiver_main( } } - // Update the last_valid LSN value in the page cache one more time. We updated + // Update the last_valid LSN value in the timeline one more time. We updated // it in the loop above, between each WAL record, but we might have received - // a partial record after the last completed record. Our page cache's value + // a partial record after the last completed record. Our timeline's value // better reflect that, because GetPage@LSN requests might also point in the // middle of a record, if the request LSN was taken from the server's current // flush ptr.