0
votes

I keep seeing this message in the logs, mainly everytime the query is made.

Query SELECT username AS col6,gender AS col1,last_name AS col2,email AS col3,first_name AS col4,something_uuid AS col5,group_email AS col7,deleted AS col8,puars AS col9 FROM something_data WHERE username=?; is not prepared on /XX.YY.91.205:9042, preparing before retrying executing. Seeing this message a few times is fine, but seeing it a lot may be source of performance problems.

The query is made using a mapper.get("username") ---> com.datastax.driver.mapping.Mapper

That's how I initialize the mapper in the constructor. After that I don't use the mappingManager anymore.

this.mapper = mappingManager.mapper(MyPojo.class);

Any clues why?

1
Can you put a piece of code that creates MappingManager & Mapper instances? I suspect that you don't keep MappingManager after its creationAlex Ott
@AlexOtt I've added that. Your assumption is correct. After initialisation in the constructor, the MappingManager is not used anymore.BadChanneler
In constructor of what? Of request or something else? My question is - are you recreating Mapping manager very often? Like for every get operation?Alex Ott
We were creating the MappingManager with @Bean from spring, but it had a custom name which was not used in repositories. In Repository it was initialised by spring using IoC.BadChanneler

1 Answers

1
votes

It looks like that you aren't keeping the instance of the MappingManager for a long time, but recreate it every time you fetch the data. It's a big mistake - MappingManager should have the same life time as Cluster and Session objects.

The mapping manager is responsible for extracting the field annotations from your class, generating queries, preparing them & then executing. The prepared queries are cached inside mapping manager, so when it destroyed, the cache is lost, and when you trying to perform get again, the process is repeated, leading to significant overhead - query need to be prepared again, and this is significant network overhead, so actually your queries are slower than if you used non-prepared queries.

Just move MappingManager instance to some static block, so it could be reused for all your mapper operations.