+8 votes
by (100 points)

We have a very strange problem:

We have a stored procedure which returns a set of data. This procedure does a rather complex join and aggregation, so it takes 700 Milliseconds to execute.

When called directly in SQL Studio, the procedure ALWAYS returns correcty and always takes about 700 ms of time.

However, when called via a Client software (C# or Excel), then it works for a while, but then suddenly, the procedure takes 30 seconds (!) and gets a timeout. The number of disk reads is normal, but CPU is going up.

This behaviour goes on for 1-2 hours, and then it is normal again ! During this time, when the procedure show this behaviour, you can still execute the procedure in SQL Studio. Also, other and more simple procedures also get normally executed when called in the client.

I checked the calls with the profiler. When calling via a client, the call is marked as "RPC", when called in SQL Studio, it is "SQL"

So probably the procedure executes normal, but the data transmission via RPC somehow is hanging. But this is only a guess.

Does anyone have a idea, or can point us in some direction? I don't know where to look. Also the Event log is empty.

5 Answers

+9 votes
by (100 points)

Problem solved -- it was a fairly complex function, and compiling the execution plan took a lot of time. I simplified the procedure by removing a lot of conditional branches (if, case) and splitting the procedure into multiple sub-procedures.

+8 votes
by (100 points)

.NET applications uses predefined (default) command timeout values. This duration is most probably not enough for some of your commands and queries. You may try to define your custom command timeout in your application.

I think you use a C# application as mentioned. Following definition in a constructor of your database context (EF code-first approach) may solve your issue.

public MyDBContext()
      : base("MyDB")
      ((IObjectContextAdapter)this).ObjectContext.CommandTimeout = 300;

I've been using this definition in my C# based applications together with EF that executes sql server stored procedures.

Good luck!

+6 votes
by (100 points)

You are not executing the file as a binary. You are executing ruby binary with argument test.rb and it interprets the Ruby script. Therefore, only ruby binary needs execution privilage and not the script itself.

You can check the privileges of the binary by running stat (which ruby) .

On the other hand if you place


on the top of your script and make it executable with chmod a+x test.rb you could then make Linux run it. The binfmt module of the kernel will check search for #! (called shebang) in the file and run the interpreter for you.

You can find this shebang in lot of the shell scripts. Nowadays it is common to put #!/usr/bin/env ruby or #!/usr/bin/env python in order to use interpreter binary in other location that is available on PATH variable like /usr/local/bin/ruby . Again env is just another binary program. It will run its argument as a program. The kernel will pass script as the parameter which will result in command /usr/bin/env ruby test.rb .

+3 votes
by (100 points)

You can return to iframe JS code which would send message to parent window via postMessage, in this way you could capture errors in host window. There wouldn't be any problems with cross-domain, and content easily would be streamed to browser as it was before.

+1 vote
by (100 points)

If you want to get an URL from the XML above, you can try to use jsoup library:

String input = "<description>\n" +
            "<img src=\"http://static.ibnlive.in.com/ibnlive/pix/sitepix/03_2010/google_new_630_90x62.jpg\"" +
            " alt=\"REDIRECTED: Google shut its Chinese portal over censorship and visitors were being redirected" +
            " to Hong Kong-based site.\" title=\"REDIRECTED: Google shut its Chinese portal" +
            " over censorship and visitors were being redirected to Hong Kong-based site.\"" +
            " border=\"0\" width=\"70\" height=\"50\" align=\"left\" hspace=\"5\"/>The company" +
            " joins Google in protesting cyber attacks and censorship in China.\n" +
Document document = Jsoup.parse(input);
String output = document.select("img").first().attr("src");