Hi, I am facing an issue with scyllaDB open source hosted on a linux server. I am using java-driver-core 4.17.0.1 to connect to the database.
The DB was running fine for a few days, however now I am frequently getting an error:
java.lang.IllegalStateException: Tried to execute unprepared query 0x790045c38053c571e2729b50223c8737 but we don't have the data to reprepare it
at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler$NodeResponseCallback.processErrorResponse(CqlRequestHandler.java:667)
at com.datastax.oss.driver.internal.core.cql.CqlRequestHandler$NodeResponseCallback.onResponse(CqlRequestHandler.java:641)
at com.datastax.oss.driver.internal.core.channel.InFlightHandler.channelRead(InFlightHandler.java:255)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
Has something significant happened to the cluster in that time? Have you added/removed nodes or performed any unusual operations?
Regardless of that, you can try setting in your configuration advanced.prepared-statements.prepared-cache.weak-values to false. For reference, here’s manual page on configuration: ht tps://java-driver.docs.scylladb.com/stable/manual/core/configuration/
This will make driver use strong values for prepared statements cache instead of weak values. This may increase memory usage of your application so keep that in mind.
No I haven’t added any nodes. There is only a single scylla-server running on an ubuntu server.
I tried setting prepared_statements_cache_size_mb to a higher value, but the behaviour is still the same.
Isn’t the query supposed to be reprepared if its not found in the cache automatically?
How can I prevent this from happening without increasing memory usage?
Yes, the query will be reprepared as long as the driver has the data.
There are 2 things you should check for:
If you are using multiple session instances make sure you are not using a different session for the execution of your prepared query.
Make sure you store your prepared statements long enough. If you are using prepared statements as short-lived temporary objects then they may be garbage collected right after they are out of scope.
If it turns out that 2. is the cause then your memory usage will probably still rise a little, but there’s no helping it. To be clear that would be normal memory usage. Your current usage is lower because you are discarding something needed (assuming 2. is the cause)