mithrandyr / SimplySql

PowerShell module for querying various SQL databases
MIT License
202 stars 30 forks source link

Closing connection doesn't close database session #31

Closed thorstenkampe closed 3 years ago

thorstenkampe commented 4 years ago

Closing a database connection doesn't close the session on the database server. Tested with MSSQL, MySQL, Oracle and PostgreSQL. (PowerShell and database servers all latest versions)

thorstenkampe commented 4 years ago

Exiting the shell from which the connection was opened, closes the session immediately.

mithrandyr commented 4 years ago

@thorstenkampe, is it possible that this is a symptom of connection pooling? You can double check the logic for the Close-SqlConnecttion command. As you can see, the connection is being Closed and then Disposed...

It seems like this behavior might be normal for connections where Connection Pooling is turned on -- see MS documentation of the Close method.

thorstenkampe commented 4 years ago

Yes, I thought so myself. The connections sooner or later will disappear except for Oracle where it seems the connection stays indefinitely. At the moment Close-SqlConnection is somehow a no-op - it doesn't do anything tangible from what I can see.

mithrandyr commented 3 years ago

@thorstenkampe -- see this from Oracle: OracleConnection.Close().

As far as I can tell, if the connection is remaining open, then the oracle instance has connection pooling and the lifetime has not been exceeded.