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