Skip to content

Add live HostDB cache clearing#13409

Open
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:hostdb-live-clear
Open

Add live HostDB cache clearing#13409
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:hostdb-live-clear

Conversation

@bneradt

@bneradt bneradt commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Operators cannot discard stale HostDB entries without restarting Traffic
Server. A restart interrupts service and delays recovery from incorrect
DNS data.

This adds a traffic_ctl command and restricted JSON-RPC method to clear
HostDB safely under partition locks while preserving in-flight records.
This also uses scoped status snapshots and verifies clearing and
repopulation without a restart.

Fixes: #9022

Operators cannot discard stale HostDB entries without restarting Traffic
Server. A restart interrupts service and delays recovery from incorrect
DNS data.

This adds a traffic_ctl command and restricted JSON-RPC method to clear
HostDB safely under partition locks while preserving in-flight records.
This also uses scoped status snapshots and verifies clearing and
repopulation without a restart.

Fixes: apache#9022
Copilot AI review requested due to automatic review settings July 20, 2026 21:54
@bneradt bneradt added this to the 11.0.0 milestone Jul 20, 2026
@bneradt bneradt added DNS HostDB Documentation New Feature AuTest JSONRPC JSONRPC 2.0 related work. traffic_ctl traffic_ctl related work. labels Jul 20, 2026
@bneradt bneradt self-assigned this Jul 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an operationally safe way to clear HostDB (DNS resolution cache) at runtime, avoiding Traffic Server restarts when operators need to discard stale/incorrect DNS data. It introduces a restricted JSON-RPC method, wires it to a new traffic_ctl hostdb clear command, and adds a gold test to validate clearing and repopulation without restarting ATS.

Changes:

  • Add restricted JSON-RPC method admin_hostdb_clear that clears HostDB’s refcounted cache under partition locks.
  • Add traffic_ctl hostdb clear command that invokes the new JSON-RPC method.
  • Add gold test to verify HostDB population → clear → empty → repopulation without restarting Traffic Server, plus doc updates for both JSON-RPC and traffic_ctl.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/gold_tests/dns/hostdb_clear.test.py New gold test covering HostDB clear + repopulation behavior without restart.
src/traffic_server/RpcAdminPubHandlers.cc Registers the new restricted JSON-RPC handler admin_hostdb_clear.
src/traffic_ctl/traffic_ctl.cc Adds traffic_ctl hostdb clear command to the CLI parser.
src/traffic_ctl/jsonrpc/CtrlRPCRequests.h Adds HostDBClearRequest client request mapping to admin_hostdb_clear.
src/traffic_ctl/CtrlCommands.h Extends HostDBCommand with clear subcommand wiring.
src/traffic_ctl/CtrlCommands.cc Implements HostDBCommand::clear() invocation via JSON-RPC.
src/mgmt/rpc/handlers/hostdb/HostDB.cc Implements clear_hostdb() handler; updates HostDB status snapshotting to retain record handles safely outside locks.
src/iocore/hostdb/P_RefCountCache.h Makes RefCountCache::clear() take per-partition exclusive locks before clearing.
src/iocore/hostdb/HostDB.cc Adds HostDBProcessor::clear() that clears the underlying refcount cache.
include/mgmt/rpc/handlers/hostdb/HostDB.h Declares the new clear_hostdb handler.
include/iocore/hostdb/HostDBProcessor.h Declares HostDBProcessor::clear() public API.
doc/developer-guide/jsonrpc/jsonrpc-api.en.rst Documents the new admin_hostdb_clear JSON-RPC method.
doc/appendices/command-line/traffic_ctl.en.rst Documents traffic_ctl hostdb clear and links it to the JSON-RPC API entry.

@bneradt
bneradt requested a review from masaori335 July 20, 2026 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AuTest DNS HostDB JSONRPC JSONRPC 2.0 related work. New Feature traffic_ctl traffic_ctl related work.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

clear hostdb cache without restarting ATS

2 participants