Oracle: how to determine the end of the client process, how does it work for sqlplus?

I have the following problem in my application that connects to an Oracle 10g database:

When my client crashes, or the process terminates through the task manager, or the client loses connection for some time, the corresponding entry in the v $ session view remains.

Now, when I connect to the database using sqlplus and I kill sqlplus.exe through the task manager, the session record is deleted almost instantly.

The latter behavior would be preferable for my application for various reasons.

What does sqlplus do differently, and can I do this also in my own applications?

+4
source share
3 answers

Further research showed that, although sqlplus behaves differently when it kills a process, it actually behaves the same when the network cable is connected to the second => The untied session will remain on the server.

Now I have created a user profile with limited idle_time , which is assigned to the users I need. The background thread sends keepalive requests to support the SNIPED connection using PMON.

See my other Oracle question : idle_time is ignored if you are interested in what I did, and see the answer for what you need to do to make idle_time work.

+1
source

SQL * Plus uses the OCI - Oracle Call Interface. This is an extensive API (more than four hundred function calls. The OCI provides many methods for handling connections and sessions. I donโ€™t know for sure, but I would suggest that SQL * Plus uses OCILogon2 () to register a dedicated session for the user, and puts something in a descriptor a session that allows it to detect when a session is abends.

So, maybe your application does not use OCI to connect the database. If you want to know more about OCI, you can read the docs. Be careful, this is pretty low-level stuff! More details ...

+2
source

You can set sqlnet.expire_time=minutes_to_check in $ORACLE_HOME/network/admin/sqlnet.ora ; it will not be instantaneous like oci, but it will clear dead compounds.

+1
source

Source: https://habr.com/ru/post/1400560/


All Articles