mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-16 09:52:54 +00:00
- All timelines are now stored in the same rocksdb repository. The GET functions have been taught to follow the ancestors. - Change the way relation size is stored. Instead of inserting "tombstone" entries for blocks that are truncated away, store relation size as separate key-value entry for each relation - Add an abstraction for the key-value store: ObjectStore. It allows swapping RocksDB with some other key-value store easily. Perhaps we will write our own storage implementation using that interface, or perhaps we'll need a different abstraction, but this is a small improvement over status quo in any case. - Garbage Collection is broken and commented out. It's not clear where and how it should be implemented.
36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
//! This module acts as a switchboard to access different repositories managed by this
|
|
//! page server. Currently, a Page Server can only manage one repository, so there
|
|
//! isn't much here. If we implement multi-tenancy, this will probably be changed into
|
|
//! a hash map, keyed by the tenant ID.
|
|
|
|
use crate::object_repository::ObjectRepository;
|
|
use crate::repository::Repository;
|
|
use crate::rocksdb_storage::RocksObjectStore;
|
|
use crate::walredo::PostgresRedoManager;
|
|
use crate::PageServerConf;
|
|
use lazy_static::lazy_static;
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
lazy_static! {
|
|
pub static ref REPOSITORY: Mutex<Option<Arc<dyn Repository>>> = Mutex::new(None);
|
|
}
|
|
|
|
pub fn init(conf: &'static PageServerConf) {
|
|
let mut m = REPOSITORY.lock().unwrap();
|
|
|
|
let obj_store = RocksObjectStore::open(conf).unwrap();
|
|
|
|
// Set up a WAL redo manager, for applying WAL records.
|
|
let walredo_mgr = PostgresRedoManager::new(conf);
|
|
|
|
// we have already changed current dir to the repository.
|
|
let repo = ObjectRepository::new(conf, Arc::new(obj_store), Arc::new(walredo_mgr));
|
|
|
|
*m = Some(Arc::new(repo));
|
|
}
|
|
|
|
pub fn get_repository() -> Arc<dyn Repository> {
|
|
let o = &REPOSITORY.lock().unwrap();
|
|
Arc::clone(o.as_ref().unwrap())
|
|
}
|