Вы находитесь на странице: 1из 3

How-To: Terminating Sessions in SAP HANA

A high resource consumption or allocating of critical resources of long running SAP HANA
sessions can result in global problems.

This SAP Note provides an overview of settings and commands that can be used to terminate
critical long running sessions.

A session in this context is the combination of connection (i.e. link to client process), thread (i.e.
actual execution on SAP HANA side), SQL statement and transaction.

SAP HANA processing is based on threads rather than processes, so there is no guaranteed
way to be able to terminate a running session.

Only if SAP HANA actively checks for termination requests the termination will succeed. The
most critical code paths already check for termination requests.

Automatic:

Statement memory limit

Starting with SPS 08 it is possible to configure an automatic termination of SQL statements


which exceed a defined memory allocation. In this way you can make sure that single SQL
statements don't allocate a high amount of memory.

Old open cursor


Old active SQL statement

indexserver.ini -> [transaction] -> idle_cursor_lifetime


Old active update transaction

uncommitted_write_transaction_lifetime

indexserver.ini -> [transaction] -> uncommitted_write_transaction_lifetime

Manually

You can disconnect (and implicitly cancel) the related session / connection using the following
command:

ALTER SYSTEM DISCONNECT SESSION '<connection_id>'

Before the disconnection succeeds, the current transaction needs to be cancelled and rolled
back. A cancellation may not succeed immediately, because it requires that the current
transaction checks for incoming cancellation requests.
Attention: If a critical session can't be cancelled with CANCEL SESSION a forced disconnection
of the session can make the situation worse, because the client process might reconnect to SAP
HANA and start the critical activity another time. In this case you will face two critical sessions
rather than only one. So you should execute a DISCONNECT SESSION with care in cases
where a CANCEL SESSION didn't succeed.

Hdbcons:
You can cancel an individual active transaction with ID <transaction_id> using the following
command:
hdbcons 'transaction c <transaction_id>'
All active transactions can be cancelled in the following way:
hdbcons 'transaction c -a'

emergencyInfo.py:

The python script emergencyInfo.py is available as of SAP HANA SPS 08 in


/usr/sap/<sid>/HDB<inst_id>/exe/python_support and can be called in the following way to
cancel one or all transactions:
python emergencyInfo.py cancelTransaction <transaction_id>

python emergencyInfo.py cancelAllTransactions

SAP HANA Studio:

As of SAP HANA SPS 08 you can activate the "Emergency Information" tab via "Administration" -
> "Open Diagnosis Mode". There you can switch to the 'Transaction' tab and proceed as follows
to cancel one or all transactions:
● Right-click on transaction and choose 'Cancel transaction <transaction_id>...' for
cancelling a single transaction.
● Choose 'Cancel All Transactions' to cancel all active transactions.

Terminate X2 plan execution:

If a thread hangs executing an X2 plan, it can be stopped using the x2StopPlan.py command as
explained in SAP Note 2037509.

If a critical session exists and can't be terminated with the approaches described above, you
should proceed as follows:

Generate call stack:

If an active thread exists for the connection in question, you can generate its callstack, e.g. using
SQL: "HANA_Threads_Callstacks" (CONN_ID = <connection_id>) available via SAP Note
1969700. The following scenarios may be responsible:

Generate runtime dump

In order preserve all relevant details of the situation it is recommended to create a SAP HANA
runtime dump (SAP Note 1813020

Вам также может понравиться