]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Do not decrement stats cache when the cache values are zero
authorPavan Rallabhandi <PRallabhandi@walmartlabs.com>
Tue, 18 Jul 2017 09:10:04 +0000 (14:40 +0530)
committerPavan Rallabhandi <PRallabhandi@walmartlabs.com>
Mon, 28 Aug 2017 07:07:22 +0000 (12:37 +0530)
With RGWs configured in a load balancer, there is a possibility of
having the cached values going unbound, when PUT/DELETE operations
do not land up on the same RGW. To avoid such cases, make sure the
decrement of stats happen only when the cached values are sane.

Fixes: http://tracker.ceph.com/issues/20661
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
(cherry picked from commit 3903e213c7ac7624e3452f5f3b1ca1c339bf2ca2)

Conflicts:
src/rgw/rgw_quota.cc

src/rgw/rgw_quota.cc

index 4abeb0c7e53ee865a36022efc44e82bead70667a..1153639184e928cda2a1e57bfba18023062bfc72 100644 (file)
@@ -221,9 +221,23 @@ public:
     uint64_t rounded_kb_added = rgw_rounded_objsize_kb(added_bytes);
     uint64_t rounded_kb_removed = rgw_rounded_objsize_kb(removed_bytes);
 
-    entry->stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed);
-    entry->stats.num_kb += (added_bytes - removed_bytes) / 1024;
-    entry->stats.num_objects += objs_delta;
+    if ((entry->stats.num_kb_rounded + rounded_kb_added - rounded_kb_removed) >= 0) {
+      entry->stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed);
+    } else {
+      entry->stats.num_kb_rounded = 0;
+    }
+    
+    if ((entry->stats.num_kb + ((added_bytes - removed_bytes) / 1024)) >= 0) {
+      entry->stats.num_kb += (added_bytes - removed_bytes) / 1024;
+    } else {
+      entry->stats.num_kb = 0;
+    }
+    
+    if ((entry->stats.num_objects + objs_delta) >= 0) {
+      entry->stats.num_objects += objs_delta;
+    } else {
+      entry->stats.num_objects = 0;
+    }
 
     return true;
   }