org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 292 (QueryExceededMemoryLimitNoDiskUseAllowed): 'Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.' on server 10.132.183.39:3717. The full response is {"operationTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "ok": 0.0, "errmsg": "Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.", "code": 292, "codeName": "QueryExceededMemoryLimitNoDiskUseAllowed", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "signature": {"hash": {"$binary": {"base64": "IW9rY6wWtI0YlxQc5MnbdQXPcWg=", "subType": "00"}}, "keyId": 7345409462263349250}}}
java.util.concurrent.CompletionException: org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 292 (QueryExceededMemoryLimitNoDiskUseAllowed): 'Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.' on server 10.132.183.39:3717. The full response is {"operationTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "ok": 0.0, "errmsg": "Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.", "code": 292, "codeName": "QueryExceededMemoryLimitNoDiskUseAllowed", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "signature": {"hash": {"$binary": {"base64": "IW9rY6wWtI0YlxQc5MnbdQXPcWg=", "subType": "00"}}, "keyId": 7345409462263349250}}}
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
at java.base/java.lang.Thread.run(Thread.java:831)
Caused by: org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 292 (QueryExceededMemoryLimitNoDiskUseAllowed): 'Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.' on server 10.132.183.39:3717. The full response is {"operationTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "ok": 0.0, "errmsg": "Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.", "code": 292, "codeName": "QueryExceededMemoryLimitNoDiskUseAllowed", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "signature": {"hash": {"$binary": {"base64": "IW9rY6wWtI0YlxQc5MnbdQXPcWg=", "subType": "00"}}, "keyId": 7345409462263349250}}}
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:136)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2805)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:573)
at org.springframework.data.mongodb.core.MongoTemplate.doStream(MongoTemplate.java:455)
at org.springframework.data.mongodb.core.MongoTemplate.stream(MongoTemplate.java:444)
at org.springframework.data.mongodb.core.MongoTemplate.stream(MongoTemplate.java:439)
at cn.com.disney.shdr.repository.common.ShdrCommonMongoRepositoryImpl.scrollAll(ShdrCommonMongoRepositoryImpl.java:93)
at jdk.internal.reflect.GeneratedMethodAccessor141.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker$RepositoryFragmentMethodInvoker.lambda$new$0(RepositoryMethodInvoker.java:288)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:136)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:120)
at org.springframework.data.repository.core.support.RepositoryComposition$RepositoryFragments.invoke(RepositoryComposition.java:516)
at org.springframework.data.repository.core.support.RepositoryComposition.invoke(RepositoryComposition.java:285)
at org.springframework.data.repository.core.support.RepositoryFactorySupport$ImplementationMethodExecutionInterceptor.invoke(RepositoryFactorySupport.java:628)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:168)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:143)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:77)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:218)
at jdk.proxy3/jdk.proxy3.$Proxy224.scrollAll(Unknown Source)
at jdk.internal.reflect.GeneratedMethodAccessor140.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:196)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:184)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:218)
at jdk.proxy3/jdk.proxy3.$Proxy224.scrollAll(Unknown Source)
at cn.com.disney.shdr.service.OrderManagementReportService.processTransportOrder(OrderManagementReportService.java:519)
at cn.com.disney.shdr.service.OrderManagementReportService.syncTransportOrder(OrderManagementReportService.java:461)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
... 1 common frames omitted
Caused by: com.mongodb.MongoQueryException: Command failed with error 292 (QueryExceededMemoryLimitNoDiskUseAllowed): 'Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.' on server 10.132.183.39:3717. The full response is {"operationTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "ok": 0.0, "errmsg": "Executor error during find command :: caused by :: Sort exceeded memory limit of 33554432 bytes, but did not opt in to external sorting.", "code": 292, "codeName": "QueryExceededMemoryLimitNoDiskUseAllowed", "$clusterTime": {"clusterTime": {"$timestamp": {"t": 1720589852, "i": 14}}, "signature": {"hash": {"$binary": {"base64": "IW9rY6wWtI0YlxQc5MnbdQXPcWg=", "subType": "00"}}, "keyId": 7345409462263349250}}}
at com.mongodb.internal.operation.FindOperation.lambda$execute$1(FindOperation.java:336)
at com.mongodb.internal.operation.OperationHelper.lambda$withSourceAndConnection$0(OperationHelper.java:356)
at com.mongodb.internal.operation.OperationHelper.withSuppliedResource(OperationHelper.java:381)
at com.mongodb.internal.operation.OperationHelper.lambda$withSourceAndConnection$1(OperationHelper.java:355)
at com.mongodb.internal.operation.OperationHelper.withSuppliedResource(OperationHelper.java:381)
at com.mongodb.internal.operation.OperationHelper.withSourceAndConnection(OperationHelper.java:354)
at com.mongodb.internal.operation.FindOperation.lambda$execute$2(FindOperation.java:329)
at com.mongodb.internal.async.function.RetryingSyncSupplier.get(RetryingSyncSupplier.java:67)
at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:340)
at com.mongodb.internal.operation.FindOperation.execute(FindOperation.java:79)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:191)
at com.mongodb.client.internal.MongoIterableImpl.execute(MongoIterableImpl.java:133)
at com.mongodb.client.internal.MongoIterableImpl.iterator(MongoIterableImpl.java:90)
at org.springframework.data.mongodb.core.MongoTemplate$CloseableIterableCursorAdapter.<init>(MongoTemplate.java:3303)
at org.springframework.data.mongodb.core.MongoTemplate.lambda$doStream$2(MongoTemplate.java:468)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:571)
... 37 common frames omitted
解决方法
目标字段上添加索引,也就是sort 排序的字段