Fix possible divide-by-zero in HHOM
patch by jbellis for CASSANDRA-5990

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8cc28a14
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8cc28a14
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8cc28a14

Branch: refs/heads/cassandra-2.0
Commit: 8cc28a1477e19545bd0f6dca9180c937f9c85c8d
Parents: f5618e3
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Thu Sep 12 13:21:20 2013 +0200
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Thu Sep 12 13:21:37 2013 +0200

----------------------------------------------------------------------
 CHANGES.txt                                                | 1 +
 src/java/org/apache/cassandra/db/HintedHandOffManager.java | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cc28a14/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index e420a7b..6ece609 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.10
+ * Fix possible divide-by-zero in HHOM (CASSANDRA-5990)
  * Allow local batchlog writes for CL.ANY (CASSANDRA-5967)
  * Optimize name query performance in wide rows (CASSANDRA-5966)
  * Upgrade metrics-core to version 2.2.0 (CASSANDRA-5947)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/8cc28a14/src/java/org/apache/cassandra/db/HintedHandOffManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/HintedHandOffManager.java 
b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
index 5ca32c3..c333359 100644
--- a/src/java/org/apache/cassandra/db/HintedHandOffManager.java
+++ b/src/java/org/apache/cassandra/db/HintedHandOffManager.java
@@ -436,9 +436,10 @@ public class HintedHandOffManager implements 
HintedHandOffManagerMBean
     private int calculatePageSize()
     {
         // read less columns (mutations) per page if they are very large
-        if (hintStore.getMeanColumns() > 0)
+        int meanColumnCount = hintStore.getMeanColumns();
+        if (meanColumnCount > 0)
         {
-            int averageColumnSize = (int) (hintStore.getMeanRowSize() / 
hintStore.getMeanColumns());
+            int averageColumnSize = (int) (hintStore.getMeanRowSize() / 
meanColumnCount);
             // page size of 1 does not allow actual paging b/c of >= behavior 
on startColumn
             return Math.max(2, Math.min(PAGE_SIZE, 
DatabaseDescriptor.getInMemoryCompactionLimit() / averageColumnSize));
         }

Reply via email to