mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
fix: Remove ability to set rocksdb as read only
This commit is contained in:
@@ -1056,10 +1056,6 @@
|
|||||||
#
|
#
|
||||||
#rocksdb_repair = false
|
#rocksdb_repair = false
|
||||||
|
|
||||||
# This item is undocumented. Please contribute documentation for it.
|
|
||||||
#
|
|
||||||
#rocksdb_read_only = false
|
|
||||||
|
|
||||||
# This item is undocumented. Please contribute documentation for it.
|
# This item is undocumented. Please contribute documentation for it.
|
||||||
#
|
#
|
||||||
#rocksdb_secondary = false
|
#rocksdb_secondary = false
|
||||||
|
|||||||
@@ -1244,9 +1244,6 @@ pub struct Config {
|
|||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rocksdb_repair: bool,
|
pub rocksdb_repair: bool,
|
||||||
|
|
||||||
#[serde(default)]
|
|
||||||
pub rocksdb_read_only: bool,
|
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rocksdb_secondary: bool,
|
pub rocksdb_secondary: bool,
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ pub struct Engine {
|
|||||||
pub(crate) db: Db,
|
pub(crate) db: Db,
|
||||||
pub(crate) pool: Arc<Pool>,
|
pub(crate) pool: Arc<Pool>,
|
||||||
pub(crate) ctx: Arc<Context>,
|
pub(crate) ctx: Arc<Context>,
|
||||||
pub(super) read_only: bool,
|
|
||||||
pub(super) secondary: bool,
|
pub(super) secondary: bool,
|
||||||
pub(crate) checksums: bool,
|
pub(crate) checksums: bool,
|
||||||
corks: AtomicU32,
|
corks: AtomicU32,
|
||||||
@@ -132,7 +131,7 @@ impl Engine {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn is_read_only(&self) -> bool { self.secondary || self.read_only }
|
pub fn is_read_only(&self) -> bool { self.secondary }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
|||||||
@@ -35,9 +35,7 @@ pub(crate) async fn open(ctx: Arc<Context>, desc: &[Descriptor]) -> Result<Arc<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug!("Opening database...");
|
debug!("Opening database...");
|
||||||
let db = if config.rocksdb_read_only {
|
let db = if config.rocksdb_secondary {
|
||||||
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)
|
Db::open_cf_descriptors_as_secondary(&db_opts, path, path, cfds)
|
||||||
} else {
|
} else {
|
||||||
Db::open_cf_descriptors(&db_opts, path, cfds)
|
Db::open_cf_descriptors(&db_opts, path, cfds)
|
||||||
@@ -55,7 +53,6 @@ pub(crate) async fn open(ctx: Arc<Context>, desc: &[Descriptor]) -> Result<Arc<S
|
|||||||
db,
|
db,
|
||||||
pool: ctx.pool.clone(),
|
pool: ctx.pool.clone(),
|
||||||
ctx: ctx.clone(),
|
ctx: ctx.clone(),
|
||||||
read_only: config.rocksdb_read_only,
|
|
||||||
secondary: config.rocksdb_secondary,
|
secondary: config.rocksdb_secondary,
|
||||||
checksums: config.rocksdb_checksums,
|
checksums: config.rocksdb_checksums,
|
||||||
corks: AtomicU32::new(0),
|
corks: AtomicU32::new(0),
|
||||||
|
|||||||
+1
-9
@@ -27,10 +27,6 @@ pub struct Args {
|
|||||||
#[arg(long, short('O'))]
|
#[arg(long, short('O'))]
|
||||||
pub option: Vec<String>,
|
pub option: Vec<String>,
|
||||||
|
|
||||||
/// Run in a stricter read-only --maintenance mode.
|
|
||||||
#[arg(long)]
|
|
||||||
pub read_only: bool,
|
|
||||||
|
|
||||||
/// Run in maintenance mode while refusing connections.
|
/// Run in maintenance mode while refusing connections.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub maintenance: bool,
|
pub maintenance: bool,
|
||||||
@@ -143,11 +139,7 @@ pub(crate) fn parse() -> Args { Args::parse() }
|
|||||||
|
|
||||||
/// Synthesize any command line options with configuration file options.
|
/// Synthesize any command line options with configuration file options.
|
||||||
pub(crate) fn update(mut config: Figment, args: &Args) -> Result<Figment> {
|
pub(crate) fn update(mut config: Figment, args: &Args) -> Result<Figment> {
|
||||||
if args.read_only {
|
if args.maintenance {
|
||||||
config = config.join(("rocksdb_read_only", true));
|
|
||||||
}
|
|
||||||
|
|
||||||
if args.maintenance || args.read_only {
|
|
||||||
config = config.join(("startup_netburst", false));
|
config = config.join(("startup_netburst", false));
|
||||||
config = config.join(("listening", false));
|
config = config.join(("listening", false));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user