Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: fix update_all doc #228

Merged
merged 2 commits into from
Feb 10, 2024
Merged

doc: fix update_all doc #228

merged 2 commits into from
Feb 10, 2024

Conversation

LKlemens
Copy link
Contributor

@LKlemens LKlemens commented Feb 1, 2024

No description provided.

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 1, 2024

Hi @zookzook
First of all thank you for all your work! elixir-mongodb-driver is very handful :)
I have question about tests - Are all tests shall pass? Some of them failing locally for me:

Finished in 70.0 seconds (2.2s async, 67.7s sync)
264 tests, 43 failures, 3 excluded

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 1, 2024

I found that I cannot connect to test mongo replica.
Did I do sth wrong?

Steps:
1. export PATH=/usr/local/Cellar/mongodb-community/7.0.2/bin/:$PATH
2.  ulimit -S -n 2048 ## in case of Mac OS X
3. mlaunch init --setParameter enableTestCommands=1 --replicaset --name "rs_1"
Detected mongod version: 7.0.2
launching: "mongod" on port 27017
launching: "mongod" on port 27018
launching: "mongod" on port 27019
4. mongosh "mongodb://localhost:27017,localhost:27018,localhost:27019/test?replicaSet=rs_1"
Current Mongosh Log ID: 65bbcc45bebb37d001b2ee7b
Connecting to:          mongodb://localhost:27017,localhost:27018,localhost:27019/test?replicaSet=rs_1&serverSelectionTimeoutMS=2000&appName=mongosh+2.1.3
MongoServerSelectionError: Server selection timed out after 2000 ms
5. the same is from iex
iex(node3@Administrators-MacBook-Pro)2> {:ok, conn} = Mongo.start_link(url: "mongodb://localhost:27017,localhost:27018,localhost:27019/test?replicaSet=rs_1")
{:ok, #PID<0.260.0>}
iex(node3@Administrators-MacBook-Pro)3> Mongo.find_one(conn, "test", %{})
** (exit) exited in: GenServer.call(#PID<0.260.0>, {:checkout_session, :read, [batch_size: 1]}, 60000)
    ** (EXIT) time out
    (elixir 1.15.7) lib/gen_server.ex:1074: GenServer.call/3
    (mongodb_driver 1.2.1) lib/mongo/session.ex:142: Mongo.Session.start_session/3
    (mongodb_driver 1.2.1) lib/mongo/stream.ex:40: Mongo.Stream.checkout_session/2
    (mongodb_driver 1.2.1) lib/mongo/stream.ex:21: Mongo.Stream.new/3
    (mongodb_driver 1.2.1) lib/mongo.ex:790: Mongo.find/4
    (mongodb_driver 1.2.1) lib/mongo.ex:818: Mongo.find_one/4
    iex:3: (file)

@zookzook
Copy link
Owner

zookzook commented Feb 1, 2024

I will look into it tomorrow. Maybe the replica-set is not able to communicate. Please check if the servers are listening to the specified ports.

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 2, 2024

yep, there are listening - I can connect it using url e.g. mongodb://localhost:27017
But connection is useless because I cannot do anything because of errors

 elixir-mongodb-driver git:(master) ✗ mongosh mongodb://localhost:27017
Current Mongosh Log ID: 65bcb0ad520d9144fdff1286
Connecting to:          mongodb://localhost:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.1.3
Using MongoDB:          7.0.2
Using Mongosh:          2.1.3

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2024-02-02T10:05:56.857+01:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2024-02-02T10:05:56.857+01:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
   2024-02-02T10:05:56.858+01:00: Soft rlimits for open file descriptors too low
------

test> show collections
MongoServerError: node is not in primary or recovering state
test> db.test.find()
MongoServerError: not primary and secondaryOk=false - consider using db.getMongo().setReadPref() or readPreference in the connection string
 mlaunch list
Detected mongod version: 7.0.2

PROCESS    PORT     STATUS     PID

mongod     27017    running    32473
mongod     27018    running    32483
mongod     27019    running    32486

@zookzook
Copy link
Owner

zookzook commented Feb 2, 2024

What prints "rs.config()"

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 2, 2024

test> rs.config()
MongoServerError: no replset config has been received

Did you try do it by yourself? Do tests work for you?

@zookzook
Copy link
Owner

zookzook commented Feb 2, 2024

Yes, this should work. That means, that your Replica-Set is not configured. Try this:

rs.initiate({_id: “rs_1”, members: [{_id: 0, host: “127.0.0.1:27017"}, {_id: 1, host: “127.0.0.1:27018”}, {_id: 2, host: “127.0.0.1:27019"]}

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 2, 2024

I checked it, and indeed it works now, thanks!
I will add it to README.
One test fails anyway - could you check if it works for you?

  test/mongo/read_preferences_test.exs:58

Mongo instances exits during tests, and I have to manually start it again and again.
Have you encountered such behavior?

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 2, 2024

After deleting those line it started passing
73
81
But I have no idea why ;/ Missing some tags setup?

@zookzook
Copy link
Owner

zookzook commented Feb 2, 2024

You need to setup the tags in this case.

@LKlemens
Copy link
Contributor Author

LKlemens commented Feb 2, 2024

I've just read the test docs 🤦
But that should be done automatically in setup section, to avoid setting it up manually before running that one test, wdyt?

@zookzook zookzook merged commit 44a08f0 into zookzook:master Feb 10, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants