Wednesday, May 4, 2011

Reporting Services Exception: Execution cannot be found

The rsExceutionNotFound Problem:

On an instance of SQL Server Reporting Services 2005 I noticed for a good while that the service is throwing rsExecutionNotFound exception and logging those as warnings to Windows application event log. A typical warning may look like


Event Type: Warning
Event Source: ASP.NET 2.0.50727.0
Event Category: Web Event
Event ID: 1309
Date:
Time:
User:
Computer: SERVERNAME
Description:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time:
Event time
Event ID: 5be391324153445f9e5e3ace93334c55
Event sequence: 38
Event occurrence: 1
Event detail code: 0

Application information:
    Application domain: /LM/W3SVC/1/Root/Reports-1-129490022321612580
    Trust level: RosettaMgr
    Application Virtual Path: /Reports
    Application Path: ...\Reporting Services\ReportManager\
    Machine name: SERVERNAME

Process information:
    Process ID:
    Process name: w3wp.exe
    Account name:

Exception information:
    Exception type: ReportServerException
    Exception message: Execution '<SESSION ID>' cannot be found (rsExecutionNotFound)

Request information:
    Request URL: http://SERVERNAME/Reports/Reserved.ReportViewerWebControl.axd?ReportSession=SessionID really long URL
    Request path: %21 {I guess these %numbers are supposed to substituted }
    User host address: %22
    User: %23
    Is authenticated: %24
    Authentication Type: %25
    Thread account name: %26

After some searching I found this blog entry http://blogs.msdn.com/b/jgalla/archive/2006/10/11/session-timeout-during-execution.aspx. But the problem described in the mentioned blog is different and the suggested solution does not work in the cases I am describing here. The problem here is not that the report execution takes too long that the reporting services session times out.

The Cause of the Exception:

After some tracking and playing around I can say with a very high degree of certainty that the cause of the problem is  Internet Explorer [8]'s way of saving URLs when a user bookmarks (adds to favorites) a report's reporting services' URL.


I noticed that the exception (rsExecutionNotFound) is always thrown and the warning is logged in Windows when the user requests a report via a click on a favorite's URL. Of course the exception won't be thrown if the user visits the bookmarked report before its Reporting Services session expires. But typically with bookmarks they're visited days after the sessions are deleted and will for sure causes an rsExecutionException to be thrown.

If you look at an Internet Explorer 8 favorites shortcut file (*.url) you'll see some addition information saved along side the base URL of the bookmarked page. I believe this additional information is saved because when the report is rendered in the browser the page typically contains many iframes so the IE save their URLs as well. And in this case the additional information includes the Reporting Services SessionID. So when the user clicks on the favorite report, IE does try to make requests with old Reporting Services SessionIDs.

Here's a snippet of *.url file


[DEFAULT]
BASEURL=http://SERVERNAME/Reports/Pages/Report.aspx?ItemPath=/some/report/here
[DOC_ctl140TouchSession0]
BASEURL=http://SERVERNAME/Reports/Reserved.ReportViewerWebControl.axd?ReportSession=SessionID really long URL {the same shown in event log}
ORIGURL=javascript:''
[DOC_ctl140_ctl00_ctl03_ctl01]
....


A Solution:


Luckily if the cause of the exception is what I described here the user does not see on their screens and the exception itself is nothing serious although it might be bothersome to see those warnings in the events log. So in reality it does not affect the user's experience.

If the cause of the exception is that fact that the report takes tremendously long time to run to the point its session on Reporting Services times out, then the above mentioned link offers an easy solution.

1 comment: