'dict' object has no attribute '_txn_read_preference' && Sort exceeded memory limit of 10485760

简介: 'dict' object has no attribute '_txn_read_preference' && Sort exceeded memory limit of 10485760

前言


今天遇到了mongo 的一条语句两个问题, 在这里分享一下留个记录


问题一

Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.

这个问题是我使用mongo的aggregate聚合语句时出现的, 意思就是说排序超过了100M的限制, 没有进行外部缓存, 需要添加allowDiskUse 这个参数, 来做一个磁盘缓存, 我的语句

db.getCollection('price').aggregate([
                        {"$match": {"date": {"$lte": 20190326}}},
                        {"$sort": {"date": -1}},                                                 
                        {"$group": {"_id": "$city", "dat": {"$first": "$$ROOT"}}}
                        ], 
                        {"allowDiskUse": true}
                        )

这样就ok了


问题二


因为上面在mongo可视化工具里面执行成功了, 所以我就放到程序中, 然后报了一个错


{AttributeError}'dict' object has no attribute '_txn_read_preference'


这就比较懵了, 解决办法就是把 {“allowDiskUse”: true} 换成 allowDiskUse=true 就可以了, 但是一般来说mongo的后续参数在可视化工具里面也可以这样写, 比如 multi=True之类的, 这个就不行, 可能是因为参数使用范围的问题吧…

目录
相关文章
|
计算机视觉 Python
解决 NoneType‘ object has no attribute ‘astype’ 问题
解决 NoneType‘ object has no attribute ‘astype’ 问题
689 0
|
存储 JSON 数据格式
数据集加载时报错'dict' object has no attribute 'requests‘
数据集加载时报错'dict' object has no attribute 'requests‘
726 5
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
AttributeError: 'NoneType' object has no attribute 'to_capabilities'
1038 0
|
TensorFlow 算法框架/工具 Python
【Tensorflow 2】解决'Tensor' object has no attribute 'numpy'
解决'Tensor' object has no attribute 'numpy'
630 3
|
并行计算 Serverless API
函数计算操作报错合集之出现 "AttributeError: 'NoneType' object has no attribute 'pop'" 错误,是什么原因
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。
854 1
|
数据处理 API 索引
【Python】已解决:AttributeError: ‘Series‘ object has no attribute ‘sortlevel‘
【Python】已解决:AttributeError: ‘Series‘ object has no attribute ‘sortlevel‘
637 4
|
安全 计算机视觉 Python
【已解决】attributeerror: ‘FreeTypeFont‘ object has no attribute ‘getsize‘
【已解决】attributeerror: ‘FreeTypeFont‘ object has no attribute ‘getsize‘
|
机器学习/深度学习 监控 数据可视化
【已解决】 ‘Conv2d’ object has no attribute ‘register_full_backward_hook’
【已解决】 ‘Conv2d’ object has no attribute ‘register_full_backward_hook’
|
API C++ Python
【Azure 应用服务】Python fastapi Function在Azure中遇见AttributeError异常(AttributeError: 'AsgiMiddleware' object has no attribute 'handle_async')
【Azure 应用服务】Python fastapi Function在Azure中遇见AttributeError异常(AttributeError: 'AsgiMiddleware' object has no attribute 'handle_async')
387 0
|
TensorFlow API 算法框架/工具
【Tensorflow+keras】解决使用model.load_weights时报错 ‘str‘ object has no attribute ‘decode‘
python 3.6,Tensorflow 2.0,在使用Tensorflow 的keras API,加载权重模型时,报错’str’ object has no attribute ‘decode’
468 0

热门文章

最新文章