You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I tried to debug a simple case (calling a Cassandra repository method twice), I saw that the PrepareRequest does not get cached.
at line CqlPrepareAsyncProcessor::61 from java-driver-core-4.13.0.jar CompletableFuture<PreparedStatement> result = cache.getIfPresent(request);
It should return the CompletableFuture (from the previous query), but it is always null.
When I check the request during debugging, I see that it's a DefaultPrepareRequest, holds a DefaultSimpleStatement. The hash of the DefaultPrepareRequest is the hash of the DefaultSimpleStatement.
Comparing the hash from the DefaultSimpleStatement from Cache, and the hash from the DefaultSimpleStatement from the request, I found that they are not equal.
As mentioned this is a duplicate of #1213. The positional values are being included in the cache key, so there are never any cache hits (unless you sent exactly the same request in).
Hi,
During performance testing, we noticed a lot of threads waiting (waiting on Cassandra) while creating prepared statements.
Using Dynatrace (our monitoring tool) we see that executing the query takes the same time as preparing the statement.


According to the documentation (https://docs.spring.io/spring-data/cassandra/docs/current/reference/html/#cassandra.template.prepared-statements.caching), it should cache the prepared statement. We use a Spring Cassandra repository, which uses the CassandraTemplate.
When I tried to debug a simple case (calling a Cassandra repository method twice), I saw that the PrepareRequest does not get cached.
at line CqlPrepareAsyncProcessor::61 from java-driver-core-4.13.0.jar
CompletableFuture<PreparedStatement> result = cache.getIfPresent(request);
It should return the CompletableFuture (from the previous query), but it is always null.
When I check the request during debugging, I see that it's a DefaultPrepareRequest, holds a DefaultSimpleStatement. The hash of the DefaultPrepareRequest is the hash of the DefaultSimpleStatement.
Comparing the hash from the DefaultSimpleStatement from Cache, and the hash from the DefaultSimpleStatement from the request, I found that they are not equal.
DefaultSimpleStatement from request:

DefaultSimpleStatement from cache:

The hash gets calculated
@Override public int hashCode() { return Objects.hash( query, positionalValues, namedValues, executionProfileName, executionProfile, keyspace, routingKeyspace, routingKey, routingToken, customPayload, idempotent, tracing, timestamp, pagingState, pageSize, consistencyLevel, serialConsistencyLevel, timeout, node, nowInSeconds); }
The difference comes from the positionalValues; which are not the same for both statements.
I cannot share the code used for the performance testing, as this is production code. I could create a small example if required.
Using:
Spring Data Cassandra version 3.3.1
Thanks,
Sander
EDIT: This might be a duplicate of #1213 but I'm not sure.
The text was updated successfully, but these errors were encountered: