mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +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:
34
configure.ac
34
configure.ac
@@ -1420,13 +1420,35 @@ AS_CASE([$with_tuning],
|
|||||||
AC_MSG_NOTICE(using default system tuning)])
|
AC_MSG_NOTICE(using default system tuning)])
|
||||||
|
|
||||||
#
|
#
|
||||||
# was --enable-querytrace specified?
|
# was --enable-querytrace or --enable-singletrace specified?
|
||||||
#
|
#
|
||||||
|
AC_ARG_ENABLE([singletrace],
|
||||||
|
AS_HELP_STRING([--enable-singletrace],
|
||||||
|
[enable single-query trace logging
|
||||||
|
[default=no]]),
|
||||||
|
enable_singletrace="$enableval", enable_singletrace="no")
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether to enable single-query trace logging])
|
||||||
|
case "$enable_singletrace" in
|
||||||
|
yes)
|
||||||
|
enable_querytrace=yes
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_DEFINE(WANT_SINGLETRACE, 1, [Define to enable single-query tracing.])
|
||||||
|
;;
|
||||||
|
no)
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR("--enable-singletrace requires yes or no")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
AC_ARG_ENABLE(querytrace,
|
AC_ARG_ENABLE(querytrace,
|
||||||
AS_HELP_STRING([--enable-querytrace],
|
AS_HELP_STRING([--enable-querytrace],
|
||||||
[enable very verbose query trace logging
|
[enable very verbose query trace logging
|
||||||
[default=no]]),
|
[default=no]]),
|
||||||
enable_querytrace="$enableval", enable_querytrace="no")
|
enable_querytrace="$enableval",
|
||||||
|
enable_querytrace="$enable_singletrace")
|
||||||
|
|
||||||
AC_MSG_CHECKING([whether to enable query trace logging])
|
AC_MSG_CHECKING([whether to enable query trace logging])
|
||||||
case "$enable_querytrace" in
|
case "$enable_querytrace" in
|
||||||
@@ -1435,10 +1457,12 @@ yes)
|
|||||||
AC_DEFINE(WANT_QUERYTRACE, 1, [Define to enable very verbose query trace logging.])
|
AC_DEFINE(WANT_QUERYTRACE, 1, [Define to enable very verbose query trace logging.])
|
||||||
;;
|
;;
|
||||||
no)
|
no)
|
||||||
|
AS_IF([test "$enable_singletrace" = "yes"],
|
||||||
|
[AC_MSG_ERROR([--enable-singletrace requires --enable-querytrace])])
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
AC_MSG_ERROR("--enable-querytrace requires yes or no")
|
AC_MSG_ERROR("--enable-querytrace requires yes or no (not $enable_querytrace)")
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@@ -1701,6 +1725,8 @@ report() {
|
|||||||
echo " Allow 'fixed' rrset-order (--enable-fixed-rrset)"
|
echo " Allow 'fixed' rrset-order (--enable-fixed-rrset)"
|
||||||
test "yes" = "$enable_querytrace" && \
|
test "yes" = "$enable_querytrace" && \
|
||||||
echo " Very verbose query trace logging (--enable-querytrace)"
|
echo " Very verbose query trace logging (--enable-querytrace)"
|
||||||
|
test "yes" = "$enable_singletrace" && \
|
||||||
|
echo " Single-query trace logging (--enable-singletrace)"
|
||||||
test -z "$HAVE_CMOCKA" || echo " CMocka Unit Testing Framework (--with-cmocka)"
|
test -z "$HAVE_CMOCKA" || echo " CMocka Unit Testing Framework (--with-cmocka)"
|
||||||
|
|
||||||
test "auto" = "$validation_default" && echo " DNSSEC validation active by default (--enable-auto-validation)"
|
test "auto" = "$validation_default" && echo " DNSSEC validation active by default (--enable-auto-validation)"
|
||||||
@@ -1752,6 +1778,8 @@ report() {
|
|||||||
|
|
||||||
test "yes" = "$enable_querytrace" || \
|
test "yes" = "$enable_querytrace" || \
|
||||||
echo " Very verbose query trace logging (--enable-querytrace)"
|
echo " Very verbose query trace logging (--enable-querytrace)"
|
||||||
|
test "yes" = "$enable_singletrace" || \
|
||||||
|
echo " Single-query trace logging (--enable-singletrace)"
|
||||||
|
|
||||||
test "no" = "$with_cmocka" && echo " CMocka Unit Testing Framework (--with-cmocka)"
|
test "no" = "$with_cmocka" && echo " CMocka Unit Testing Framework (--with-cmocka)"
|
||||||
|
|
||||||
|
@@ -841,6 +841,14 @@ isc_logfile_roll(isc_logfile_t *file);
|
|||||||
*\li file is not NULL.
|
*\li file is not NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
isc_log_setforcelog(bool v);
|
||||||
|
/*%<
|
||||||
|
* Turn forced logging on/off for the current thread. This can be used to
|
||||||
|
* temporarily increase the debug level to maximum for the duration of
|
||||||
|
* a single task event.
|
||||||
|
*/
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
#endif /* ISC_LOG_H */
|
#endif /* ISC_LOG_H */
|
||||||
|
@@ -31,6 +31,7 @@
|
|||||||
#include <isc/stat.h>
|
#include <isc/stat.h>
|
||||||
#include <isc/stdio.h>
|
#include <isc/stdio.h>
|
||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
|
#include <isc/thread.h>
|
||||||
#include <isc/time.h>
|
#include <isc/time.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
@@ -45,6 +46,8 @@
|
|||||||
#define RDUNLOCK(lp) RWUNLOCK(lp, isc_rwlocktype_read);
|
#define RDUNLOCK(lp) RWUNLOCK(lp, isc_rwlocktype_read);
|
||||||
#define WRUNLOCK(lp) RWUNLOCK(lp, isc_rwlocktype_write);
|
#define WRUNLOCK(lp) RWUNLOCK(lp, isc_rwlocktype_write);
|
||||||
|
|
||||||
|
static thread_local bool forcelog = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXXDCL make dynamic?
|
* XXXDCL make dynamic?
|
||||||
*/
|
*/
|
||||||
@@ -1453,6 +1456,9 @@ isc_log_wouldlog(isc_log_t *lctx, int level) {
|
|||||||
if (lctx == NULL) {
|
if (lctx == NULL) {
|
||||||
return (false);
|
return (false);
|
||||||
}
|
}
|
||||||
|
if (forcelog) {
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
int highest_level = atomic_load_acquire(&lctx->highest_level);
|
int highest_level = atomic_load_acquire(&lctx->highest_level);
|
||||||
if (level <= 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;
|
bool printcategory, printmodule, printlevel, buffered;
|
||||||
isc_logchannel_t *channel;
|
isc_logchannel_t *channel;
|
||||||
isc_logchannellist_t *category_channels;
|
isc_logchannellist_t *category_channels;
|
||||||
|
int_fast32_t dlevel;
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
|
|
||||||
REQUIRE(lctx == NULL || VALID_CONTEXT(lctx));
|
REQUIRE(lctx == NULL || VALID_CONTEXT(lctx));
|
||||||
@@ -1566,9 +1573,10 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
channel = category_channels->channel;
|
channel = category_channels->channel;
|
||||||
category_channels = ISC_LIST_NEXT(category_channels, link);
|
category_channels = ISC_LIST_NEXT(category_channels, link);
|
||||||
|
|
||||||
int_fast32_t dlevel = atomic_load_acquire(&lctx->debug_level);
|
if (!forcelog) {
|
||||||
if (((channel->flags & ISC_LOG_DEBUGONLY) != 0) && dlevel == 0)
|
dlevel = atomic_load_acquire(&lctx->debug_level);
|
||||||
{
|
if (((channel->flags & ISC_LOG_DEBUGONLY) != 0) &&
|
||||||
|
dlevel == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1579,6 +1587,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category,
|
|||||||
} else if (channel->level < level) {
|
} else if (channel->level < level) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((channel->flags & ISC_LOG_PRINTTIME) != 0 &&
|
if ((channel->flags & ISC_LOG_PRINTTIME) != 0 &&
|
||||||
local_time[0] == '\0') {
|
local_time[0] == '\0') {
|
||||||
@@ -1862,3 +1871,8 @@ unlock:
|
|||||||
UNLOCK(&lctx->lock);
|
UNLOCK(&lctx->lock);
|
||||||
RDUNLOCK(&lctx->lcfg_rwl);
|
RDUNLOCK(&lctx->lcfg_rwl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
isc_log_setforcelog(bool v) {
|
||||||
|
forcelog = v;
|
||||||
|
}
|
||||||
|
@@ -344,6 +344,7 @@ isc_log_registermodules
|
|||||||
isc_log_setcontext
|
isc_log_setcontext
|
||||||
isc_log_setdebuglevel
|
isc_log_setdebuglevel
|
||||||
isc_log_setduplicateinterval
|
isc_log_setduplicateinterval
|
||||||
|
isc_log_setforcelog
|
||||||
isc_log_settag
|
isc_log_settag
|
||||||
isc_log_usechannel
|
isc_log_usechannel
|
||||||
isc_log_vwrite
|
isc_log_vwrite
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include <isc/formatcheck.h>
|
#include <isc/formatcheck.h>
|
||||||
#include <isc/fuzz.h>
|
#include <isc/fuzz.h>
|
||||||
#include <isc/hmac.h>
|
#include <isc/hmac.h>
|
||||||
|
#include <isc/log.h>
|
||||||
#include <isc/mutex.h>
|
#include <isc/mutex.h>
|
||||||
#include <isc/nonce.h>
|
#include <isc/nonce.h>
|
||||||
#include <isc/once.h>
|
#include <isc/once.h>
|
||||||
@@ -1596,6 +1597,10 @@ ns__client_reset_cb(void *client0) {
|
|||||||
|
|
||||||
client->state = NS_CLIENTSTATE_READY;
|
client->state = NS_CLIENTSTATE_READY;
|
||||||
INSIST(client->recursionquota == NULL);
|
INSIST(client->recursionquota == NULL);
|
||||||
|
|
||||||
|
#ifdef WANT_SINGLETRACE
|
||||||
|
isc_log_setforcelog(false);
|
||||||
|
#endif /* WANT_SINGLETRACE */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -1787,6 +1792,12 @@ ns__client_request(isc_nmhandle_t *handle, isc_region_t *region, void *arg) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WANT_SINGLETRACE
|
||||||
|
if (id == 0) {
|
||||||
|
isc_log_setforcelog(true);
|
||||||
|
}
|
||||||
|
#endif /* WANT_SINGLETRACE */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The client object handles requests, not responses.
|
* The client object handles requests, not responses.
|
||||||
* If this is a UDP response, forward it to the dispatcher.
|
* If this is a UDP response, forward it to the dispatcher.
|
||||||
|
Reference in New Issue
Block a user