Database connections created in Martini are maintained in a connection pool so they can be reused for future requests. Each pool keeps the maximum amount of open connections it can hold depending on its properties. In some cases, you may encounter this limit being reached (and even exceeded) causing unavailability of connections at runtime.
When a database connection is used in your services, Martini tries its best to put the connection back in its pool after using it. However, under some circumstances you may also find these connections leaking.
Martini offers a way to monitor JDBC connections by recording their stacktrace upon creation to help you decide if it
is a connection leak or whether you need to reconfigure the database pool's properties. To enable this feature,
set the logger level of
DEBUG. You can then use the
operation from the REST API to query the connections' metadata.
Here is a sample response from this operation:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
This response shows that an active connection named
store-2010329540 exists from the
store database pool. It was
created and opened specifically from the
GetCustomers Gloop service at line 12.
Note that connections are only recorded after configuring the log level so previously created connections are not returned by the API. If you need to track them immediately, restart the database pool to reset the connections. Remember to set the log level back after troubleshooting since recording such information may incur a performance overhead.