SSIS - Killing Sessions with SSIS
From SQLServerPedia
|
We all know about the query from hell - the one executed by a departmental user that pulls the entire contents of the cube down into Excel and brings your server to its knees just at the worst possible moment. What can you do about it? Well, you can set a general timeout on all queries that are run against Analysis Services using the ServerTimeout property in msmdsrv.ini. However you should be mindful that all queries could possibly time out after two minutes. On the other hand, you can wait for users to provide feedback that the server is really slow, and then take a look at what's running and kill sessions manually. Neither option seems satisfactory. It would be ideal to kill sessions automatically but at the same time apply some rules such as:
select * from $system.discover_commands But you may need more information in order to make the decision on whether to kill or not so it could also be useful to run the two following DMV queries to find out more about sessions and connections: select * from $system.discover_sessions select * from $system.discover_connections
3. With the resulting recordset stored in a variable, you can then loop over the recordset in a For each task in your control flow and use an Analysis Services Execute DDL task to run the XMLA Cancel command to kill each query:
4. The last step is to schedule the package to run frequently, perhaps every 30-60 seconds, using SQL Server Agent. It is very easy to do. Of course you could add loads more functionality to this basic package – including sending an email to someone after you've killed their session explaining what has happened, or you may only want to kill a session if there are other users running queries at the same time. Author CreditsThis wiki article was adapted from a blog post by Chris Webb. Chris Webb is an independent consultant specialising in SQL Server Analysis Services cube design, tuning and troubleshooting and the MDX query language. He’s a co-author of “MDX Solutions with Microsoft SQL Server 2005 Analysis Services and Hyperion Essbase” and a regular speaker at user groups and conferences in the UK and Europe. He can be contacted via his company website, Crossjoin.co.uk. His online presences include: Related ReadingFor more information about session management, check out these articles:
|

