首页 > 数据库 >mongodb报错Sort exceeded memory limit of 104857600 bytes

mongodb报错Sort exceeded memory limit of 104857600 bytes

时间:2023-07-14 17:13:00浏览次数:41  
标签:Sort abc mongodb allowDiskUse 报错 memory main true find

mongodb运行过程中,遇到错误信息:

2023-07-14T09:29:33.853 ERR Failed to QueryBsPoolUnivStat error="(QueryExceededMemoryLimitNoDiskUseAllowed) Executor error during find command :: caused by :: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting."
2023-07-14T09:29:33.853 ERR Failed to query LoadAllStockpoolUnivStatHistory  perf history error="(QueryExceededMemoryLimitNoDiskUseAllowed) Executor error during find command :: caused by :: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting."
panic: Load  all LoadAllStockpoolUnivStatHistory: (QueryExceededMemoryLimitNoDiskUseAllowed) Executor error during find command :: caused by :: Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting.

goroutine 1 [running]:
abc/srv/abc/stock/data.(*DataClient).LoadMongoCache(0xc000042600)
        /test/srv/abc/stock/data/data.go:455 +0x9a5
abc/srv/abc/stock.NewDataServer(0xc000042600, {0xc0008b02e0, 0x4})
        /test/srv/abc/stock/provider.go:64 +0x2f4
main.setupRouter({0x7f6690308800, 0xc0003dd520}, 0x32?, {0xc0008b02e0, 0x4})
        /test/cmd/abce/main.go:83 +0x265
main.main()
        /test/cmd/abce/main.go:65 +0x685


mongodb的版本:5.0.13

报错产生的原因:
因为查询排序数据量太大,导致报错。
详细内容可以参看官方文档。地址如下:

https://www.mongodb.com/docs/manual/reference/operator/aggregation/sort/?_ga=2.90473562.1126669746.1689308968-1238152925.1673317434#sort-operator-and-memory

 

具体说明:

Starting in MongoDB 6.0, pipeline stages that require more than 100 megabytes of memory to execute write temporary files to disk by default. In earlier verisons of MongoDB, you must pass { allowDiskUse: true } to individual find and aggregate commands to enable this behavior.
Individual find and aggregate commands may override the allowDiskUseByDefault parameter by either: Using { allowDiskUse: true } to allow writing temporary files out to disk when allowDiskUseByDefault is set to false Using { allowDiskUse: false } to prohibit writing temporary files out to disk when allowDiskUseByDefault is set to true

 

解决方案:
根据文档,可以在查询中添加{ allowDiskUse: true }

不过本次没有修改代码并添加{ allowDiskUse: true },因为发现集合中缺少索引,创建索引后,问题得到解决。

网上有人说可以修改参数:internalQueryExecMaxBlockingSortBytes。比如,执行以下命令:

db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: 335544320})

但是,我查了一下,没有这个参数:

> use admin
switched to db admin
> db.runCommand( { getParameter : 1, "internalQueryExecMaxBlockingSortBytes" : 1 } );
{ "ok" : 0, "errmsg" : "no option found to get" }
> 


其它
获取所有配置参数的值:

db.runCommand( { getParameter : '*' } )

标签:Sort,abc,mongodb,allowDiskUse,报错,memory,main,true,find
From: https://www.cnblogs.com/abclife/p/17553522.html

相关文章

  • mongodb4.4.22主从(副本集附仲裁节点)部署带认证模式
    环境:OS:CentOS7DB:4.4.22机器角色:192.168.1.102:29001主192.168.1.104:29001从192.168.1.105:29001仲裁节点 1.下载相应的版本https://www.mongodb.com/download-center/community我这里下载的是mongodb-linux-x86_64-rhel70-4.4.22.tgz 2.创建安装目录192.168.1.102......
  • 【AGC】删除控制台应用重建报错url is null问题
    ​【关键字】AGC、agconnect-services.json、InvalidParameterException 【问题描述】有开发者反馈在删除了AppGalleryConnect中某个应用及其对应的项目,再重新创建相同的应用(包名一致),并且重新下载agconnect-services.json到项目中,应用会因为com.huawei.agconnect闪退。报错......
  • 【报错解决】使用代理后从Github中clone仓库报错
    当电脑使用代理后,会造成Github的clone和push等功能无法正常使用报错内容:PSD:\Github>gitclonehttps://github.com/sige5193/bittly.gitCloninginto'bittly'...fatal:unabletoaccess'https://github.com/sige5193/bittly.git/':Failedtoconnecttogithub.com......
  • mongodb 入门 和 php示例
    内容太多了,感觉不好写,就写点入门的吧,其他参考参考_MonogDB中文网(mongodb.net.cn)虽然内容是机器翻译的,但也还好,基本能看. 相关概念: database数据库collection集合,相当于数据库表document文档,相当于数据记录行 dockerrun-d--namemongo-p27017:27......
  • Sort
    该和排序算法做个了结了15种排序算法动态演示这个视频是在网上看到的。那我们就跟着视频来写出这15种排序算法吧。这15种排序分别是:1.简单选择排序2.插入排序3.快速排序4.合并排序5.堆排序6.基数排序7.最高有效位排序8.内省排序9.适应性归并排序10.希尔排序(缩小增量......
  • node 运行报错 SyntaxError: Cannot use import statement outside a module
    报错信息PSD:\myCode\excercise\node>nodeindex.js(node:26820)Warning:ToloadanESmodule,set"type":"module"inthepackage.jsonorusethe.mjsextension.(Use`node--trace-warnings...`toshowwherethewarningwascreate......
  • 使用nuxtjs静态部署时报错TypeError: renderContext.renderResourceHints is not a fu
    在使用nuxt框架进行静态打包部署时候每次总会有一两个界面报TypeError:renderContext.renderResourceHintsisnotafunction的错误 一开始以为是asyncData中获取的数据有问题,在各种排查后返现数据没问题,再次编译还是会有错误,最后甚至把asyncdata方法给删除掉都还是有这个错......
  • 【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Win
    问题描述PHP的WebJob,通过artisan来配置路径启动PHP任务,相关启动脚本如下:artisan_path="d:\\home\\site\\wwwroot";cd${artisan_path}echo"\n"pwdphpartisanschedule:run但是,在运行的时候遇见报错:[07/06/202301:57:31>0f21a2:INFO]/d/home/site/wwwroo......
  • vue+vite项目在浏览器运行正常,在钉钉白屏报错,在嵌入的app里面白屏报错
    1.在钉钉直接打开本地跑的项目白屏并且报错UncaughtReferenceError:globalThisisnotdefined/@vite/client:135:7ReferenceError:globalThisisnotdefinedathttp://192.168.20.36:5173/@vite/client:135:7UncaughtSyntaxError:Unexpectedtoken./src/main.ts:19:38......
  • 解决redis hash序列化报错的具体操作步骤
    RedisHash序列化报错的解决方法1.问题背景在使用Redis时,有时候会遇到Hash序列化报错的问题。这种问题通常是由于Redis中存储的数据类型与操作的数据类型不一致导致的。在下面的文章中,我将为你详细介绍解决这个问题的步骤和相应的代码示例。2.解决步骤步骤操作1.查......