我的产品比较多,导入20万产品,访问分类报错:Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in

问题咨询 · TonyLi · 于 6年前 发布 · 4815 次阅读

报错信息为:

An Error occurred while handling another error:
exception 'ReflectionException' with message 'Method fecshop\services\Product::getFrontCategoryProducts() does not exist' in /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php:195
Stack trace:
#0 /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php(195): ReflectionMethod->__construct('fecshop\\service...', 'getFrontCategor...')
#1 /www/web/dropship/vendor/yiisoft/yii2/views/errorHandler/callStackItem.php(26): yii\web\ErrorHandler->addTypeLinks('fecshop\\service...')
#2 /www/web/dropship/vendor/yiisoft/yii2/base/View.php(330): require('/www/web/dropsh...')
#3 /www/web/dropship/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('/www/web/dropsh...', Array)
#4 /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php(249): yii\base\View->renderFile('@yii/views/erro...', Array, Object(yii\web\ErrorHandler))
#5 /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php(304): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
#6 /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php(326): yii\web\ErrorHandler->renderCallStackItem('/www/web/dropsh...', 74, 'fecshop\\service...', 'getFrontCategor...', Array, 9)
#7 /www/web/dropship/vendor/yiisoft/yii2/views/errorHandler/exception.php(381): yii\web\ErrorHandler->renderCallStack(Object(yii\mongodb\Exception))
#8 /www/web/dropship/vendor/yiisoft/yii2/base/View.php(330): require('/www/web/dropsh...')
#9 /www/web/dropship/vendor/yiisoft/yii2/base/View.php(250): yii\base\View->renderPhpFile('/www/web/dropsh...', Array)
#10 /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php(249): yii\base\View->renderFile('@yii/views/erro...', Array, Object(yii\web\ErrorHandler))
#11 /www/web/dropship/vendor/yiisoft/yii2/web/ErrorHandler.php(116): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
#12 /www/web/dropship/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\web\ErrorHandler->renderException(Object(yii\mongodb\Exception))
#13 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\mongodb\Exception))
#14 {main}
Previous exception:
exception 'MongoDB\Driver\Exception\RuntimeException' with message 'Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.' in /www/web/dropship/vendor/yiisoft/yii2-mongodb/Command.php:187
Stack trace:
#0 /www/web/dropship/vendor/yiisoft/yii2-mongodb/Command.php(187): MongoDB\Driver\Server->executeCommand('dropship', Object(MongoDB\Driver\Command))
#1 /www/web/dropship/vendor/yiisoft/yii2-mongodb/Command.php(732): yii\mongodb\Command->execute()
#2 /www/web/dropship/vendor/yiisoft/yii2-mongodb/Collection.php(360): yii\mongodb\Command->aggregate('<span class="st...', '[[<span class="...', '[]')
#3 /www/web/dropship/vendor/fancyecommerce/fecshop/services/product/ProductMongodb.php(537): yii\mongodb\Collection->aggregate('[[<span class="...')
#4 /www/web/dropship/vendor/fancyecommerce/fecshop/services/Product.php(340): fecshop\services\product\ProductMongodb->getFrontCategoryProducts('[<span class="s...')
#5 [internal function]: fecshop\services\Product->actionGetFrontCategoryProducts('[<span class="s...')
#6 /www/web/dropship/vendor/fancyecommerce/fecshop/services/Service.php(48): call_user_func_array('[<span class="t...', '[[<span class="...')
#7 /www/web/dropship/vendor/fancyecommerce/fecshop/services/category/Product.php(74): fecshop\services\Service->__call('<span class="st...', '[[<span class="...')
#8 /www/web/dropship/vendor/fancyecommerce/fecshop/services/category/Product.php(74): fecshop\services\Product->getFrontCategoryProducts(Array)
#9 [internal function]: fecshop\services\category\Product->actionGetFrontList(Array)
#10 /www/web/dropship/vendor/fancyecommerce/fecshop/services/Service.php(48): call_user_func_array(Array, Array)
#11 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/category/Index.php(385): fecshop\services\Service->__call('getFrontList', Array)
#12 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/category/Index.php(385): fecshop\services\category\Product->getFrontList(Array)
#13 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/category/Index.php(48): fecshop\app\appfront\modules\Catalog\block\category\Index->getCategoryProductColl()
#14 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/controllers/CategoryController.php(30): fecshop\app\appfront\modules\Catalog\block\category\Index->getLastData()
#15 [internal function]: fecshop\app\appfront\modules\Catalog\controllers\CategoryController->actionIndex()
#16 /www/web/dropship/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#17 /www/web/dropship/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#18 /www/web/dropship/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('index', Array)
#19 /www/web/dropship/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('catalog/categor...', Array)
#20 /www/web/dropship/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(fecshop\yii\web\Request))
#21 /www/web/dropship/appfront/web/index.php(68): yii\base\Application->run()
#22 {main}

