Rename page_cache.rs to tenant_mgr.rs.

Once upon a time, 'page_cache.rs' contained an actual page cache, but
it hasn't for a very long time. Rename to reflect what it actually does
these days.
This commit is contained in:
Heikki Linnakangas
2021-08-30 15:17:30 +03:00
parent a3f3d46016
commit b949127b06
11 changed files with 36 additions and 38 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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<Vec<String>> {
}
pub(crate) fn get_branches(conf: &PageServerConf, tenantid: &ZTenantId) -> Result<Vec<BranchInfo>> {
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<BranchInfo> {
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);

View File

@@ -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<Body>) -> Result<Response<Bo
let request_data: TenantCreateRequest = json_request(&mut request).await?;
let response_data = tokio::task::spawn_blocking(move || {
page_cache::create_repository_for_tenant(get_config(&request), request_data.tenant_id)
tenant_mgr::create_repository_for_tenant(get_config(&request), request_data.tenant_id)
})
.await
.map_err(ApiError::from_err)??;

View File

@@ -466,8 +466,8 @@ pub struct LayeredTimeline {
//
// last_record_lsn points to the end of last processed WAL record.
// It can lag behind last_valid_lsn, if the WAL receiver has
// received some WAL after the end of last record, but not the
// whole next record yet. In the page cache, we care about
// received some WAL after the end of last record, but not the whole
// next record yet. For get_page_at_lsn requests, we care about
// last_valid_lsn, but if the WAL receiver needs to restart the
// streaming, it needs to restart at the end of last record, so we
// track them separately. last_record_lsn should perhaps be in
@@ -790,7 +790,7 @@ impl Timeline for LayeredTimeline {
.observe_closure_duration(|| self.checkpoint_internal(true))
}
/// Remember that WAL has been received and added to the page cache up to the given LSN
/// Remember that WAL has been received and added to the timeline up to the given LSN
fn advance_last_valid_lsn(&self, lsn: Lsn) {
let old = self.last_valid_lsn.advance(lsn);
@@ -824,7 +824,7 @@ impl Timeline for LayeredTimeline {
}
///
/// Remember the (end of) last valid WAL record remembered in the page cache.
/// Remember the (end of) last valid WAL record remembered in the timeline.
///
/// NOTE: this updates last_valid_lsn as well.
///

View File

@@ -12,11 +12,11 @@ pub mod branches;
pub mod http;
pub mod layered_repository;
pub mod logger;
pub mod page_cache;
pub mod page_service;
pub mod relish;
pub mod repository;
pub mod restore_local_repo;
pub mod tenant_mgr;
pub mod waldecoder;
pub mod walreceiver;
pub mod walredo;

View File

@@ -34,8 +34,8 @@ use zenith_utils::zid::{ZTenantId, ZTimelineId};
use crate::basebackup;
use crate::branches;
use crate::page_cache;
use crate::relish::*;
use crate::tenant_mgr;
use crate::walreceiver;
use crate::PageServerConf;
@@ -229,7 +229,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))?;
@@ -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)?;

View File

@@ -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::*;

View File

@@ -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.