Please include an setup example using NodeJS in a dockerized environment. We're running this in Kubernetes and we have no ideia how to properly setup the /heath test combined with the existing pool
@rturk What kind of application are you running? Is a check of the pool sufficient? For example, if you're running an API, perhaps you need to test that (with a route just for this purpose) which would, in turn, test the pool.
@rturk Do you mean a liveness probe for https://kubernetes.io/docs/user-guide/walkthrough/k8s201/#health-checking ? If so, Dan seems to be on the right track with a route.
You can make the node-oracledb code as comprehensive (and as fast or slow) as you like. The most basic check would get a connection and do a 'SELECT 1 FROM DUAL' to see if the DB is still running. Fundamentally this would check just one connection, but you would assume that user's later pool.getConnection() calls would silently handle (hint: use Oracle 12.2 client libraries) any reconnection necessary if there had been a network drop and other connections in the pool are not valid.
You may want to check other application components, or do more checks on the node-oracledb (connection pool stats) or the DB (on RAC nodes, free space etc).
Node-oracledb should probably expose the ping function used by the connection pool (like Python cx_Oracle does). This would be used in your health check instead of the SELECT. This is a future enhancement for node-oracledb.
Node-oracledb 2.2 has a new connection.ping() method that removes the need to do 'select 1 from dual' calls.
@cjbj can you clarify the diference between ping() and select 1 from dual ? especially considering getting a connection from the connection pool, making a query and releasing the connection to the pool?
ping() 'exercises' the code path to the DB but doesn't involve the SQL layer, so it should be a more efficient. It checks that a particular connection / session is usable. It maps down to OCIPing.