Poolboy for MongoDB driver: pool_timeout seems not working

I defined children in main project file.

mongo_options = [ hostname: db_host,
port: db_port,
database: db_name,
name: :mongo_db,
pool: DBConnection.Poolboy ]

children = [
worker(Mongo, [mongo_options])
]

Any I have a aggregation query takes time.

arrr_opts = [allow_disk_use: true,
timeout: 15_000,
pool_timeout: 15_000,
pool: DBConnection.Poolboy]

Mongo.aggregate(:mongo_db, “asset”, pipeline, aggr_opts)
|> Enum.to_list()

When I run the code, I receive below error when it passed 5 sec.

2018-03-01 15:10:20.604 [error] module=DBConnection.Connection function=disconnect/2 line=181 Mongo.Protocol (#PID<0.387.0>) disconnected: ** (Mongo.Error) tcp recv: unknown POSIX error - :timeout

** (Mongo.Error) tcp recv: unknown POSIX error - :timeout
(mongodb) lib/mongo/cursor.ex:154: anonymous fn/5 in Enumerable.Mongo.AggregationCursor.start_fun/5
(elixir) lib/stream.ex:1270: anonymous fn/5 in Stream.resource/3
(elixir) lib/enum.ex:1838: Enum.reverse/1
(elixir) lib/enum.ex:2596: Enum.to_list/1

:timeout seems to be working, but pool_timeout is not.

Anybody has any idea why it is not working?

Thank you adavance.
ihkim.

Your issue isn’t that the driver isn’t following the :pool_timeout option, it is that we are setting the :send_timeout option on the socket. Which is the timeout error that you are seeing. Unfortunately I believe this is a fragment from before the driver was using the db_connection package and was missed during the migration.

As a temporary workaround, you can add timeout: 15_000 (or any number you want) to your mongo_options list and it should fix your problem.

I will make a point of fixing and releasing this fix shortly. Thank you for finding it!

Ankhers,

Yes, the workaround is working.
Thank you for your help!!! :+1:

ihkim.