Giter Site home page Giter Site logo

fastmongo's Introduction

fastmongo's People

Contributors

jword avatar leocavalcante avatar reasno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fastmongo's Issues

failed, Error: Exec format error[8]

Warning: Swoole\Process::exec(): execv(/bhshejiao/vendor/bin/mongo-proxy-linux-amd64) failed, Error: Exec format error[8] in /bhshejiao/vendor/hyperf/gotask/src/Process/GoTaskProcess.php on line 65

3.x 版本查询条件 非 limit=1时 结果不符合预期

$collection = $mongo->database('supsite')->collection('data_article');
$data          = $collection->find(['siteid' => $siteid], ['skip'=>0,'limit'=>15]);
var_dump(count($data));

collection 实际570条数据 limit = 1 时查出的数据正常 但limit 15 return 了全部数据 570

文件权限问题

PHP Warning: Swoole\Process::exec(): execv(/data/wwwroot/xx/vendor/bin/mongo-proxy-linux-amd64) failed, Error: Permission denied[13] in /data/wwwroot/xxx/vendor/hyperf/gotask/src/Process/GoTaskProcess.php on line 65
在使用fastmongo的时候报这个错,麻烦告知下错误
1
2

missing .sock when use Hyperf command

在Controller 中 MongoClient 正常使用.

但在 Hyperf Command 中. 就發生錯誤,

我已經使用一個全新的Hyperf 2.0去測試這問題, ,

發現每當運行 php bin/hyperf.php start 時.. 都會在/tmp /中建立一個 {app name}_{XXXX}.sock 的file .

但運行Hyperf Command時, tmp /中 並沒有新增相關的sock file. 而出現以下錯誤.

[WARNING] RemoteGoTask::__call failed, because unable to establish connection unix:///tmp/skeleton_5f363719a4f47.sock PHP Fatal error: Uncaught Spiral\Goridge\Exceptions\RelayException: No such file or directory (2) in /hyperf-skeleton/vendor/hyperf/gotask/src/Relay/CoroutineSocketRelay.php:134

以下是composer.json

"require": { "php": ">=7.2", "ext-swoole": ">=4.5", "hyperf/cache": "~2.0.0", "hyperf/command": "^2.0", "hyperf/config": "~2.0.0", "hyperf/db-connection": "~2.0.0", "hyperf/framework": "~2.0.0", "hyperf/guzzle": "~2.0.0", "hyperf/http-server": "~2.0.0", "hyperf/logger": "~2.0.0", "hyperf/memory": "~2.0.0", "hyperf/process": "~2.0.0", "hyperf/redis": "~2.0.0", "hyperf/async-queue": "~2.0.0", "reasno/fastmongo": "^0.2.1" },

有较完整的文档吗

readme里面的例子太少了,且都是普通查询相关的,别的一些聚合操作,函数都没有。请问有更完整一些的文档吗。

可否格式化一下返回值内的_id对象?

首先感谢作者的辛苦努力,非常高效。
但是在使用过程中,获得_id 字符串实在很费力。

例如获取插入后的_id,恕我能力太差,实在不知道这个对象在PHP下怎么快速得到一个string的_id。

这里用协程调用是这样子写吗,比直接for循环还慢很多

协程

<?php
        $max = 10000;
        $co = new Coroutine\Concurrent(10);

        $startTime = microtime(true);
            for ($i=0; $i<$max; $i++){
                $co->create(function() {
                    $condtion = ['adset_id' => '111'.rand(1, 10000)];
                    $data = ['adset_id' => '111', 'test'=> rand(1, 10000)];
                    try {
                        $this->mongoClient->updateByCondition($condtion, $data);
                    } catch (\Exception $e){
                        return $this->json(500, ['error'=>$e->getMessage()]);
                    }
                });


            }

        $endTime = microtime(true);
        $time = $endTime - $startTime;

直接for循环

