Troubleshooting orphaned sessions and SPIDS in Dynamics Ax

After my last post was published I got some questions on how orphaned SQL processes (SPIDs) are cleaned up in Ax when an AOS or client crashes. A simple answer to that would be that the behavior is different depending on what crashed and what that process was doing at that instant of time.

Let’s take about the client side first. If a client crashes or is killed due to unresponsiveness the server will terminate the session of the client on the server after a certain interval when it does get a ping from the client.  In Ax 4.0 and in Dynamics Ax 2009 each client sends a ping request to the server periodically indicating that it is alive.  The server terminates client sessions that do not send the ping request within a predetermined time interval of 90 seconds.  If an AOS kills a client session you will see an error similar to the following message in the AOS event viewer.

Object Server 02: No ping from 3. Terminating the session.

Sometimes you may see the following warning in the event viewer following the above error:

Object Server 01: RPC error: Client provided an invalid session ID 3

The second event happens when a client connects to a server that was previously terminated by the server. In this case the server has removed this session from its memory but later on the client sent an RPC request to the server but the server will flag this as invalid session.

Now coming back to the database SPID, if this client was connected to the database the connection will be closed but if this client’s SQL connection is blocked behind some other connection then this SQL connection will not be closed as the AOS cannot close the connection in the database. 

For the server depending on the type of the crash the outcome is something similar. If a session on the server is terminated due to some error on the server, the server will close any open SQL connections unless those are blocked in the database. If there is an access violation leading to a crash in the server which causes the process to terminate then all the SQL connections from that process will close.

So in most cases you will not have orphaned processes (SPIDS) in the database. The SPIDS might exist only because they are blocked behind some other SPID and the AOS could not clean them up successfully in the database. These SPIDS will be cleaned up when the blocking SPID in the database finishes its current actions. Because of the connection pooling that is implemented inside the AOS server we do not recommend terminating SPIDS manually in the database while the AOSs’ are still running.

I hope you found this information useful. For the past couple of posts I have concentrated mainly on session management and troubleshooting session in the AOS. My upcoming posts are going to be slightly different as I am going to focus on some X++ developer oriented topics. I will start with some posts on the Query framework in Ax and we will also have posts by some other folks working in the Ax platform team.

Please let us know if you would like us to cover a specific topic.

Thank You,

Amar Nalla


Comments (2)

  1. Seng Chai Gan says:

    Hi Amar,

    How to explain if event logs only have this warning messages:

    Object Server 01:

    Client provided an invalid session ID 32

    but without "Object Server 01: No ping from 32. Terminating the session."



  2. Anthony says:

    Our AOS servers are leaving behing sleeping SPID's on the database which is causing us some issues.

    The AX database is set up in snapshot isolation so it logs row versions to tempdb based on the SPID.

    Our tempdb is filling up quite quickly with the version store and requires manual termination of the SPID's to remove the transactions (sys.dm_trans_active_snapshot_database_transactions) and release the space its used in tempdb.

    Setting the client to auto close after a period of inactivity still leaves the SPID active and all of the objects in tempdb remain.

    Anyone any ideas on how to terminate SPID's from sessions where the sessions has no valid SPID?