2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

add a quick-and-dirty method of debugging a single query

when built with "configure --enable-singletrace", named will produce
detailed query logging at the highest debug level for any query with
query ID zero.

this enables monitoring of the progress of a single query by specifying
the QID using "dig +qid=0". the "client" logging category should be set
to a low severity level to suppress logging of other queries. (the
chance of another query using QID=0 at the same time is only 1 in 2^16.)

"--enable-singletrace" turns on "--enable-querytrace" as well, so if the
logging severity is not lowered, all other queries will be logged
verbosely as well. compiling with either of these options will impair
query performance; they should only be turned on when testing or
troubleshooting.
This commit is contained in:
Evan Hunt
2020-05-15 16:37:44 -07:00
parent 23f2ab4543
commit 249184e03e
5 changed files with 90 additions and 28 deletions

View File

@@ -31,6 +31,7 @@
#include <isc/stat.h>
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/thread.h>
#include <isc/time.h>
#include <isc/util.h>
@@ -45,6 +46,8 @@
#define RDUNLOCK(lp) RWUNLOCK(lp, isc_rwlocktype_read);
#define WRUNLOCK(lp) RWUNLOCK(lp, isc_rwlocktype_write);
static thread_local bool forcelog = false;
/*
* XXXDCL make dynamic?
*/
@@ -1453,6 +1456,9 @@ isc_log_wouldlog(isc_log_t *lctx, int level) {
if (lctx == NULL) {
return (false);
}
if (forcelog) {
return (true);
}
int highest_level = atomic_load_acquire(&lctx->highest_level);
if (level <= highest_level) {
@@ -1484,6 +1490,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
bool printcategory, printmodule, printlevel, buffered;
isc_logchannel_t *channel;
isc_logchannellist_t *category_channels;
int_fast32_t dlevel;
isc_result_t result;
REQUIRE(lctx == NULL || VALID_CONTEXT(lctx));
@@ -1566,18 +1573,20 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
channel = category_channels->channel;
category_channels = ISC_LIST_NEXT(category_channels, link);
int_fast32_t dlevel = atomic_load_acquire(&lctx->debug_level);
if (((channel->flags & ISC_LOG_DEBUGONLY) != 0) && dlevel == 0)
{
continue;
}
if (channel->level == ISC_LOG_DYNAMIC) {
if (dlevel < level) {
if (!forcelog) {
dlevel = atomic_load_acquire(&lctx->debug_level);
if (((channel->flags & ISC_LOG_DEBUGONLY) != 0) &&
dlevel == 0) {
continue;
}
if (channel->level == ISC_LOG_DYNAMIC) {
if (dlevel < level) {
continue;
}
} else if (channel->level < level) {
continue;
}
} else if (channel->level < level) {
continue;
}
if ((channel->flags & ISC_LOG_PRINTTIME) != 0 &&
@@ -1862,3 +1871,8 @@ unlock:
UNLOCK(&lctx->lock);
RDUNLOCK(&lctx->lcfg_rwl);
}
void
isc_log_setforcelog(bool v) {
forcelog = v;
}