<?php
        $max = 10000;
        $co = new Coroutine\Concurrent(10);

        $startTime = microtime(true);
            for ($i=0; $i<$max; $i++){
                $co->create(function() {
                    $condtion = ['adset_id' => '111'.rand(1, 10000)];
                    $data = ['adset_id' => '111', 'test'=> rand(1, 10000)];
                    try {
                        $this->mongoClient->updateByCondition($condtion, $data);
                    } catch (\Exception $e){
                        return $this->json(500, ['error'=>$e->getMessage()]);
                    }
                });


            }

        $endTime = microtime(true);
        $time = $endTime - $startTime;

直接for循环40多秒写完,用协程调用一直卡着

findOne方法查不到数据会报错误

[WARNING] RemoteGoTask::__call failed, because error 'error while executing mongo command: mongo: no documents in result' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'
[ERROR] error 'error while executing mongo command: mongo: no documents in result' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'[123] in /www_home/modocenter-server_push/vendor/spiral/goridge/src/RPC.php
[ERROR] #0 /www_home/modocenter-server_push/vendor/spiral/goridge/src/RPC.php(107): Spiral\Goridge\RPC->handleBody()
#1 /www_home/modocenter-server_push/vendor/hyperf/gotask/src/IPC/SocketIPCSender.php(55): Spiral\Goridge\RPC->call()
#2 /www_home/modocenter-server_push/vendor/hyperf/gotask/src/GoTaskConnection.php(89): Hyperf\GoTask\IPC\SocketIPCSender->call()
#3 /www_home/modocenter-server_push/vendor/hyperf/gotask/src/GoTaskConnection.php(50): Hyperf\GoTask\GoTaskConnection->retry()
#4 /www_home/modocenter-server_push/vendor/hyperf/gotask/src/SocketGoTask.php(41): Hyperf\GoTask\GoTaskConnection->__call()

数据库更新失败

$result = $this->db->collection('xxx')->updateOne(['_id'=> ‘xxxxx’], ['$set'=> ['fd'=> 'xxxx']]);

这样做,更新不成功,麻烦告诉下,谢谢
Hyperf\GoTask\MongoClient\Type\UpdateResult Object
(
[matchedCount:Hyperf\GoTask\MongoClient\Type\UpdateResult:private] => 0
[modifiedCount:Hyperf\GoTask\MongoClient\Type\UpdateResult:private] => 0
[upsertedCount:Hyperf\GoTask\MongoClient\Type\UpdateResult:private] => 0
[upsertedId:Hyperf\GoTask\MongoClient\Type\UpdateResult:private] =>
)
这个是打印的$result返回值
确定updateOne里面的数据是无误的
我试过用其他字段修改是成功的,但是改用 _id 之后就不行了

调用 find() 方法报错:error '{rawData} request for <*mongo_client.FindCmd Value>' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'

按照说明引入了该包,使用依赖注入引入 MongoClient,如下调用:

class IndexController extends AbstractController
{
    /**
     * @Inject()
     * @var MongoClient
     */
    private MongoClient $mongoClient;

    public function index()
    {
        $user = $this->request->input('user', 'Megalodon');
        $method = $this->request->getMethod();

        return [
            'method' => $method,
            'message' => "Hello {$user}.",
            'test' => $this->mongoClient->credit->test,// 空对象
            'test2' => $this->mongoClient->credit->test->find(),// 报错
        ];
    }
}

完整错误信息:

[WARNING] RemoteGoTask::__call failed, because error '{rawData} request for <*mongo_client.FindCmd Value>' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'
[ERROR] error '{rawData} request for <*mongo_client.FindCmd Value>' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'[123] in /www/credit-model-backend/vendor/spiral/goridge/src/RPC.php

Mongo连接问题

想问下通过边车进程的连接有连接池的概念吗,我在循环写入(1w左右)mongo集合的时候回碰到这种错误,好像大概率是因为连接数的问题导致的。

RemoteGoTask::__call failed, because error 'error while executing mongo command: connection(xxx-ip) incomplete read of message header: EOF' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'

Spiral\Goridge\Exceptions\ServiceException : error 'error while executing mongo command: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: xxx, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : dial tcp xxx: connect: connection refused }, { Addr: xxx, Type: RSSecondary, State: Connected, Average RTT: 14362421 }, ] }' on 'Hyperf\GoTask\Relay\CoroutineSocketRelay'

