You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by be...@apache.org on 2024/11/04 09:06:04 UTC
(cassandra) branch cassandra-4.1 updated (28759d8bbc -> 94c2a09772)
This is an automated email from the ASF dual-hosted git repository.
bereng pushed a change to branch cassandra-4.1
in repository https://gitbox.apache.org/repos/asf/cassandra.git
from 28759d8bbc CEP-10: Simulator Java11 Support (backport to cassandra-4.1)
new ff54fd5ffd CASSANDRA-19986 Prepared statements cache computation improvements
new 94c2a09772 Merge branch 'cassandra-4.0' into cassandra-4.1
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../org/apache/cassandra/cql3/QueryHandler.java | 3 +++
.../org/apache/cassandra/cql3/QueryProcessor.java | 31 +++++++++++++++-------
src/java/org/apache/cassandra/utils/MD5Digest.java | 6 +++++
.../cassandra/cql3/PstmtPersistenceTest.java | 4 ++-
4 files changed, 34 insertions(+), 10 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org
(cassandra) 01/01: Merge branch 'cassandra-4.0' into cassandra-4.1
Posted by be...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
bereng pushed a commit to branch cassandra-4.1
in repository https://gitbox.apache.org/repos/asf/cassandra.git
commit 94c2a097728e36938079eefa0b2fb461c6b75e1a
Merge: 28759d8bbc ff54fd5ffd
Author: Bereng <be...@gmail.com>
AuthorDate: Mon Nov 4 09:57:50 2024 +0100
Merge branch 'cassandra-4.0' into cassandra-4.1
* cassandra-4.0:
CASSANDRA-19986 Prepared statements cache computation improvements
.../org/apache/cassandra/cql3/QueryHandler.java | 3 +++
.../org/apache/cassandra/cql3/QueryProcessor.java | 31 +++++++++++++++-------
src/java/org/apache/cassandra/utils/MD5Digest.java | 6 +++++
.../cassandra/cql3/PstmtPersistenceTest.java | 4 ++-
4 files changed, 34 insertions(+), 10 deletions(-)
diff --cc src/java/org/apache/cassandra/cql3/QueryProcessor.java
index a23475bfed,910f8c79f8..5b803e7caf
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@@ -106,9 -91,9 +106,9 @@@ public class QueryProcessor implements
static
{
preparedStatements = Caffeine.newBuilder()
- .executor(MoreExecutors.directExecutor())
- .maximumWeight(capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMB()))
+ .executor(ImmediateExecutor.INSTANCE)
+ .maximumWeight(capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMiB()))
- .weigher(QueryProcessor::measure)
+ .weigher(QueryProcessor::getSizeOfPreparedStatementForCache)
.removalListener((key, prepared, cause) -> {
MD5Digest md5Digest = (MD5Digest) key;
if (cause.wasEvicted())
@@@ -436,10 -411,14 +436,15 @@@
CQLStatement statement = raw.prepare(clientState);
statement.validate(clientState);
+ Prepared res;
if (isInternal)
- return new Prepared(statement, "", fullyQualified, keyspace);
+ res = new Prepared(statement, "", fullyQualified, keyspace);
else
- return new Prepared(statement, query, fullyQualified, keyspace);
+ res = new Prepared(statement, query, fullyQualified, keyspace);
++
+ res.pstmntSize = measurePstmnt(res);
+
+ return res;
}
public static UntypedResultSet executeInternal(String query, Object... values)
@@@ -778,14 -678,14 +783,14 @@@
{
// Concatenate the current keyspace so we don't mix prepared statements between keyspace (#5352).
// (if the keyspace is null, queryString has to have a fully-qualified keyspace so it's fine.
- long statementSize = ObjectSizes.measureDeep(prepared.statement);
+ MD5Digest statementId = computeId(queryString, keyspace);
// don't execute the statement if it's bigger than the allowed threshold
- if (statementSize > capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMiB()))
- if (getSizeOfPreparedStatementForCache(statementId, prepared) > capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMB()))
++ if (getSizeOfPreparedStatementForCache(statementId, prepared) > capacityToBytes(DatabaseDescriptor.getPreparedStatementsCacheSizeMiB()))
throw new InvalidRequestException(String.format("Prepared statement of size %d bytes is larger than allowed maximum of %d MB: %s...",
- statementSize,
+ prepared.pstmntSize,
- DatabaseDescriptor.getPreparedStatementsCacheSizeMB(),
+ DatabaseDescriptor.getPreparedStatementsCacheSizeMiB(),
queryString.substring(0, 200)));
- MD5Digest statementId = computeId(queryString, keyspace);
+
Prepared previous = preparedStatements.get(statementId, (ignored_) -> prepared);
if (previous == prepared)
SystemKeyspace.writePreparedStatement(keyspace, statementId, queryString);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org