morningman commented on code in PR #69557:
URL: https://github.com/apache/doris/pull/69557#discussion_r4366910140


##########
fe/fe-connector/fe-connector-cache/src/main/java/org/apache/doris/connector/cache/ScopedMetaCache.java:
##########
@@ -1144,6 +1150,11 @@ private void completeRemoval(
             VersionedValue<K, V> versioned, RemovalCause cause, boolean 
budgetEviction) {
         if (cause.wasEvicted() || budgetEviction) {
             evictionCount.increment();
+            if (weightBounded) {
+                // Every value of a bounded cache holds a reservation; it is 
released below.
+                evictionWeight.accumulateAndGet(
+                        versioned.registration.reservation.getBytes(), 
JvmSizeUtils::saturatedAdd);

Review Comment:
   Confirmed, and fixed in `31dba971849`. Releasing an `AdmissionReservation` 
zeroes its bytes, and an exact `invalidateKey` releases the generation its key 
node still points to, by a CAS outside the key node's monitor, so a release 
landing between Caffeine's removal and the deferred drain made the eviction 
count 0 bytes. Quota accounting was not affected: the reservation is still 
released exactly once. Each `Registration` now records the bytes its 
reservation was admitted with when the generation is created (both the fresh 
admission and the replacement create it right after admission), and 
`completeRemoval` adds those; reading the reservation under the key node's 
monitor would not have helped, since the invalidation's release does not take 
it. Budget reclamation in `evictLocalColdestWithDeferredRemovals` reads the 
same field for the bytes it removed, which equals the live value of a 
reservation that is not released and needs no budget manager lock. 
`MetaCacheWeightGovernanceTest#evi
 ctionWeightKeepsTheAdmittedBytesWhenInvalidationReleasesFirst` keeps the 
removal deferral open inside `forEach`, queues a capacity eviction and 
invalidates both keys before the drain: EVICTION_WEIGHT is now 768, where it 
was 0, and the budget is fully released.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to