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


##########
src/java/org/apache/cassandra/db/SystemKeyspace.java:
##########
@@ -1862,17 +1865,61 @@ 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;
+        boolean possibleLeakDetected = false;
+        // accumulate the number of bytes loaded into the prepared cache, if 
it exceeds the cache size, assume we've
+        // encountered a leak and stop loading prepared statements.
+        long preparedBytesLoaded = 0L;
+        long cacheCapacity = 
QueryProcessor.getPreparedStatementsCacheMaximumCapacity();
         for (UntypedResultSet.Row row : resultSet)
         {

Review Comment:
   This is extremely hard to read imo. I understand your worried about pulling 
the size from the cache etc. But that is not the case anymore as we have that 
as a config value. Just loop and break KISS



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