Next exception 'yii\mongodb\Exception' with message 'Sort exceeded memory limit of 104857600 bytes, but did not opt in to external sorting. Aborting operation. Pass allowDiskUse:true to opt in.' in /www/web/dropship/vendor/yiisoft/yii2-mongodb/Command.php:193
Stack trace:
#0 /www/web/dropship/vendor/yiisoft/yii2-mongodb/Command.php(732): yii\mongodb\Command->execute()
#1 /www/web/dropship/vendor/yiisoft/yii2-mongodb/Collection.php(360): yii\mongodb\Command->aggregate('<span class="st...', '[[<span class="...', '[]')
#2 /www/web/dropship/vendor/fancyecommerce/fecshop/services/product/ProductMongodb.php(537): yii\mongodb\Collection->aggregate('[[<span class="...')
#3 /www/web/dropship/vendor/fancyecommerce/fecshop/services/Product.php(340): fecshop\services\product\ProductMongodb->getFrontCategoryProducts('[<span class="s...')
#4 [internal function]: fecshop\services\Product->actionGetFrontCategoryProducts('[<span class="s...')
#5 /www/web/dropship/vendor/fancyecommerce/fecshop/services/Service.php(48): call_user_func_array('[<span class="t...', '[[<span class="...')
#6 /www/web/dropship/vendor/fancyecommerce/fecshop/services/category/Product.php(74): fecshop\services\Service->__call('<span class="st...', '[[<span class="...')
#7 /www/web/dropship/vendor/fancyecommerce/fecshop/services/category/Product.php(74): fecshop\services\Product->getFrontCategoryProducts(Array)
#8 [internal function]: fecshop\services\category\Product->actionGetFrontList(Array)
#9 /www/web/dropship/vendor/fancyecommerce/fecshop/services/Service.php(48): call_user_func_array(Array, Array)
#10 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/category/Index.php(385): fecshop\services\Service->__call('getFrontList', Array)
#11 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/category/Index.php(385): fecshop\services\category\Product->getFrontList(Array)
#12 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/block/category/Index.php(48): fecshop\app\appfront\modules\Catalog\block\category\Index->getCategoryProductColl()
#13 /www/web/dropship/vendor/fancyecommerce/fecshop/app/appfront/modules/Catalog/controllers/CategoryController.php(30): fecshop\app\appfront\modules\Catalog\block\category\Index->getLastData()
#14 [internal function]: fecshop\app\appfront\modules\Catalog\controllers\CategoryController->actionIndex()
#15 /www/web/dropship/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#16 /www/web/dropship/vendor/yiisoft/yii2/base/Controller.php(156): yii\base\InlineAction->runWithParams(Array)
#17 /www/web/dropship/vendor/yiisoft/yii2/base/Module.php(523): yii\base\Controller->runAction('index', Array)
#18 /www/web/dropship/vendor/yiisoft/yii2/web/Application.php(102): yii\base\Module->runAction('catalog/categor...', Array)
#19 /www/web/dropship/vendor/yiisoft/yii2/base/Application.php(380): yii\web\Application->handleRequest(Object(fecshop\yii\web\Request))
#20 /www/web/dropship/appfront/web/index.php(68): yii\base\Application->run()
#21 {main}
共收到 2 条回复
water#16年前 0 个赞

这个部分进行了优化,需要添加一定的索引。

@fecshop\models\mongodb\Product.php

更改索引:

public static function create_index()
    {
        $indexs = [
            ['spu'        => -1],
            ['sku'        => -1],
            ['category' => -1,'score'           => 1],
            ['category' => -1,'review_count'    => 1],
            ['category' => -1,'favorite_count'  => 1],
            ['category' => -1,'created_at'      => 1],
            ['category' => -1,'final_price'     => 1],
        ];

        $options = ['background' => true];
        foreach ($indexs as $columns) {
            self::getCollection()->createIndex($columns, $options);
        }
    }

新版本会更新上去。

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics