add rocksdb secondary; fix read_only mode.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
6b80361c31
commit
96fcf7f94d
5 changed files with 27 additions and 2 deletions
|
@ -236,6 +236,8 @@ pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rocksdb_read_only: bool,
|
pub rocksdb_read_only: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
|
pub rocksdb_secondary: bool,
|
||||||
|
#[serde(default)]
|
||||||
pub rocksdb_compaction_prio_idle: bool,
|
pub rocksdb_compaction_prio_idle: bool,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
pub rocksdb_compaction_ioprio_idle: bool,
|
pub rocksdb_compaction_ioprio_idle: bool,
|
||||||
|
@ -752,6 +754,7 @@ impl fmt::Display for Config {
|
||||||
line("RocksDB Recovery Mode", &self.rocksdb_recovery_mode.to_string());
|
line("RocksDB Recovery Mode", &self.rocksdb_recovery_mode.to_string());
|
||||||
line("RocksDB Repair Mode", &self.rocksdb_repair.to_string());
|
line("RocksDB Repair Mode", &self.rocksdb_repair.to_string());
|
||||||
line("RocksDB Read-only Mode", &self.rocksdb_read_only.to_string());
|
line("RocksDB Read-only Mode", &self.rocksdb_read_only.to_string());
|
||||||
|
line("RocksDB Secondary Mode", &self.rocksdb_secondary.to_string());
|
||||||
line(
|
line(
|
||||||
"RocksDB Compaction Idle Priority",
|
"RocksDB Compaction Idle Priority",
|
||||||
&self.rocksdb_compaction_prio_idle.to_string(),
|
&self.rocksdb_compaction_prio_idle.to_string(),
|
||||||
|
|
|
@ -38,6 +38,14 @@ impl Database {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter_maps(&self) -> impl Iterator<Item = (&MapsKey, &MapsVal)> + Send + '_ { self.map.iter() }
|
pub fn iter_maps(&self) -> impl Iterator<Item = (&MapsKey, &MapsVal)> + Send + '_ { self.map.iter() }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
|
pub fn is_read_only(&self) -> bool { self.db.secondary || self.db.read_only }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
#[must_use]
|
||||||
|
pub fn is_secondary(&self) -> bool { self.db.secondary }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Index<&str> for Database {
|
impl Index<&str> for Database {
|
||||||
|
|
|
@ -28,6 +28,8 @@ pub struct Engine {
|
||||||
cfs: Mutex<BTreeSet<String>>,
|
cfs: Mutex<BTreeSet<String>>,
|
||||||
pub(crate) db: Db,
|
pub(crate) db: Db,
|
||||||
corks: AtomicU32,
|
corks: AtomicU32,
|
||||||
|
pub(super) read_only: bool,
|
||||||
|
pub(super) secondary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) type Db = DBWithThreadMode<MultiThreaded>;
|
pub(crate) type Db = DBWithThreadMode<MultiThreaded>;
|
||||||
|
@ -80,10 +82,13 @@ impl Engine {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
debug!("Opening database...");
|
debug!("Opening database...");
|
||||||
|
let path = &config.database_path;
|
||||||
let res = if config.rocksdb_read_only {
|
let res = if config.rocksdb_read_only {
|
||||||
Db::open_cf_for_read_only(&db_opts, &config.database_path, cfs.clone(), false)
|
Db::open_cf_descriptors_read_only(&db_opts, path, cfds, false)
|
||||||
|
} else if config.rocksdb_secondary {
|
||||||
|
Db::open_cf_descriptors_as_secondary(&db_opts, path, path, cfds)
|
||||||
} else {
|
} else {
|
||||||
Db::open_cf_descriptors(&db_opts, &config.database_path, cfds)
|
Db::open_cf_descriptors(&db_opts, path, cfds)
|
||||||
};
|
};
|
||||||
|
|
||||||
let db = res.or_else(or_else)?;
|
let db = res.or_else(or_else)?;
|
||||||
|
@ -103,6 +108,8 @@ impl Engine {
|
||||||
cfs: Mutex::new(cfs),
|
cfs: Mutex::new(cfs),
|
||||||
db,
|
db,
|
||||||
corks: AtomicU32::new(0),
|
corks: AtomicU32::new(0),
|
||||||
|
read_only: config.rocksdb_read_only,
|
||||||
|
secondary: config.rocksdb_secondary,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,10 @@ impl crate::Service for Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn worker(self: Arc<Self>) -> Result<()> {
|
async fn worker(self: Arc<Self>) -> Result<()> {
|
||||||
|
if self.services.globals.is_read_only() {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
|
||||||
self.set_emergency_access()
|
self.set_emergency_access()
|
||||||
.await
|
.await
|
||||||
.inspect_err(|e| error!("Could not set the configured emergency password for the conduit user: {e}"))?;
|
.inspect_err(|e| error!("Could not set the configured emergency password for the conduit user: {e}"))?;
|
||||||
|
|
|
@ -329,4 +329,7 @@ impl Service {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn server_is_ours(&self, server_name: &ServerName) -> bool { server_name == self.config.server_name }
|
pub fn server_is_ours(&self, server_name: &ServerName) -> bool { server_name == self.config.server_name }
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_read_only(&self) -> bool { self.db.db.is_read_only() }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue