deadlock

What's the best way to solve this kind of javascript dead loop?

Hi guys, Recently I'm maintaining a legacy project. I found one javascript dead loop problem in a page. The demo code is as follows. When the user clicks the first inputbox and type in 3 then directly click the second input box, the dead loop occurs. Now my question is what's the best way to solve or prevent this kind of problem? Great ...

How do I find out what type of locking a table has?

Hi all, I'm getting alot of deadlocks on a table. It is SQL Server 2005 the sp that is getting the error does the following Delete From EmployeeAccrualAdj Where EmployeeID = @iEmployeeID and SchemeCode = @sSchemeCode and AdjTypeCode = @sAdjTypeCode and EffectiveDate >= @dtDateFrom I'm trying to work out if the...

Acquire a lock on two mutexes and avoid deadlock

The following code contains a potential deadlock, but seems to be necessary: to safely copy data to one container from another, both containers must be locked to prevent changes from occurring in another thread. void foo::copy(const foo & rhs) { pMutex->lock(); rhs.pMutex->lock(); // do copy } Foo has an STL container and ...

How to catch SqlException caused by deadlock?

From a .NET 3.5 / C# app, I would like to catch SqlException but only if it is caused by deadlocks on a SQL Server 2008 instance. Typical error message is Transaction (Process ID 58) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. Yet, it does not seem to be a do...

Java Static-block Shutdown Hook with System.exit

This code will deadlock: public class Main { static public final Object a = new Object(); static { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { if (a == null); } }); System.exit(0); } static public void main(final String[] args) {} } This code will ex...

Thread Deadlock

I have 2 threads. One thread prints odd numbers and the second thread prints even numbers. Now, I have to execute the threads alternatively so that i can output 1,2,3,4,5,6,..... I have written a program for this and this is resulting in a deadlock. Can someone explain what is the problem with the code and how to rectify it? class Boo...

how to guarantee no deadlock

I was stuck at one question in an interview. Given two threads, and each one has a lock, how to guarantee no deadlock. My knowledge is that it is not easy to avoid deadlock, that's why I got stuck. Can anybody give a hint. Thanks! ...

Why is my DCOM client locking on a call to SendMessage?

Running on XP. I have a client that calls calls CoInitializeEx(NULL, COINIT_MULTITHREADED), loads a (local) DCOM object, and attaches an event interface so the DCOM object can send back events. The client looks a lot like notepad with a multi-line textbox covering the client area to display event messages. Here are the calls that create ...

How to avoid mysql 'Deadlock found when trying to get lock; try restarting transaction'

I have a innoDB table which records online users. It gets updated every page refresh by a user to keep track of which pages they are on and their last access date to the site. I then have a cron that runs every 15 minutes to DELETE old records. I got a 'Deadlock found when trying to get lock; try restarting transaction' for about 5 minu...

Deadlock occurs in Function Scoped Static variables (Thread Unsafe in VC++)

The question is how function-level statics are constructed when the function is called on multiple threads? Problem Description: Deadlock occurs and my application doesn't get terminated. During initialization of local static variable it tries to acquire MSVCR80!_lock and never gets hold on the lock. !locks command in WinDbg gives the ...

Python's time.sleep - never waking up

I think this is going to be one of those simple-when-you-see-it problems, but it has got me baffled. [STOP PRESS: I was right. Solution was found. See the answers.] I am using Python's unittest framework to test a multi-threaded app. Nice and straight forward - I have 5 or so worker threads monitoring a common queue, and a single produ...

Help Deadlock analysis

The Deadlock occurs in my application when initialization of local static variable happens in the function called from DLLMain Entry point with param DLL_THREAD_DETACH. Below is Windbg analysis This is usually caused by another thread holding the loader lock. Following are the Locks Held. CritSec ntdll!LdrpLoaderLock+0 at 7c97e178 ...

SQL 2008 SP - Deadlock cause or red herring?

One of my co-workers has a stored procedure that does the following Begin tran 1) Dynamically generate a select statement. 2) Insert into table x 3) Execute the select statement End tran If this stored procedure is ran by two septate threads simultaneously, he gets the following error: System.Data.SqlClient.SqlException: Transaction ...

Why Static variable initialization internally tries to acquire _lock(_EXIT_LOCK1)

Why Static variable initialization internally tries to acquire _lock(_EXIT_LOCK1)? Here is the calls stack when the initialization of a local static variable happens. *MSVCR80!_lock+0x2e MyDLL32.dll!_onexit(int (void)* func=0x0864ae10) Line 103 C MyDLL32.dll!atexit(void (void)* func=0x0864ae10) Line 127 + 0x9 bytes C* Can you p...

Troubleshooting a COM+ application deadlock

I'm trying to troubleshoot a COM+ application that deadlocks intermittently. The last time it locked up, I was able to take a usermode dump of the dllhost process and analyze it using WinDbg. After inspecting all the threads and locks, it all boils down to a critical section owned by this thread: ChildEBP RetAddr Args to Child ...

SQL Server Deadlock Fix: Force join order, or automatically retry?

i have a stored procedure that performs a join of TableB to TableA: SELECT <--- Nested <--- TableA Loop <-- | ---TableB At the same time, in a transaction, rows are inserted into TableA, and then into TableB. This situation is occasionally causing deadlocks, as the stored pr...

ASP.NET web app deadlocking - think it's caused by SQL Server locking

Our client's web app restarts suddenly at random intervals. For each restart, we've found an entry like this in the Windows Event Log: Event Type: Warning Event Source: W3SVC-WP Event Category: None Event ID: 2262 Date: 2/21/2010 Time: 1:33:52 PM User: N/A Computer: LIQUID-NXCFZ9DJ Description: ISAPI 'c:\WINDOWS\Microsoft.NET\Framework...

Deadlock in ruby code using SizedQueue

I think I'm running up against a fundamental misunderstanding on my part of how threading works in ruby and I'm hoping to get some insight. I'd like to have a simple producer and consumer. First, a producer thread that pulls lines from a file and sticks them into a SizedQueue; when those run out, stick some tokens on the end to let the...

question about InnoDB deadlock in MySQL?

I found this kind of interesting problem in MySQL InnoDB engine, could anyone explain why the engine always claim it's a deadlock. First, I created a table with a single row, single column: CREATE TABLE `SeqNum` (`current_seq_num` bigint(30) NOT NULL default '0', PRIMARY KEY (`current_seq_num`) ) ENGIN...

Debugging a tough LINQ-to-SQL Timeout

I'm getting a timeout error when trying to execute a LINQ (-to-SQL) query System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Now, this is not just a case of a slow query: I run the equivalent SQL in SQL Management Studio and it com...