Add live HostDB cache clearing - #13409
Conversation
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
There was a problem hiding this comment.
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_clearthat clears HostDB’s refcounted cache under partition locks. - Add
traffic_ctl hostdb clearcommand 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. |
|
I'm just forwarding message, but P0 and P1 seems blocker. P4 is pretty interesting, this fixed a leak silently, which I introduced, thank you :) Review:
|
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