[
https://issues.apache.org/jira/browse/HDDS-13595?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Ivan Andika updated HDDS-13595:
-------------------------------
Description:
In the listKeys, the following code is used to not list the keys if the cache
entry marks it as deleted.
{code:java}
// Entry should not be marked for delete, consider only those
// entries.
CacheValue<OmKeyInfo> cacheValue =
keyTable.getCacheValue(new CacheKey<>(kv.getKey()));
if (cacheValue == null || cacheValue.getCacheValue() != null) {
cacheKeyMap.put(kv.getKey(), kv.getValue());
currentCount++;
} {code}
However, it overwrites the cache key map (i.e. Map#put) regardless whether
cacheKeyMap contains the entry or not. This might not be correct in key
overwrite case where both cache and DB contains non-null entry, but cache entry
should be more up-to-date and should be returned instead. We can use
putIfAbsent instead.
was:
In the listKeys, the following code is used to not list the keys if the cache
entry marks it as deleted.
{code:java}
// Entry should not be marked for delete, consider only those
// entries.
CacheValue<OmKeyInfo> cacheValue =
keyTable.getCacheValue(new CacheKey<>(kv.getKey()));
if (cacheValue == null || cacheValue.getCacheValue() != null) {
cacheKeyMap.put(kv.getKey(), kv.getValue());
currentCount++;
} {code}
However, it overwrites the cache key map (i.e. Map#put) regardless whether
cacheKeyMap contains the entry or not. This might not be correct in key
overwrite case where both cache and DB contains non-null entry, but cache entry
should be more up-to-date and should be returned instead.
> ListKeys should not overwrite entry if non-null cache entry exists
> ------------------------------------------------------------------
>
> Key: HDDS-13595
> URL: https://issues.apache.org/jira/browse/HDDS-13595
> Project: Apache Ozone
> Issue Type: Bug
> Reporter: Ivan Andika
> Assignee: Ivan Andika
> Priority: Major
>
> In the listKeys, the following code is used to not list the keys if the cache
> entry marks it as deleted.
> {code:java}
> // Entry should not be marked for delete, consider only those
> // entries.
> CacheValue<OmKeyInfo> cacheValue =
> keyTable.getCacheValue(new CacheKey<>(kv.getKey()));
> if (cacheValue == null || cacheValue.getCacheValue() != null) {
> cacheKeyMap.put(kv.getKey(), kv.getValue());
> currentCount++;
> } {code}
> However, it overwrites the cache key map (i.e. Map#put) regardless whether
> cacheKeyMap contains the entry or not. This might not be correct in key
> overwrite case where both cache and DB contains non-null entry, but cache
> entry should be more up-to-date and should be returned instead. We can use
> putIfAbsent instead.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]