Questions tagged [deadlock]

Situation where two (or more) operations need overlapping sets of resources, and neither can complete because they cannot obtain all locks necessary to complete an operation and release their locks.

Deadlock is situation where multiple operations are waiting for same resource(s) while simultananeously holding other resources that other threads holding the desired resources are waiting for.

For example, given resources A,B,C and processes 1,2.

  1. 1 locks A and B
  2. 2 locks C
  3. 2 needs A to finish
  4. 1 needs C to finish.

Neither 1 or 2 can release resources before finishing. Therefore, deadlock occurred.

The classical solution to all deadlock problems is to always acquire the resources in the same order in all threads or processes.

Reference

Deadlock in Wikipedia

3451 questions
1
vote
1 answer

Role of System.out.format in Oracle's deadlock example

I was going over several deadlock examples and noticed interesting thing while playing with Oracle's sample: https://docs.oracle.com/javase/tutorial/essential/concurrency/deadlock.html. If you substitute this line: System.out.format("%s: %s" + " …
Yulaz
  • 81
  • 8
1
vote
1 answer

Is mutation safe on a static variable from multiple thread in crystal-lang?

Consider this example - class Test @@store = "" end Here store is a class variable of Test and can be mutated from anywhere. Suppose i am runing my program in multi thread mode & so variable store can be mutated from multiple thread at a time.…
Ujjwal Kumar Gupta
  • 2,308
  • 1
  • 21
  • 32
1
vote
1 answer

Synchronized call of functions using std::condition_variable

I got addicted to learning concurrency again and tried to solve this problem. In short, I have a class and 3 functions. I need to sync their calls (need to print FirstSecondThird). It will become more clear with the code below: std::function
Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
1
vote
1 answer

MPI_Bcast hanging sometimes

I have the following block of code that runs MPI_Bcat. Strangely the process sometimes hangs sometimes when I run it but not others. The debug info shows all processes reached line 129 (all process 0 to n-1 printed bcast start). But they never…
Dogemore
  • 590
  • 1
  • 5
  • 18
1
vote
1 answer

EventListener is returning to a thread that didn't call it. This is creating a deadlock when it calls methods in the main thread

I am logging and fairly new to threads. My main thread is 1, a listener is started in another thread and on return calls to my main methods come from another thread. This is creating a deadlock on yet another thread which is in a 3rd party package.…
Al G Johnston
  • 129
  • 2
  • 10
1
vote
1 answer

How do you logically formulate the problem of operating systems deadlocks?

It is a programming assignment in Prolog to write a program that takes in input of processes, resources, etc and either print out the safe order of execution or simply return false if there is no safe order of execution. I am very new to Prolog and…
user6913551
1
vote
1 answer

MySQL inserts holding locks on unrelated tables

I'm getting this strange deadlock from MySQL: ------------------------ LATEST DETECTED DEADLOCK ------------------------ *** (1) TRANSACTION: TRANSACTION 2300749061, ACTIVE 1 sec inserting mysql tables in use 1, locked 1 INSERT INTO…
Tyler S
  • 11
  • 3
1
vote
0 answers

Deadlock between 2 INSERT's in the same table

We just started resolving deadlocks happening in our system. We've traced most of it except for the least frequent case: a deadlock in the same table between 2 INSERT transactions. What could be causing the deadlocks? Info we have: It happened…
Oyen
  • 344
  • 2
  • 14
1
vote
4 answers

What are the problems of using transactions in a database?

From this post. One obvious problem is scalability/performance. What are the other problems that transactions use will provoke? Could you say there are two sets of problems, one for long running transactions and one for short running ones? If yes,…
Vinko Vrsalovic
  • 330,807
  • 53
  • 334
  • 373
1
vote
1 answer

Setting DEADLOCK_PRIORITY in L2S/Entity Framework

Had a little trouble with deadlocks and one of the actions (aside from the "get rid of the deadlock in the first place" action) is to set the deadlock priority of one particular stored procedure so that it should never be chosen as the victim (it is…
Duncan
  • 10,218
  • 14
  • 64
  • 96
1
vote
0 answers

MySQL Deadlock: Transaction holds and waits for the same lock

at the moment I'm sitting on a problem that turns out to be a deadlock within our backend. In order to be able to possibly reproduce the problem, I have had the "LATEST DETECTED DEADLOCK" output via the command "SHOW ENGINE INNODB…
1
vote
1 answer

Channels consumer blocks normal HTTP in Django?

I am running a development server locally python manage.py runserver 8000 Then I run a script which consumes the Consumer below from channels.generic.websocket import AsyncJsonWebsocketConsumer class MyConsumer(AsyncJsonWebsocketConsumer): …
Pithikos
  • 18,827
  • 15
  • 113
  • 136
1
vote
2 answers

Confused about defer in goroutines

I came across the following code snippet that demonstrates the 'broadcast' functionality in sync.Cond. The snippet is as follows: package main import ( "fmt" "sync" ) func main() { type Button struct { Clicked *sync.Cond } …
sc_ray
  • 7,803
  • 11
  • 63
  • 100
1
vote
1 answer

Async task deadlocks if task is extracted first

I'm using Microsoft's AsyncHelper (source) to call an async method from a synchronous context. This works just fine: Result r = AsyncHelper.RunSync(async () => await SomeClass.SomeMethodAsync()); However, if I extract the Task and then try to run…
TheHvidsten
  • 4,028
  • 3
  • 29
  • 62
1
vote
1 answer

May be a bug in tomcat 9.0.26 when i meet a deadlock

when i press test my application with spring boot 2.1.9.RELEASE and tomcat 9.0.26 i meet a deadlock. It's maybe a bug with tomcat. when i use tomcat 8.5.49 instead the bug is not appear. The follow is the stack i dump from my application. Found one…
echo
  • 21
  • 1
  • 3