Skip to content

Conversation

@yknoya
Copy link
Contributor

@yknoya yknoya commented Aug 6, 2025

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 the write_partition method in HostDBSync was skipping the write operation.
Specifically, the following if statement was triggered, and according to a gdb inspection, entry->meta.expiry_time was set to -1:

// check if the item has expired, if so don't persist it to disk
if (entry->meta.expiry_time < curr_time) {
continue;
}

(gdb) p entry->meta.expiry_time
$1 = -1
(gdb) p curr_time
$2 = 1754462975

Cause

The cause of entry->meta.expiry_time being -1 lies in the load process of host.db, specifically in the LoadRefCountCacheFromPath function:

CacheEntryType *newItem = load_func((char *)&buf, tmpValue.size);
if (newItem != nullptr) {
cache.put(tmpValue.key, newItem, tmpValue.size - sizeof(CacheEntryType));
}

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:

void put(uint64_t key, C *item, int size = 0, ink_time_t expiry_time = -1);

Fix

The correct value to pass for the 4th argument of RefCountCache<HostDBInfo>::put is stored in tmpValue.expiry_time.
This patch updates the call to explicitly pass tmpValue.expiry_time as the expiry_time argument.

@yknoya yknoya requested a review from bryancall as a code owner August 6, 2025 07:25
@cmcfarlen cmcfarlen requested a review from ezelkow1 August 11, 2025 22:36
@ezelkow1 ezelkow1 assigned ezelkow1 and yknoya and unassigned ezelkow1 Aug 11, 2025
@ezelkow1 ezelkow1 added this to the 9.2.12 milestone Aug 11, 2025
@ezelkow1
Copy link
Member

ezelkow1 commented Sep 4, 2025

[approve ci autest 0]

@ezelkow1
Copy link
Member

ezelkow1 commented Sep 4, 2025

[approve ci]

@ezelkow1 ezelkow1 merged commit 17e52b0 into apache:9.2.x Sep 4, 2025
15 checks passed
@ezelkow1 ezelkow1 moved this from In progress to Done for v9.2.x in 9.2.x Branch and Release Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done for v9.2.x

Development

Successfully merging this pull request may close these issues.

2 participants