You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by mr...@apache.org on 2016/12/21 00:52:11 UTC

usergrid git commit: Fix cassandra transport frame size exceptions due to numeric overflow causing incorrect calucations of batch loading of entities from cassandra.

Repository: usergrid
Updated Branches:
  refs/heads/hotfix-20160819 cdc417d98 -> ff574d3b3


Fix cassandra transport frame size exceptions due to numeric overflow causing incorrect calucations of batch loading of entities from cassandra.


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

Branch: refs/heads/hotfix-20160819
Commit: ff574d3b3399b38048a4b9328004261623256bd4
Parents: cdc417d
Author: Michael Russo <mr...@apigee.com>
Authored: Tue Dec 20 16:51:19 2016 -0800
Committer: Michael Russo <mr...@apigee.com>
Committed: Tue Dec 20 16:51:19 2016 -0800

----------------------------------------------------------------------
 .../impl/MvccEntitySerializationStrategyV3Impl.java   | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/ff574d3b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
index 57607d0..f2ecdec 100644
--- a/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
+++ b/stack/corepersistence/collection/src/main/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyV3Impl.java
@@ -159,12 +159,14 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
          *
          */
 
-        final int maxEntityResultSizeInBytes = serializationFig.getMaxEntitySize() * entityIds.size();
+        // convert getMaxEntitySize to a long avoid a numeric overflow and use a double for the result precision
+        final double maxEntityResultSizeInBytes = (double)( (long)serializationFig.getMaxEntitySize() * (long)entityIds.size() );
 
-        //if we're less than 1, set the number of requests to 1
-        final int numberRequests = Math.max( 1, maxEntityResultSizeInBytes / cassandraFig.getThriftBufferSize() );
+        // if we're less than 1, set the number of requests to 1
+        final double numberRequests = Math.max( 1, maxEntityResultSizeInBytes / cassandraFig.getThriftBufferSize() );
 
-        final int entitiesPerRequest = entityIds.size() / numberRequests;
+        // don't overflow the buffer because of the remainder
+        final double entitiesPerRequest = Math.floor(entityIds.size() / numberRequests);
 
 
         final Scheduler scheduler;
@@ -181,10 +183,10 @@ public class MvccEntitySerializationStrategyV3Impl implements MvccEntitySerializ
 
         final EntitySetImpl entitySetResults = Observable.from( rowKeys )
             //buffer our entities per request, then for that buffer, execute the query in parallel (if neccessary)
-            .buffer( entitiesPerRequest ).flatMap( listObservable -> {
+            .buffer( (int)entitiesPerRequest ).flatMap( listObservable -> {
 
 
-                //here, we execute our query then emit the items either in parallel, or on the current thread
+                // here, we execute our query then emit the items either in parallel, or on the current thread
                 // if we have more than 1 request
                 return Observable.just( listObservable ).map( scopedRowKeys -> {