@@ -572,8 +572,8 @@ When ``#close`` is called on a client by any thread, all connections are closed:
572
572
client.close
573
573
574
574
575
- Use with Forking Servers
576
- ------------------------
575
+ Usage with Forking Servers
576
+ --------------------------
577
577
578
578
When using the Mongo Ruby driver with a forking web server such as Unicorn,
579
579
worker processes should generally each have their own Mongo::Client instances.
@@ -584,7 +584,7 @@ This is because:
584
584
2. File descriptors like network sockets are shared between parent and
585
585
child processes.
586
586
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.
588
588
If the parent process needs to perform operations on the MongoDB database,
589
589
reset the client in an ``after_fork`` handler which is defined in
590
590
``unicorn.rb``:
@@ -616,6 +616,11 @@ the following code will close the connection in the parent:
616
616
*Note:* This pattern should be used with Ruby driver version 2.6.2 or higher.
617
617
Previous driver versions did not recreate monitoring threads when reconnecting.
618
618
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
+
619
624
Details on Retryable Writes
620
625
---------------------------
621
626
0 commit comments