Add live HostDB cache clearing#13409
Open
bneradt wants to merge 1 commit into
Open
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
Contributor
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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