Skip to content

Commit 023d867

Browse files
authored
Minor changes to fork guidance following mongoid (#1006)
1 parent 6d09534 commit 023d867

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

source/tutorials/ruby-driver-create-client.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,8 @@ When ``#close`` is called on a client by any thread, all connections are closed:
572572
client.close
573573

574574

575-
Use with Forking Servers
576-
------------------------
575+
Usage with Forking Servers
576+
--------------------------
577577

578578
When using the Mongo Ruby driver with a forking web server such as Unicorn,
579579
worker processes should generally each have their own Mongo::Client instances.
@@ -584,7 +584,7 @@ This is because:
584584
2. File descriptors like network sockets are shared between parent and
585585
child processes.
586586

587-
It is easiest to not create any Mongo::Client instances prior to the fork.
587+
It is recommended to not create any Mongo::Client instances prior to the fork.
588588
If the parent process needs to perform operations on the MongoDB database,
589589
reset the client in an ``after_fork`` handler which is defined in
590590
``unicorn.rb``:
@@ -616,6 +616,11 @@ the following code will close the connection in the parent:
616616
*Note:* This pattern should be used with Ruby driver version 2.6.2 or higher.
617617
Previous driver versions did not recreate monitoring threads when reconnecting.
618618

619+
*Note:* If the parent process performs operations on the Mongo client and
620+
does not close it, the parent process will continue consuming a connection slot
621+
in the cluster and will continue monitoring the cluster for as long as the
622+
parent remains alive.
623+
619624
Details on Retryable Writes
620625
---------------------------
621626

0 commit comments

Comments
 (0)