开启的时候报错

执行 php bin/hyperf.php vendor:publish reasno/fastmongo时候报/hyperf-project/config/autoload/mongodb.php] already exists错误

求助findOne 不返回 _id

求助,findOne 怎么返回指定字段,不返回_id
$col->findOne(['account' => '小米'],['account'=>1,'_id'=>0]); 这样写没有起效果。

MongoDB连接报错:unable to authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed)

报错:

error while executing mongo command: connection() : auth error: sasl conversation error: unable to authenticate using mechanism \"SCRAM-SHA-256\": (AuthenticationFailed) Authentication failed.

而且本地 docker 和线上 docker 配置是一样的,本地曾经出现过这个问题,但是是因为把 host 写成了 127.0.0.1 而不是 docker 容器名,本地改了就好了。但线上怎么改都有这个问题。

  • 连接地址格式:mongodb://user:[email protected]:27017
  • 已尝试把密码改成最简单的 123456
  • 已尝试把连接 host 改为 mongodb 的容器名(连接时提示unable to authenticate using mechanism \"SCRAM-SHA-256\": (AuthenticationFailed)
  • 已尝试把连接 host 改为 127.0.0.1(连接时提示超时)
  • 已将包版本升级至 0.2.6

MongoDB版本:4.1
Hyperf 版本:2.2

时不时会出现:链接被拒绝的报错

时不时会出现:链接被拒绝的报错
[WARNING] RemoteGoTask::__call failed, because unable to establish connection tcp://127.0.0.1:6001: Connection refused (111) [ERROR] Spiral\Goridge\Exceptions\RelayException: unable to establish connection tcp://127.0.0.1:6001: Connection refused (111)(0) in phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/Relay/CoroutineSocketRelay.php:137 Stack trace: #0 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/Relay/SocketTransporter.php(35): Hyperf\GoTask\Relay\CoroutineSocketRelay->connect() #1 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/spiral/goridge/src/RPC.php(48): Hyperf\GoTask\Relay\CoroutineSocketRelay->send() #2 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/IPC/SocketIPCSender.php(55): Spiral\Goridge\RPC->call() #3 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/GoTaskConnection.php(89): Hyperf\GoTask\IPC\SocketIPCSender->call() #4 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/GoTaskConnection.php(50): Hyperf\GoTask\GoTaskConnection->retry() #5 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/SocketGoTask.php(41): Hyperf\GoTask\GoTaskConnection->__call() #6 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/GoTaskProxy.php(39): Hyperf\GoTask\SocketGoTask->call() #7 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/MongoClient/MongoProxy.php(76): Hyperf\GoTask\GoTaskProxy->call() #8 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/gotask/src/MongoClient/Collection.php(84): Hyperf\GoTask\MongoClient\MongoProxy->find() #9 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/app/Mongo/Base.php(64): Hyperf\GoTask\MongoClient\Collection->find() #10 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/runtime/container/proxy/App_Process_CommonQueue.proxy.php(197): App\Mongo\Base->find() #11 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/runtime/container/proxy/App_Process_CommonQueue.proxy.php(45): App\Process\CommonQueue->check_state() #12 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/runtime/container/proxy/App_Process_CommunityQueue.proxy.php(56): App\Process\CommonQueue->handle() #13 phar:///www_home/modocenter-server_push/modocenter-push-v5.0.10.phar/vendor/hyperf/process/src/AbstractProcess.php(134): App\Process\CommunityQueue->handle() #14 {main}
php 版本信息
PHP 7.4.24 (cli) (built: Oct 3 2021 19:22:29) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Yasd v0.3.9-alpha, Our Copyright, by codinghuang

swoole 信息
`swoole

Swoole => enabled
Author => Swoole Team [email protected]
Version => 4.8.0
Built => Oct 15 2021 14:01:04
coroutine => enabled with boost asm context
epoll => enabled
eventfd => enabled
signalfd => enabled
cpu_affinity => enabled
spinlock => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.0.2k-fips 26 Jan 2017
http2 => enabled
json => enabled
curl-native => enabled
pcre => enabled
zlib => 1.2.7
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.