Git Product home page Git Product logo

raku-mongodb-driver's Introduction

Leaf MongoDB Driver for Raku

T A L

Documentation

INSTALLING THE MODULES

Use zef to install the package.

zef install MongoDB

AUTHORS

  • Original creator of the modules is Paweล‚ Pabian (2011-2015, v0.6.0)(bbkr on github)
  • Current maintainer Marcel Timmerman (2015-present) (MARTIMM on github)

Contributors

  • Dan Zwell (lefth on github)
  • David Golden, who has pointed me to important documents he has developed together with a MongoDB team. It's about guide lines for server discovery and building up a topology of the servers seeded from the url.

raku-mongodb-driver's People

Contributors

bbkr avatar martimm avatar samcv avatar szabgab avatar zoffixznet avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

raku-mongodb-driver's Issues

Object-to-Wire model discussion

At the early stage of development of Mongo DB Perl 6 driver I stepped into the same problem that every language solved differently - how to separate Wire document(s) from Wire options.

For example

  • Python flattens everything in huge messy list of params

insert(doc_or_docs[, manipulate=True[, safe=False[, check_keys=True[, **kwargs]]]])

find([spec=None[, fields=None[, skip=0[, limit=0[, timeout=True[, snapshot=False[, tailable=False[, sort=None[, max_scan=None[, as_class=None[, slave_okay=False[, await_data=False[, partial=False[, manipulate=True[, **kwargs]]]]]]]]]]]]]]])

  • Perl 5 is inconsistent, because it sometimes flattens

$coll->insert({ name => 'mongo', type => 'database' }, {safe => 1});

and sometimes chains

$cursor = $coll->query->limit($per_page)->skip($page_num * $per_page);

making it hard to understand type of object returned and when actual query to database takes place.

  • Perl 6 gives tons of new capabilities when it comes to method signatures, overloading and dispatching. Logic behind my idea of interface is that I want to keep simple things simple.

For example $collection.insert( %document1, %document2 ) is the most natural way of inserting multiple documents (note that Perl 6 does not flatten it the same way as Perl 5).

However slurpy parameters must appear last, and that would require placing options before them
$collection.insert(:continue_on_error, %document1, %document2) # note the bool flags in Perl 6
or giving up on them
$collection.insert( [%document1, %document2], :continue_on_error)
and this array wrapping I personally dislike.

In my humble opinion closures are the way to go. Some examples:

$collection.insert(:continue_on_error).(%document1, %document2)
or without options
$collection.insert.(%document1, %document2)
or reuse closure
my $feeder = $collection.insert(:continue_on_error);
$feeder.(%document1, %document2)
$feeder.(%document3)

my $cursor = $collection.find(limit=>20, fields=>['name', 'age'] ).()
yes, this is correct, many problems are solved if cursor object instance is returned from closure, not directly from collection
$collection.find.(nick=>'bbkr')
throwing options to closure removes nasty hash wrapping here, this is my nice-to-have

Benefits:

  • closures are fast, whole Perl 6 is closure based
  • closures allow to "BSONize" some parts of Wire protocol fields and reuse them changing only %document(s)
  • your query is executed when closure is executed, clear rules on that

Problems:

  • many users will forget to call closure, but since we have awesome where{} blocks in subroutine signatures we can detect $collection.insert( %document1, %document2 ) case and assume one wants $collection.insert.( %document1, %document2 ) with very small performance impact, beginners will be happy, hackers can still use Wire options.

Please share your thoughts.

Advice / Idea on how to Improve Insert / Update performance

Hi,
I'd like to get your opinion about this so I'm trying to increase the insert speed in my program but when I create a channel and then create multiple promises to dequeue the channel it seems to block but I don't understand why ...
Here is my small code to create promise to dequeue the mongo channel.

my $mongoc = {
  react
    whenever $mongoq {
#      say $_;
      $k++;
      mongoStore($_);
    }
  }
};
my @mongop;
do { @mongop.push: Promise.start($mongoc) for 1..1 };

Below is my code to insert data in Mongo with a specific field is the entry exist or not. $hr contains the final hash of data to be stored in Mongo. So my problem is that all of this working fine for 1 promise but as soon as I start 2 or more then only one entry is stored. After some debugging it seems that this behavior is only triggered when you call mongoStore so it seems there might be some issue when the run-command is used in // ?

