tolbertam commented on code in PR #3917:
URL: https://github.com/apache/cassandra/pull/3917#discussion_r2080830916


##########
src/java/org/apache/cassandra/db/SystemKeyspace.java:
##########
@@ -1862,17 +1866,52 @@ public static void resetPreparedStatements()
         preparedStatements.truncateBlockingWithoutSnapshot();
     }
 
-    public static int loadPreparedStatements(TriFunction<MD5Digest, String, 
String, Boolean> onLoaded)
+    public static int loadPreparedStatements(TriFunction<MD5Digest, String, 
String, Prepared> onLoaded)
+    {
+        return loadPreparedStatements(onLoaded, 
QueryProcessor.PRELOAD_PREPARED_STATEMENTS_FETCH_SIZE);
+    }
+
+    public static int loadPreparedStatements(TriFunction<MD5Digest, String, 
String, Prepared> onLoaded, int pageSize)
     {
         String query = String.format("SELECT prepared_id, logged_keyspace, 
query_string FROM %s.%s", SchemaConstants.SYSTEM_KEYSPACE_NAME, 
PREPARED_STATEMENTS);
-        UntypedResultSet resultSet = executeOnceInternal(query);
+        UntypedResultSet resultSet = executeOnceInternalWithPaging(query, 
pageSize);
         int counter = 0;
+
+        // As the cache size may be briefly exceeded before statements are 
evicted, we allow loading 110% the cache size
+        // to avoid logging early.
+        long cacheSize = new 
DataStorageSpec.LongBytesBound(DatabaseDescriptor.getPreparedStatementsCacheSizeMiB(),
+                                                            
DataStorageSpec.DataStorageUnit.MEBIBYTES).toBytes();
+        long preparedBytesLoadThreshold = (long) (cacheSize * 1.1);

Review Comment:
   I found that we still need a small buffer to avoid erroneously logging.  In 
my testing found that we often loaded a statement or two past the cache size. A 
10% buffer should be more than adequate.



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscr...@cassandra.apache.org
For additional commands, e-mail: pr-h...@cassandra.apache.org

Reply via email to