valchkou / cassandra-driver-mapping

JPA addon for DataStax Java Driver for Cassandra
58 stars 24 forks source link

Re-preparing warnings when using MappingSession #52

Closed DBatOWL closed 9 years ago

DBatOWL commented 9 years ago

When using the session to get an entity, i.e.

Entity entity = mappingSession.get(Entity.class, id);

I often get warnings from com.datastax.driver.core.Cluster.addPrepared() telling me the statement has already been prepared. Originally I thought it was a caching issue but I often see this for the same entity within short periods of time, somethings less than 30 seconds apart. Is there a extra level of synchronization that I need to do, or trigger, so that the statement will not undergo the seemingly redundant prepare step?

valchkou commented 9 years ago

No you don't have to do anything special. I will look into it

valchkou commented 9 years ago

datastax keeps it's own cache not available from outside. I can't keep my cache in sync with theirs but you can try to tune it. default cache in my code initialized as CacheBuilder.newBuilder().expireAfterAccess(5, TimeUnit.MINUTES).maximumSize(1000).concurrencyLevel(4).build();

can you try increase size or/and timeout and let me know if helped ? https://github.com/valchkou/cassandra-driver-mapping#pscache

DBatOWL commented 9 years ago

When I tried playing with these values in the past I wasn't seeing the message go away, but then I may have set the size of the cache too small as I was only considering the small number of prepared statements I had created, not all statements. I've given it another try, with a much larger cache and a one hour time out and I've only see the message appear once. If it becomes more frequent I'll see about further tuning the values but right now things looks good. Thanks for the advice!