ircd: Promote slave-mode to a non-maintenance mode allowing listeners.

This commit is contained in:
Jason Volk 2023-03-19 12:41:45 -07:00
parent 19462b5fae
commit c3c73fcbe7
6 changed files with 58 additions and 34 deletions

View File

@ -571,7 +571,7 @@ applyargs()
if(slave)
{
ircd::db::open_slave.set("true");
ircd::slave.set("true");
read_only = true; // slave implies read_only
}

View File

@ -18,7 +18,6 @@ namespace ircd::db
// Broad conf items
extern conf::item<std::string> open_recover;
extern conf::item<bool> open_repair;
extern conf::item<bool> open_slave;
extern conf::item<bool> auto_compact;
extern conf::item<bool> auto_deletion;
extern conf::item<bool> open_stats;

View File

@ -129,9 +129,10 @@ namespace ircd
// Operating Mode Selectors
extern conf::item<bool> debugmode;
extern conf::item<bool> maintenance;
extern conf::item<bool> soft_assert;
extern conf::item<bool> read_only; // implies write_avoid
extern conf::item<bool> maintenance;
extern conf::item<bool> slave;
extern conf::item<bool> read_only;
extern conf::item<bool> defaults;
}

View File

@ -81,17 +81,6 @@ ircd::db::auto_deletion
{ "persist", false },
};
/// Conf item dictates whether databases will be opened in slave mode; this
/// is a recent feature of RocksDB which may not be available. It allows two
/// instances of a database, so long as only one is not opened as a slave.
decltype(ircd::db::open_slave)
ircd::db::open_slave
{
{ "name", "ircd.db.open.slave" },
{ "default", false },
{ "persist", false },
};
/// Gather statistics about files on open to inform the compaction algorithm.
/// This can be disabled to prevent touching a lot of files on open, but it's
/// unclear when/if that information will be gathered to ever inform compactor.
@ -940,7 +929,7 @@ try
}
,slave
{
db::open_slave
ircd::slave
}
,read_only
{

View File

@ -107,6 +107,22 @@ ircd::maintenance
}
};
/// Conf item dictates whether databases will be opened in slave mode; this
/// is a recent feature of RocksDB which may not be available. It allows
/// multiple processes to open the same database in a single-writer multiple
/// reader configuration.
///
/// Originally this was intended as a maintenance mode to explore another live
/// running server's database. However it now allows listeners which can serve
/// as load-balanced mirrors and caches over a database shared at the fs level
/// locally or with nfs/ceph/intermezzo etc.
decltype(ircd::slave)
ircd::slave
{
{ "name", "ircd.slave" },
{ "default", false },
{ "persist", false },
};
/// Coarse mode declaration for read-only behavior. All subsystems and feature
/// modules respect this indicator by preventing any writes and persistence
@ -125,6 +141,10 @@ ircd::read_only
if(!read_only)
return;
// Not implict maintenance mode when slave mode is set.
if(slave)
return;
maintenance.set("true");
}
};

View File

@ -63,6 +63,11 @@ on_load()
init_conf_listeners();
init_room_listeners();
if(listeners.empty())
log::warning
{
"No listening sockets configured; can't hear anyone."
};
}
void
@ -145,7 +150,7 @@ init_conf_listeners()
{
"Listener '%s' configured for %s:%s by environment",
p.first,
p.second["host"],
unquote(p.second["host"]),
p.second["port"],
};
}
@ -167,12 +172,6 @@ init_room_listeners()
{
load_listener(event);
});
if(listeners.empty())
log::warning
{
"No listening sockets configured; can't hear anyone."
};
}
//
@ -265,19 +264,35 @@ load_listener(const m::event &event)
json::get<"content"_>(event)
};
if(!load_listener(name, opts))
return false;
log::notice
if(ircd::slave)
{
"Listener '%s' configured for %s:%s by %s",
name,
opts["host"],
opts["port"],
string_view{event.event_id},
};
log::warning
{
"Listener '%s' configured for %s:%s by %s ignored in slave mode.",
name,
unquote(opts["host"]),
opts["port"],
string_view{event.event_id},
};
return true;
return false;
}
if(load_listener(name, opts))
{
log::notice
{
"Listener '%s' configured for %s:%s by %s",
name,
unquote(opts["host"]),
opts["port"],
string_view{event.event_id},
};
return true;
}
return false;
}
ctx::context