Fix HostDB sync issue by preserving expiry_time on load #12431
Merged
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.
Problem
Although PR #12395 addresses an issue related to loading host.db, a new issue has been identified concerning the synchronization to host.db after the fix.
In short, the cache loaded from host.db is not being synced back to host.db.
Since synchronization to host.db is handled by
HostDBSync, I investigated the behavior and found that thewrite_partitionmethod inHostDBSyncwas skipping the write operation.Specifically, the following
ifstatement was triggered, and according to a gdb inspection,entry->meta.expiry_timewas set to -1:trafficserver/iocore/hostdb/P_RefCountCacheSerializer.h
Lines 167 to 170 in 9f6abab
Cause
The cause of
entry->meta.expiry_timebeing -1 lies in the load process of host.db, specifically in theLoadRefCountCacheFromPathfunction:trafficserver/iocore/hostdb/P_RefCountCache.h
Lines 612 to 615 in 9f6abab
The cache is registered via a call to
cache.put(RefCountCache<HostDBInfo>::put), but since the 4th argument (expiry_time) is omitted, the default value -1 is used:trafficserver/iocore/hostdb/P_RefCountCache.h
Line 405 in 9f6abab
Fix
The correct value to pass for the 4th argument of
RefCountCache<HostDBInfo>::putis stored intmpValue.expiry_time.This patch updates the call to explicitly pass
tmpValue.expiry_timeas theexpiry_timeargument.