improve calculation of database size

"max-journal-size" is set by default to twice the size of the zone
database. however, the calculation of zone database size was flawed.

- change the size calculations in dns_db_getsize() to more accurately
  represent the space needed for a journal file or *XFR message to
  contain the data in the database. previously we returned the sizes
  of all rdataslabs, including header overhead and offset tables,
  which resulted in the database size being reported as much larger
  than the equivalent journal transactions would have been.
- map files caused a particular problem here: the full name can't be
  determined from the node while a file is being deserialized, because
  the uppernode pointers aren't set yet. so we store "full name length"
  in the dns_rbtnode structure while serializing, and clear it after
  deserialization is complete.
This commit is contained in:
Evan Hunt
2020-03-09 11:32:47 -07:00
parent c99f7cf9bd
commit c5405c2700
10 changed files with 172 additions and 46 deletions

View File

@@ -1184,6 +1184,47 @@ rbt_nodechain(void **state) {
test_context_teardown(ctx);
}
/* Test addname return values */
static void
rbtnode_namelen(void **state) {
isc_result_t result;
test_context_t *ctx = NULL;
dns_rbtnode_t *node;
unsigned int len;
UNUSED(state);
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
ctx = test_context_setup();
node = NULL;
result = insert_helper(ctx->rbt, ".", &node);
len = dns__rbtnode_namelen(node);
assert_int_equal(result, ISC_R_EXISTS);
assert_int_equal(len, 1);
node = NULL;
result = insert_helper(ctx->rbt, "a.b.c.d.e.f.g.h.i.j.k.l.m", &node);
len = dns__rbtnode_namelen(node);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(len, 27);
node = NULL;
result = insert_helper(ctx->rbt, "isc.org", &node);
len = dns__rbtnode_namelen(node);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(len, 9);
node = NULL;
result = insert_helper(ctx->rbt, "example.com", &node);
len = dns__rbtnode_namelen(node);
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(len, 13);
test_context_teardown(ctx);
}
#if defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__)
/*
@@ -1324,6 +1365,8 @@ main(void) {
_teardown),
cmocka_unit_test_setup_teardown(rbt_nodechain, _setup,
_teardown),
cmocka_unit_test_setup_teardown(rbtnode_namelen, _setup,
_teardown),
#if defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__)
cmocka_unit_test_setup_teardown(benchmark, _setup, _teardown),
#endif /* defined(DNS_BENCHMARK_TESTS) && !defined(__SANITIZE_THREAD__) */