bereng commented on code in PR #3917:
URL: https://github.com/apache/cassandra/pull/3917#discussion_r2081045842
##########
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:
We better align to the code when the cache's size is initialized at the top
of the class:
`cacheSize=capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMiB())`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]