sub mongoStore (Hash $h) {
  my $sub=callframe.code.name;
  my $host=$h<host>;
  my $port=$h<port>;
  my $start=DateTime.now;
  my ($countperf,$packperf,$insertperf);
  $req .= new: (count => $col.name, query => (:$host, :$port),);
  my $doc;
  try {
    $doc=$db.run-command($req);
    $countperf=DateTime.now - $start;
    if ($doc<n> eq 0) {
      $h<ctime>=DateTime.now;
    }
    else {
      $h<mtime>=DateTime.now;
    }
    CATCH {
      default {
        say "$sub count exception: ",.^name, 'โ†’ ', .Str , " host: $h<host> port: $h<port>";
      }
    }
  }
my $hr= {
    :host($h<host>),
    :port($h<port>),
  };
$hr<ip>=$h<ip> if $h<ip>;
my $uq=(
    q => (:$host, :$port,),
    u => ('$set' => @($hr)),
    upsert => True,
  );
  # say $uq;
  $req .= new: (update => $col.name, updates => [$uq]);
  try {
    $db.run-command($req);
    CATCH {
      default {
        say "$sub update exception: ",.^name, 'โ†’ ', .Str , " ip: $h<ip> port: $h<port>";
      }
    }
  }
  $insertperf=DateTime.now - $start;

Do you have any idea how to improve performance / solve the concurrency issue ?

MongoDB::Wire can't inherit from BSON

Running the tests via prove -lr --exec="perl6 -Ilib" t gives many test failures with the following error message:

===SORRY!=== Error while compiling /home/cochrane/Projekte/OSSProjekte/mongo-perl6-driver/lib/MongoDB/Wire.pm
BSON does not support inheritance, so MongoDB::Wire cannot inherit from it
at /home/cochrane/Projekte/OSSProjekte/mongo-perl6-driver/lib/MongoDB/Wire.pm:9

I see that the latest commit to the repo is two days ago, so I'm guessing I'm doing something wrong here by running the tests like this. Nevertheless, I thought it a good idea to let you know about the issue. BSON was installed via panda install BSON.

My perl6 version is:

$ perl6 --version
This is perl6 version 2015.09-383-gf0d4820 built on MoarVM version 2015.09-85-g3a00a08

Cheers,

Paul

login and logout

Users can be added but users can not yet login. Two methods must be supported, mongodb-cr and scram-sha1. There are other methods which come later

zef install: MongoDB fails

Note the failure is when using the very latest rakudo (branch nom) with bumps to nqp and MoarVM:
perl6 -v:

This is Rakudo version 2017.06-45-g86e7b2b built on MoarVM version 2017.06-13-g7405dfa
implementing Perl 6.c.

===> Testing: MongoDB:ver('0.37.3')

# Failed test 'Server selected'
# at t/110-Client.t line 62

# Failed test 'Status of server is SS-Unknown'
# at t/110-Client.t line 64
# expected: 'SS-Standalone'
#      got: 'SS-Unknown'

# Failed test 'Topology TT-Unknown'
# at t/110-Client.t line 67
# expected: 'TT-Single'
#      got: 'TT-Unknown'
# Looks like you failed 3 tests of 3

[... and more failures]

test 401-rc-query occasional socket mixup

Sometimes there is a mixup of sockets mixing up in other threads. Below is an example output.

> prove6 -v t/401-rc-query-write.t
...
    ok 1 - insert request ok
    ok 2 - inserted 1 document
 1 2016-07-22 18:25:56 [D] run command insert
5 total sockets open: 0
5 open socket
1 total sockets open: 0
1 open socket
 5 2016-07-22 18:25:56 [T] open socket
 1 2016-07-22 18:25:56 [T] open socket
 5 2016-07-22 18:25:56 [D] socket send, size: 58
 1 2016-07-22 18:25:56 [D] socket send, size: 347
 5 2016-07-22 18:25:56 [D] socket receive, sizes: request=4, received=4
 1 2016-07-22 18:25:56 [D] socket receive, sizes: request=4, received=4
 5 2016-07-22 18:25:56 [D] socket receive, sizes: request=190, received=190
 1 2016-07-22 18:25:56 [T] close socket
Tried to read() on a socket from outside its originating thread
  in method receive at /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Server/Socket.pm6 (MongoDB::Server::Socket) line 51
  in method get-bytes at /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Wire.pm6 (MongoDB::Wire) line 270
  in method query at /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Wire.pm6 (MongoDB::Wire) line 65
  in method find at /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Collection.pm6 (MongoDB::Collection) line 111
  in method run-command at /home/marcel/Languages/Perl6/Projects/mongo-perl6-driver/lib/MongoDB/Database.pm6 (MongoDB::Database) line 81
  in block <unit> at t/401-rc-query-write.t line 78
...

Couldn't install

Hi. I did panda install MongoDB and it came back with this below, can you please help me find out what is the actual problem? tx

ubuntu@ip-172-31-47-63:~/dev/futs$ panda install MongoDB
OpenSSL provides the requested OpenSSL::Digest
URI provides the requested URI::Escape
==> MongoDB depends on Auth::SCRAM, Base64, OpenSSL
OpenSSL provides the requested OpenSSL::Digest
PKCS5 provides the requested PKCS5::PBKDF2
==> Auth::SCRAM depends on OpenSSL, Base64, PKCS5
OpenSSL provides the requested OpenSSL::Digest
==> PKCS5 depends on OpenSSL
==> Fetching OpenSSL
==> Building OpenSSL
==> Testing OpenSSL
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
in method setup at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 306
in method CALL-ME at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 317
in method new at /home/ubuntu/dev/futs/.panda-work/1474229756_1/lib/OpenSSL.pm6 (OpenSSL) line 36
in block at t/01-basic.t line 6

t/01-basic.t ...........
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 9/9 subtests
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
in method setup at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 306
in method CALL-ME at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 317
in method new at /home/ubuntu/dev/futs/.panda-work/1474229756_1/lib/OpenSSL.pm6 (OpenSSL) line 36
in sub fetch at t/02-socket.t line 24
in block at t/02-socket.t line 6

t/02-socket.t ..........
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 4/4 subtests
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
in method setup at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 306
in method CALL-ME at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 317
in method new at /home/ubuntu/dev/futs/.panda-work/1474229756_1/lib/OpenSSL/RSATools.pm6 (OpenSSL::RSATools) line 20
in block at t/03-rsa.t line 10

t/03-rsa.t .............
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 8/8 subtests
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
in method setup at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 306
in method CALL-ME at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 317
in sub encrypt at /home/ubuntu/dev/futs/.panda-work/1474229756_1/lib/OpenSSL/CryptTools.pm6 (OpenSSL::CryptTools) line 9
in block at t/04-crypt.t line 10

Looks like you planned 11 tests, but ran 1

t/04-crypt.t ...........
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 10/11 subtests
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
in method setup at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 306
in method CALL-ME at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 317
in sub sha1 at /home/ubuntu/dev/futs/.panda-work/1474229756_1/lib/OpenSSL/Digest.pm6 (OpenSSL::Digest) line 22
in block at t/05-digest.t line 8

t/05-digest.t ..........
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 3/3 subtests
Cannot locate native library 'libssl.so': libssl.so: cannot open shared object file: No such file or directory
in method setup at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 306
in method CALL-ME at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/sources/24DD121B5B4774C04A7084827BFAD92199756E03 (NativeCall) line 317
in method new at /home/ubuntu/dev/futs/.panda-work/1474229756_1/lib/OpenSSL.pm6 (OpenSSL) line 36
in block at t/10-client-ca-file.t line 6

t/10-client-ca-file.t ..
Dubious, test returned 255 (wstat 65280, 0xff00)
Failed 7/7 subtests

Test Summary Report

t/01-basic.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 9 tests but ran 0.
t/02-socket.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 4 tests but ran 0.
t/03-rsa.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 8 tests but ran 0.
t/04-crypt.t (Wstat: 65280 Tests: 1 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 11 tests but ran 1.
t/05-digest.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 3 tests but ran 0.
t/10-client-ca-file.t (Wstat: 65280 Tests: 0 Failed: 0)
Non-zero exit status: 255
Parse errors: Bad plan. You planned 7 tests but ran 0.
Files=6, Tests=1, 26 wallclock secs ( 0.03 usr 0.00 sys + 24.38 cusr 1.12 csys = 25.53 CPU)
Result: FAIL
The spawned process exited unsuccessfully (exit code: 1)
in sub run-and-gather-output at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/24811C576EF8F85E7672B26955C802BB2FC94675 (Panda::Common) line 85
in block at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/48E2EB9144E069353B240AD2D147B48C65F70152 (Panda::Tester) line 22
in sub indir at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/24811C576EF8F85E7672B26955C802BB2FC94675 (Panda::Common) line 20
in method test at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/48E2EB9144E069353B240AD2D147B48C65F70152 (Panda::Tester) line 5
in method install at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 156
in block at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 229
in method resolve at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/sources/582CB7486602954A4601BDCE5A0EAC54B05DA58A (Panda) line 223
in sub MAIN at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 line 18
in block at /home/ubuntu/rakudo/rakudo-star-2016.07/install/share/perl6/site/resources/E0D978079BB5081DE986D058BB8AB08252F05CC8 line 151

rakudo 2012.02 panda install failure

With rakudo 2012.02, running 'panda install MongoDB' results in the following test error (once per test file):

===SORRY!===
Virtual call $.collection may not be used on partially constructed objects
at lib/MongoDB/Cursor.pm:15

Client class uses too many threads permanently

A Client object needs a thread to check for new servers in case of replica set servers and others. This mostly does not change a lot when all servers are detected and this thread should stop then. Periodic checks should be sufficient later e.g. when requesting for a Server object.

The Server object created by the Client is also taking a thread to monitor a mongo server to see if it is still there or to monitor any changes. This means for every server there is one thread. This can all be done by one monitoring thread for all servers.

So in case of a master replica set server, two slave servers and an arbiter would take up 5 threads!

Tests fails as it cannot launch mongodb server

Trying to install on Rakudo Star 2017.04 in the rakudo-star Docker image I get the error below.
It might be some issue with the mongodb server installed, or some interaction with the Docker image.

Any command I should execute to help finding the source of the problem?

2017-06-15 14:20:34.989772 [F]  1: The spawned command '/usr/bin/mongod --dbpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server1/m.data --port=65010 --fork --logappend --logpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server1/m.log --smallfiles --pidfilepath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server1/m.pid --oplogSize=128 --verbose=vv --nojournal' exited unsuccessfully (exit code: 1). At ./lib/MongoDB/Server/Control.pm6 (MongoDB::Server::Control):45
t/099-mk-sandbox.t ......1/?2017-06-15 14:20:35.624151 [F]  1: The spawned command '/usr/bin/mongod --dbpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server2/m.data --port=65011 --fork --logappend --logpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server2/m.log --smallfiles --pidfilepath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server2/m.pid --oplogSize=128 --verbose=vv --nojournal' exited unsuccessfully (exit code: 1). At ./lib/MongoDB/Server/Control.pm6 (MongoDB::Server::Control):45
t/099-mk-sandbox.t ......2/?2017-06-15 14:20:36.184927 [F]  1: The spawned command '/usr/bin/mongod --dbpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server3/m.data --port=65012 --fork --logappend --logpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server3/m.log --smallfiles --pidfilepath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server3/m.pid --oplogSize=128 --verbose=vv --nojournal' exited unsuccessfully (exit code: 1). At ./lib/MongoDB/Server/Control.pm6 (MongoDB::Server::Control):45
2017-06-15 14:20:36.841302 [F]  1: The spawned command '/usr/bin/mongod --dbpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server1/m.data --port=65010 --fork --logappend --logpath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server1/m.log --smallfiles --pidfilepath=/root/.zef/store/mongo-perl6-driver.git/b065ef515c30ce3b4f645df60b3e4638492d75e0/Sandbox/Server1/m.pid --oplogSize=128 --verbose=vv --nojournal' exited unsuccessfully (exit code: 1). At ./lib/MongoDB/Server/Control.pm6 (MongoDB::Server::Control):45

From that point on all the tests seem to fail:

t/099-mk-sandbox.t ...... ok
Failed to connect: connection refused

Add support for mongodb+srv connection string

Hi Marcel,
I'm trying to connect to MongoDB Atlas instance but it's required to use a connection string like this one:
Parsing error in url 'mongodb+srv://user:[email protected]/?retryWrites=true&w=majority'
but the current driver don'ts know how to handle this connection and complains with this:
2024-02-25 19:11 UTC 58.886576 [F][1][Uri][380]: Parsing error in url 'mongodb+srv://host.o9jgs.mongodb.net/?retryWrites=true&w=majority'
Would you be able to add support for this ? Or tell me how I can workaround this ?

Thanks a lot.

unfinished tests and hangups

On travis there have been several events which makes the package unreliable. Some tests didn't finish and others are hanging. It must be something with concurrency used on several places. This is difficult to pinpoint the sore spots.

Uri class does not accept ipv6 addresses

ipv4 is accepted as well as hostnames. The problem is also that the syntax cannot cope with the ip6 spec. According to Wikipedia and StackOverflow, the following must be written and accepted E.g. a localhost address ::1 must then be written as [::1]:27017. So a url can then be specified as mongodb://[::1]:27017.

The Server class also needs a change here and there to cope with ipv6 but that will be small

Failed to connect: connection refused

I copy-pasted the first part of the example in the README till the first run-comand and ran the script. I got:

Failed to connect: connection refused
  in method open at /usr/share/perl6/site/sources/5AE1A383104B2204E0D49C98A4764DC550EB8763 (MongoDB::Server::Socket) line 59
  in method get-socket at /usr/share/perl6/site/sources/9C204975B90DE157AA4A198A645BD8AB21804B36 (MongoDB::Server) line 317
  in method query at /usr/share/perl6/site/sources/75DA101655DA0DF9F1B052F6D9017F3AA3E589B2 (MongoDB::Wire) line 57
  in method timed-query at /usr/share/perl6/site/sources/75DA101655DA0DF9F1B052F6D9017F3AA3E589B2 (MongoDB::Wire) line 27
  in method raw-query at /usr/share/perl6/site/sources/9C204975B90DE157AA4A198A645BD8AB21804B36 (MongoDB::Server) line 393
  in block  at /usr/share/perl6/site/sources/320020F919BC24BC1A155DE05C66B59D9FED6B21 (MongoDB::Server::Monitor) line 95

2017-06-15 15:42:09.792451 [E]  3: Server localhost:27017 error Failed to connect: connection refused. At site#sources.320020F919BC24BC1A155DE05C66B59D9FED6B21 (MongoDB::Server::Monitor):155

several times till I stopped it with Ctrl-C.

At the same time:

# mongo 127.0.0.1/27017
MongoDB shell version: 2.4.10
connecting to: 127.0.0.1/27017
> exit
bye

this is:

# perl6 -v
This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda
implementing Perl 6.c.

The MongoDB module was installed using the force because #16.

I wonder what could be the problem.

Add support for mongoDB 6.0

This driver is using a deprecated OP_QUERY operation that is not anymore supported by MongoDB 6.0.
Can you update the driver to use OP_MSG instead which is the new supported method see this

$collection.insert is not implemented?

use BSON::Document;
use MongoDB::Client;

my $client = MongoDB::Client.new(:uri('mongodb://'));
my $database = $client.database('myProject');

my MongoDB::Collection $collection = $database.collection('people');
$collection.insert: (
    name => "Foo Bar",
);

gives me

No such method 'insert' for invocant of type 'MongoDB::Collection'. Did you mean 'invert'?

I know there are other ways to insert a document, but I wonder if this should be also included as this seems to be the method used in the MongoDB API.

hangup in test 100

test 100

...
 9 2016-07-23 20:50:50 [D] socket send, size: 58
 9 2016-07-23 20:50:50 [D] socket receive, request size 4
 9 2016-07-23 20:50:50 [D] socket receive, received size 4
 9 2016-07-23 20:50:50 [D] socket receive, request size 190
 9 2016-07-23 20:50:50 [D] socket receive, received size 190
 9 2016-07-23 20:50:50 [T] close socket
 9 2016-07-23 20:50:50 [D] Weighted mean RTT: 0.012535 for server localhost:65012
9 W s-status lock
9 W s-status locked
9 W s-status block writers
9 W s-status block writers continue
9 W s-status run code
9 set status
9 W s-status accept other writers
9 W s-status unlock
9 W s-status unlocked
9 W unlock called
    ok 2 - Monitoring is ok
    ok 3 - Weighted mean is 0.012535
    ok 4 - Ok response from server
    ok 5 - Is master
9 W s-select lock
9 W s-select locked
9 W s-select block writers
9 W s-select block writers continue
9 W s-select run code
9 total sockets open: 0 of 1
9 W s-select accept other writers
9 W s-select unlock
9 W s-select unlocked
9 W unlock called
 9 2016-07-23 20:50:51 [T] open socket
^C

Windows support

Is mongo-perl6-driver supported for Windows platforms? So far I have not been able to get a successful return from the Mongo server running on localhost. It appears to connect and locate a collection, but fails to return anything gives the error:

โ†[1;37;48;2;255;0;0m2017-10-10 14:32:51.673758 [E] 1: No server object for quer
y. At site#sources\A9A2F3AEE7E91396B118935B2318B5F8F53E6D6A (MongoDB::Collection
):54 in find()โ†[0m

Is there a support wiki?

Cannot connect to local database on Windows 10

Using mongodb 3.4.9 64-bit on Windows 10, the mongo shell can connect, Python can connect, but the test script on the mongo-perl6-driver homepage cannot connect. The exception is:

Could not connect socket: No connection could be made because the target machine actively refused it.
in submethod BUILD at D:\rakudo\share\perl6\site\sources\F06B1BC1B4DA64A475CC2619F99FBDE5AC0E1F5B (MongoDB::Server::Socket) line 26
in method get-socket at D:\rakudo\share\perl6\site\sources\4F88D22071E3E320D8AAB5083BFC265C51014181 (MongoDB::Server) line 310
in method query at D:\rakudo\share\perl6\site\sources\BC879B4D25A6E436249E3A7F8D507366F886FFC8 (MongoDB::Wire) line 57
in method raw-query at D:\rakudo\share\perl6\site\sources\4F88D22071E3E320D8AAB5083BFC265C51014181 (MongoDB::Server) line 433
in submethod BUILD at D:\rakudo\share\perl6\site\sources\4F88D22071E3E320D8AAB5083BFC265C51014181 (MongoDB::Server) line 68
in block at D:\rakudo\share\perl6\site\sources\0D505187A8D30D605200BB70D053E9478E43DBB7 (MongoDB::Client) line 599
in method discover-servers at D:\rakudo\share\perl6\site\sources\0D505187A8D30D605200BB70D053E9478E43DBB7 (MongoDB::Client) line 569
in block at D:\rakudo\share\perl6\site\sources\0D505187A8D30D605200BB70D053E9478E43DBB7 (MongoDB::Client) line 130

My perl6 version is the 2017.09 release.

run-command failing with newest mongod server

run-command uses find to send the commands to the server which is not correct. On older servers, the query field was ignored but the newer servers make a problem with it, which is correct of course. Removing the query field would also save encoding time.

MongoDB::Logger doesn't play nice with Log::Async

The following test code shows the problem. (I'm assuming a database "tvu" with collection "users". Change these to match the data that's in your DB.)

use MongoDB::Client;
use Log::Async;
my MongoDB::Client $client .= new(:uri("mongodb://127.0.0.1"));
my $db = $client.database('tvu');
logger.send-to($*OUT);
for $db.collection("users").find() -> $document {
	info ~$document;
}

The expected result is to see all the documents. The actual result is the following error, repeated many times:

No such method 'id' for invocant of type 'Any'
in block at D:\rakudo\share\perl6\site\sources\1B022E7E13BEE5A72407C8392CD0C4153240767C (Log::Async) line 45
in block at D:\rakudo\share\perl6\site\sources\1B022E7E13BEE5A72407C8392CD0C4153240767C (Log::Async) line 49
in code at D:\rakudo\share\perl6\site\sources\9B568CCA1135076961258D53B50B2C064E633CAB line 175

Another reproducible error I see on Windows (not Linux, as far as I remember) is:

Use of uninitialized value of type Any in string context.
Methods .^name, .perl, .gist, or .say can be used to stringify it to something meaningful.
in block at D:\rakudo\share\perl6\site\sources\9B568CCA1135076961258D53B50B2C064E633CAB (MongoDB::Log) line 34

[Performance]: Taking 20 seconds to do a single query

Hey, I was glad to find this Raku Mongo library.

I tried following the docs, and did a simple query on a field that is indexed. It took 22 seconds to print the result.

Am I doing something wrong?

#!/usr/bin/env raku

use v6;

use BSON::Document;
use MongoDB::Client;
use MongoDB::Database;
use MongoDB::Collection;

sub MAIN($db, $collection, $id) {

    my MongoDB::Client $client .= new(:uri('mongodb://127.0.0.1:27017'));
    my MongoDB::Database $database = $client.database($db);
    my MongoDB::Collection $coll = $database.collection($collection);

    my MongoDB::Cursor $cursor = $coll.find(:number-to-return(1));
    $cursor.fetch.perl.say;
}

This is on Mongo version 3.0.15, with the latest library version installed from zef.

Tests failed -Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')

On OSX. See also MARTIMM/BSON#8

$ panda install MongoDB
==> Fetching MongoDB
==> Building MongoDB
Compiling lib/MongoDB/Wire.pm to mbc
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB/Protocol.pm to mbc
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB/Cursor.pm to mbc
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB/Collection.pm to mbc
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB/Database.pm to mbc
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB/Connection.pm to mbc
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB.pm to mbc
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
Compiling lib/MongoDB/DBRef.pm to mbc
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
Use of Nil in numeric context  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Builder.pm:125
==> Testing MongoDB
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/301-Collection.t ....... 
No subtests run 
t/100-connection.t ....... 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
No subtests run 
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/300-Collection.t ....... 
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/200-database.t ......... 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/502-find.t ............. 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/500-find.t ............. 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/503-find.t ............. 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/700-DBRef.t ............ 
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/700-DBRef.t ............ 

===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/505-find-and-modify.t .. 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/505-find-and-modify.t .. 
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/remove.t ............... 
No subtests run 
===SORRY!===
Missing or wrong version of dependency '&encode_int32' (from 'lib/BSON/Binary.pm')
t/update.t ............... 
No subtests run 

Test Summary Report
-------------------
t/301-Collection.t     (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/100-connection.t     (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/300-Collection.t     (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/200-database.t       (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
Use of Nil in numeric contextt/501-find-one.t       (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
t/502-find.t           (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
t/500-find.t           (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
t/503-find.t           (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
  in block  at /Users/gabor/rakudo-star-2015.06/install/share/perl6/lib/Panda/Tester.pm:36
t/700-DBRef.t          (Wstat: 0 Tests: 0 Failed: 0)
==> Installing MongoDB
  Parse errors: No plan found in TAP output
t/insert.t             (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/505-find-and-modify.t (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
t/504-find.t           (Wstat: 256 Tests: 0 Failed: 0)
  Non-zero exit status: 1
  Parse errors: No plan found in TAP output
t/remove.t             (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
t/update.t             (Wstat: 0 Tests: 0 Failed: 0)
  Parse errors: No plan found in TAP output
Files=14, Tests=0,  7 wallclock secs ( 0.07 usr  0.03 sys + 20.01 cusr  1.24 csys = 21.35 CPU)
Result: FAIL
Copying blib/lib/MongoDB.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB.pm
Copying blib/lib/MongoDB.pod to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB.pod
Copying blib/lib/MongoDB/Collection.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Collection.pm
Copying blib/lib/MongoDB/Collection.pod to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Collection.pod
Copying blib/lib/MongoDB/Connection.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Connection.pm
Copying blib/lib/MongoDB/Connection.pod to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Connection.pod
Copying blib/lib/MongoDB/Cursor.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Cursor.pm
Copying blib/lib/MongoDB/Cursor.pod to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Cursor.pod
Copying blib/lib/MongoDB/Database.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Database.pm
Copying blib/lib/MongoDB/Database.pod to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Database.pod
Copying blib/lib/MongoDB/DBRef.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/DBRef.pm
Copying blib/lib/MongoDB/Protocol.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Protocol.pm
Copying blib/lib/MongoDB/Wire.pm to /Users/gabor/rakudo-star-2015.06/install/share/perl6/site/lib/MongoDB/Wire.pm
==> Successfully installed MongoDB

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.