0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-05-19 19:33:45 +02:00

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) if(slave)
{ {
ircd::db::open_slave.set("true"); ircd::slave.set("true");
read_only = true; // slave implies read_only read_only = true; // slave implies read_only
} }

View file

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

View file

@ -129,9 +129,10 @@ namespace ircd
// Operating Mode Selectors // Operating Mode Selectors
extern conf::item<bool> debugmode; extern conf::item<bool> debugmode;
extern conf::item<bool> maintenance;
extern conf::item<bool> soft_assert; 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; extern conf::item<bool> defaults;
} }

View file

@ -81,17 +81,6 @@ ircd::db::auto_deletion
{ "persist", false }, { "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. /// 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 /// 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. /// unclear when/if that information will be gathered to ever inform compactor.
@ -940,7 +929,7 @@ try
} }
,slave ,slave
{ {
db::open_slave ircd::slave
} }
,read_only ,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 /// Coarse mode declaration for read-only behavior. All subsystems and feature
/// modules respect this indicator by preventing any writes and persistence /// modules respect this indicator by preventing any writes and persistence
@ -125,6 +141,10 @@ ircd::read_only
if(!read_only) if(!read_only)
return; return;
// Not implict maintenance mode when slave mode is set.
if(slave)
return;
maintenance.set("true"); maintenance.set("true");
} }
}; };

View file

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