Screen/Database query keep on loading/executing unless sql service is restarted - sql-server

I am using MVC razor in one of the Web Application using .Net
One of the screen in my web application has 2 DropDownList, 1 button and 1 Grid. When I click on 1st DDL, the screen instead of focusing on 2nd DDL it starts to keep on loading.. and gives exception: the timeout period expired prior to completion of the operation
DDL select query is: select * from Table where year='2014'and name='pqr'(used in code behind Entity Framework) which throws this exception. Same thing is happening in DB, when I run the above LINQ query in SSMS, it keeps on executing.
If I restart SQL Service, everything starts to work normal and the result is shown but after some time if I try same then again the same issue occurs. In this case, I need to restart the sql service again and again which shouldn't happen.
In SSMS, I checked Activity Monitoring and found that sometimes some SPId's are getting blocked and that time only screen/query keep on loading/executing.
Using DBCC INPUTBUFFER(spid);I came to know which Stored Procedure / Table is blocking (please correct if my understanding is wrong here). I also tried using with (NOLOCK) on certain tables inside Stored Proc, which also didn't workout for me.
How can I resolve this issue at DB level? My application is already live.
Note: This issue occurs intermittently.

Related

Oracle change notification Exception

My one of the table holds data for business transactions and I have to run a job when there's no transaction for interval 5 minutes, I am trying to achieve this using Timer() in java. So to get notified if any transaction is executed I need some triggering ( I do not have code access as it is 3rd party tool ) for that purpose I am using database change notification.
However while running this I get below error very often. I am using java 1.6, ojdbc6.jar for connection purpose and the application is running on weblogic with oracle 11g database.
Exception in thread "Thread-4" java.lang.IndexOutOfBoundsException at java.nio.Buffer.checkIndex(Buffer.java:540) at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:139) at oracle.jdbc.driver.NTFConnection.unmarshalOneNSPacket(NTFCon‌​nection.java:334) at oracle.jdbc.driver.NTFConnection.run(NTFConnection.java:182)
Please modify the example http://appcrawler.com/wordpress/2012/08/28/jdbc-and-oracle-database-change-notification/ for your listener and check if issue still exists. My understading that issue is not related to Oracle DB, but part of Java realization of your code. Please, add java tag into your question as well.

Trigger XMPP message from SQL Server trigger or ON INSERT

I need to be able to send an XMPP message when a row gets inserted into a particular table in our SQL Server database (and have it not make the insert fail if the XMPP server or code isn't available/fails/etc).
Is this possible without causing the insert to fail in some circumstances?
To avoid potentially blocking your database application, I'd recommend NOT to send any external messages directly from a trigger. After all, the trigger executes in the context of the SQL statement that caused it to fire, and if the trigger is delayed, then your statement will have to wait until the trigger is done (or has timed out).
Instead, what I'd do is this:
insert a row into a "command" table with enough information to be able to later send your XMPP message - this can be done in the trigger
have a separate piece of code, e.g. a scheduled SQL Server job, that checks that "Command" table every x minutes or hours or however frequently (or infrequently) that you need - and this job running separately and independently from your application should them attempt to send out those messages, and handle any potential error situations - while your main application happily works along not bothered by any delays, time outs etc.

SSIS Logging showing random behaviour while logging event in dbo.syssisLog table

I was planning to use SSIS logging to get task level details (duration of running, error message thrown-if any, user who triggered the job ) for my package.
SSIS was creating dbo.syssisLog table under System table and it was working just fine. Suddenly it stops creating table under System table and start creating under Users table. Also now it is not logging some events which were logged previously when created under System table. Events like: PackageStart and User:PackageStart/User:PackageEnd event for some tasks.
Can anyone please guide me what's going wrong here ?
The table showing under System versus User tables is fairly meaningless but if you want the table to show the same, set it as a MS shipped table
EXECUTE sys.sp_MS_marksystemobject 'sysssislog'
The way database logging works in the package deployment model, is that SSIS will attempt to log to dbo.sysdtslog90/dbo.sysssislog (depending on your version) but if that table doesn't exist, it will create it for you. There is a copy of that table in the msdb catalog which is marked as a system object. When SSIS creates its own copy, it just has the DDL somewhere in the bowels of the code that does logging. You'll notice it also creates a stored procedure sp_ssis_addlogentry to assist in the logging.
As for your observation for inconsistent logging behaviour, all I can say is I've never seen that. The only reason it won't log an event is if the event doesn't occur - either a precursor condition didn't happen or the package errors out. If you can provide a reproducible scenario where it does and then doesn't log events, I'll be happy to tell you why it does/doesn't do it.

how to debug when sql server timesout using a stored procedure at a certain time of day

I am using asp.net (version 4) and am trying to run a stored procedure which I have created
ALTER PROCEDURE [dbo].[some_proc]
AS
BEGIN
INSERT INTO [dbo].[some_proc](Creation_Date)
VALUES (getDate());
select SCOPE_IDENTITY();
END
The procedure runs fine when called from within server management studio (runs in less than a second) and also runs fine from my web app UNTIL the afternoon (about 3pm), at which point I get a timeout error, as below:
The request channel timed out while waiting for a reply after 00:00:29.9969982. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
Other stored procedures that I try and run and return expected results. All the stored procedures query the same database.
I have reviewed several other answers on similar questions but they haven't helped me regarding this situation.
I realise this issue may be very specific to my situation, and if it is then my question would be how do I start to debug this issue (any tools or techniques would be really helpful)
You could run a SQL Server Profiler session recording database activity between 2.30 and 3.30
also check SQL Server Agent for any jobs that start around that time

how to push data or message from sql server to web application

I'm developing a asp.net MVC 3 web application project. The project is simple, it provides a web page listing stored procedures in SQL Server. when user selects a stored procedure and hit "run" button, it is invoked to execute in SQL Server and return some execution result.
My stored procedure is logically divided into several steps, say 10 steps, each step prints a message like step 1: doing A..., step2: dong B..., until step 10: done or step 10: fail. (with error message).
I don't want the user just hang on to wait until stored procedure finishes and just see the final result message. I want them to see some kind of live execution of stored procedure, so that user is well updated of where the stored procedure is.Some stored procedures are quick and take few seconds to finish, some are very slow and take even 1 hour to finish.
Now the question is: how could I push theses step messages from SQL Server to web application, so that in web browser, user can see each step message get printed in real-time fashion?
I search lots of info, the best i can see is model controller notifies view once there's change in model, but still need model controller to pull from SQL Server, I don't see any real push from SQL Server to web application. Your advice is highly appreciated.
One approach would be to create a log table at the start of the procedure, with a unique name. The MVC code would display a grid or other element showing this log table, the stored procedure would simply add rows to the table after each step is complete...
Grab the session ID of the connection
The procedure creates a file called LOG_SessID
The MVC opens the table and uses the Meta Refresh or a Timer to redisplay the page
Each redisplay checks to see if the table still exists, if not, it
assumes the procedure is done and prints the appropriate message
One possible solution can be that you break your SP into steps and call each Step's SP and update the User screen (even have separate MVC VIEWS/PARTIAL VIEWS for each step's success and failure) based on the result!

Resources