devmadhuu commented on code in PR #6508:
URL: https://github.com/apache/ozone/pull/6508#discussion_r1567445643


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/fs/CachingSpaceUsageSource.java:
##########
@@ -94,7 +95,16 @@ public void incrementUsedSpace(long usedSpace) {
   }
 
   public void decrementUsedSpace(long reclaimedSpace) {
-    cachedValue.addAndGet(-1 * reclaimedSpace);
+    long current = cachedValue.get();
+    long newValue = current - reclaimedSpace;
+    if (newValue < 0) {

Review Comment:
   Since usedSpace value can be decremented till ZERO and beyond that if we try 
to decrement, it may go negative, so this logic also not solving the problem 
completely. E.g. lets say we have current used space as 10 and `reclaimedSpace` 
is 15, ideally this should not happen, but our logic should be more resilient, 
in this scenario, we still should set the current used space value to ZERO 
because going negative is not allowed.



-- 
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