database: detect misconfigured unit tests that don't set available_memory

available_memory is used to seed many caches and controllers. Usually
it's detected from the environment, but unit tests configure it
on their own with fake values. If they forget, then the undefined
behavior sanitizer will kick in in random places (see 8aa842614a
("test: gossip_test: configure database memory allocation correctly")
for an example.

Prevent this early by asserting that available_memory is nonzero.

Closes #7612
This commit is contained in:
Avi Kivity
2020-11-15 18:52:52 +02:00
committed by Pekka Enberg
parent 13c6c90d8c
commit f55b522c1b

View File

@@ -392,6 +392,8 @@ database::database(const db::config& cfg, database_config dbcfg, service::migrat
, _shared_token_metadata(stm)
, _sst_dir_semaphore(sst_dir_sem)
{
assert(dbcfg.available_memory != 0); // Detect misconfigured unit tests, see #7544
local_schema_registry().init(*this); // TODO: we're never unbound.
setup_metrics();