deadlock

Acquiring multiple locks atomically in java

﹥>﹥吖頭↗ 提交于 2019-12-04 10:57:11
I have the following code: Note: I simplified the code as much as possible for readability. If I forgot any critical pieces let me know. public class User(){ private Relations relations; public User(){ relations = new Relations(this); } public getRelations(){ return relations; } } public class Relations(){ private User user; public Relations(User user){ this.user = user; } public synchronized void setRelation(User user2){ Relations relations2 = user2.getRelations(); synchronized(relations2){ storeRelation(user2); if(!relations2.hasRelation(user)) relations2.setRelation(user); } } public

WinForms multithreading issue

孤者浪人 提交于 2019-12-04 10:56:59
Ive got a thread that does some work in the background and passes updates to the Form using the Invoke, BeginInvoke methods. The thread is created after the form is displayed so no issue there. The issue is how to correctly shutdown. My worker thread has the ability to be asked to exit, and will exit some time soon after that (miliseconds). However if the form has closed first the Invoke stuff breaks. I tried adding a Thread.Join to the forms closing event, but of course this causes a deadlock, even for BeginInvoke since somhow a Thread.Join blocks a BeginInvoke on that thread... What is the

Python's time.sleep - never waking up

岁酱吖の 提交于 2019-12-04 10:53:03
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 producer thread making work-items for them. The producer thread is being triggered by a test-case. In this test, only one task is being put on the queue. The processing it does is in the test is just a stub for the real processing, so the worker thread does a 5

How to avoid the deadlock in a subprocess without using communicate()

本秂侑毒 提交于 2019-12-04 10:38:10
问题 proc = subprocess.Popen(['start'],stdin=subprocess.PIPE,stdout=subprocess.PIPE) proc.stdin.write('issue commands') proc.stdin.write('issue more commands') output = proc.stdout.read() # Deadlocked here # Actually I have more commands to issue here I know that communicate() can give me a solution to this problem but I wanted to issue more commands later. But communicate() kind of closes the subprocess. Is there any know work around here for this. I am trying to interact with a router using a

how to avoid deadlock in mysql

痴心易碎 提交于 2019-12-04 10:36:46
问题 I have the following query (all tables are innoDB) INSERT INTO busy_machines(machine) SELECT machine FROM all_machines WHERE machine NOT IN (SELECT machine FROM busy_machines) and machine_name!='Main' LIMIT 1 Which causes a deadlock when I run it in threads, obviously because of the inner select, right? The error I get is: (1213, 'Deadlock found when trying to get lock; try restarting transaction') How can I avoid the deadlock? Is there a way to change to query to make it work, or do I need

How commonly do deadlock issues occur in programming?

隐身守侯 提交于 2019-12-04 10:26:25
I've programmed in a number of languages, but I am not aware of deadlocks in my code. I took this to mean it doesn't happen. Does this happen frequently (in programming, not in the databases) enough that I should be concerned about it? Deadlocks could arise if two conditions are true: you have mutilple theads, and they contend for more than one resource. Do you write multi-threaded code? You might do this explicitly by starting your own threads, or you might work in a framework where the threads are created out of your sight, and so you're running in more than one thread without you seeing

How to get rid of deadlock in a SQL Server 2005 and C# application?

旧巷老猫 提交于 2019-12-04 09:58:28
I have a code in C# for windows service which is mainly responsible to update records in a table in my database, but I get always a lot of errors in my log, all errors are about deadlock of resource, This is the error: System.Data.SqlClient.SqlException (0x80131904): Transaction (Process ID 57) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action 1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning

SQL deadlock on delete then bulk insert

﹥>﹥吖頭↗ 提交于 2019-12-04 09:06:51
I have an issue with a deadlock in SQL Server that I haven't been able to resolve. Basically I have a large number of concurrent connections (from many machines) that are executing transactions where they first delete a range of entries and then re-insert entries within the same range with a bulk insert. Essentially, the transaction looks like this BEGIN TRANSACTION T1 DELETE FROM [TableName] WITH( XLOCK HOLDLOCK ) WHERE [Id]=@Id AND [SubId]=@SubId INSERT BULK [TableName] ( [Id] Int , [SubId] Int , [Text] VarChar(max) COLLATE SQL_Latin1_General_CP1_CI_AS ) WITH(CHECK_CONSTRAINTS, FIRE_TRIGGERS

Is fork (supposed to be) safe from signal handlers in a threaded program?

喜欢而已 提交于 2019-12-04 08:56:30
问题 I'm really uncertain about the requirements POSIX places on the safety of fork in the presence of threads and signals. fork is listed as one of the async-signal-safe functions, but if there is a possibility that library code has registered pthread_atfork handlers which are not async-signal-safe, does this negate the safety of fork ? Does the answer depend on whether the thread in which the signal handler is running could be in the middle of using a resource that the atfork handlers need? Or

Sql Server Deadlock Object IDs are too large

淺唱寂寞╮ 提交于 2019-12-04 08:39:01
问题 I am trying to trace a deadlock that is occurring in our SQL 2005 database (64-bit). We do not currently have snapshot isolation enabled. I turned on tf-1204 and received the output below. From this output I am able to determine that Node 1 is a stored procedure that selects data and only modifies values in #temp tables. Node 2 is another stored procedure does a simple primary key based update on a single row of data. What I can't determine is the actual resource that was in contention here.