I recently migrated my MongoDB database from Windows Server to CentOS. The version is 2.4.9. I noticed that I have a slow retrieval of records by _id field! I ran a repair datab
Found the problem chatting with a MongoDB developer: I was running spring framework 4.0.0 and the slowness is related to this issue:
https://jira.spring.io/browse/SPR-11335
Updating Spring to version 4.0.1 (or above) solves the problem.
This was the stack trace from my call to the problem:
at java.lang.Class.getGenericSignature(Native Method)
at java.lang.Class.getGenericInterfaces(Class.java:813)
at org.springframework.core.SerializableTypeWrapper$2.getType(SerializableTypeWrapper.java:106)
at org.springframework.core.SerializableTypeWrapper$TypeProxyInvocationHandler.invoke(SerializableTypeWrapper.java:220)
at com.sun.proxy.$Proxy5.equals(Unknown Source)
at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:252)
at org.springframework.core.ResolvableType.equals(ResolvableType.java:682)
at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:252)
at org.springframework.core.ResolvableType.variableResolverSourceEquals(ResolvableType.java:719)
at org.springframework.core.ResolvableType.equals(ResolvableType.java:683)
at org.springframework.util.ConcurrentReferenceHashMap$Segment.findInChain(ConcurrentReferenceHashMap.java:571)
at org.springframework.util.ConcurrentReferenceHashMap$Segment.getReference(ConcurrentReferenceHashMap.java:439)
at org.springframework.util.ConcurrentReferenceHashMap.getReference(ConcurrentReferenceHashMap.java:238)
at org.springframework.util.ConcurrentReferenceHashMap.get(ConcurrentReferenceHashMap.java:217)
at org.springframework.core.ResolvableType.forType(ResolvableType.java:1018)
at org.springframework.core.ResolvableType.forType(ResolvableType.java:998)
at org.springframework.core.ResolvableType.getGenerics(ResolvableType.java:489)
at org.springframework.core.ResolvableType.getGeneric(ResolvableType.java:451)
at org.springframework.core.convert.TypeDescriptor.getElementTypeDescriptor(TypeDescriptor.java:305)
at org.springframework.core.convert.TypeDescriptor.equals(TypeDescriptor.java:456)
at org.springframework.util.ObjectUtils.nullSafeEquals(ObjectUtils.java:252)
at org.springframework.core.convert.support.GenericConversionService$ConverterCacheKey.equals(GenericConversionService.java:436)
at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:996)
at org.springframework.core.convert.support.GenericConversionService.getConverter(GenericConversionService.java:235)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:176)
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:162)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getPotentiallyConvertedSimpleRead(MappingMongoConverter.java:715)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readCollectionOrArray(MappingMongoConverter.java:773)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.readValue(MappingMongoConverter.java:1048)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.access$100(MappingMongoConverter.java:77)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$MongoDbPropertyValueProvider.getPropertyValue(MappingMongoConverter.java:999)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.getValueInternal(MappingMongoConverter.java:755)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:256)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:249)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:261)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:249)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:223)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:187)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:183)
at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:77)
at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1966)
at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1662)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1487)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1471)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:527)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:518)
at com.sytrue.record.persistence.repo.impl.RecordRepositoryImpl.findAsMapIds(RecordRepositoryImpl.java:139)
I had the same issue. I have updated my spring framework from 4.0.0 to 4.0.3 and it worked !!!