@@ -457,12 +457,28 @@ pool.end(function (err) {
457
457
```
458
458
459
459
The ` end ` method takes an _ optional_ callback that you can use to know once
460
- all the connections have ended. The connections end _ gracefully_ , so all
461
- pending queries will still complete and the time to end the pool will vary.
460
+ all the connections have ended.
462
461
463
462
** Once ` pool.end() ` has been called, ` pool.getConnection ` and other operations
464
463
can no longer be performed**
465
464
465
+ This works by calling ` connection.end() ` on every active connection in the
466
+ pool, which queues a ` QUIT ` packet on the connection. And sets a flag to
467
+ prevent ` pool.getConnection ` from continuing to create any new connections.
468
+
469
+ Since this queues a ` QUIT ` packet on each connection, all commands / queries
470
+ already in progress will complete, just like calling ` connection.end() ` . If
471
+ ` pool.end ` is called and there are connections that have not yet been released,
472
+ those connections will fail to execute any new commands after the ` pool.end `
473
+ since they have a pending ` QUIT ` packet in their queue; wait until releasing
474
+ all connections back to the pool before calling ` pool.end() ` .
475
+
476
+ Since the ` pool.query ` method is a short-hand for the ` pool.getConnection ` ->
477
+ ` connection.query ` -> ` connection.release() ` flow, calling ` pool.end() ` before
478
+ all the queries added via ` pool.query ` have completed, since the underlying
479
+ ` pool.getConnection ` will fail due to all connections ending and not allowing
480
+ new connections to be created.
481
+
466
482
## PoolCluster
467
483
468
484
PoolCluster provides multiple hosts connection. (group & retry & selector)
0 commit comments