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
0 answers

How can I use PTHREAD_PRIO_INHERIT and PTHREAD_PRIO_PROTECT properly?

I have been trying to use some ways to prevent Priority Inversion problem but I still have deadlock issue. I found out that there are some protocols which library provide such that PTHREAD_PRIO_INHERIT and PTHREAD_PRIO_PROTECT. I set…
methamphetamine
  • 148
  • 1
  • 5
1
vote
2 answers

Java multithreaded program (producer and consumer) hangs..?

I have a simple variant of the producer and consumer example in Java. I think it should work ok but it hangs. I first thought it might be some form of deadlock, but when I look at the thread dump, it seems it's stuck in the middle of a infinite…
pilsungk
  • 13
  • 3
1
vote
1 answer

Deadlock error occurrd when query mysql in golang, not in query segment but after out of "rows.Next()" loop

when i use golang to query mysql, sometimes i found "deadlock err" in my code. my question is not "why deadlock occurred", but why deadlock err found in "err = rows.Err()". in my mind, if deadlock occurred, i should get it at "tx.Query"'s return…
1
vote
0 answers

Executing a query whose table is being run in a stored procedure

I was assigned to make a stop button for our system transaction. Upon clicking the button STOP, I must be able to interrupt the stored procedure A and rollback. So I made a few checkers in my stored procedure. Here's an example flow of my stored…
1
vote
3 answers

How can i detect a deadlock?

I just recently started learning go and wanted to test my skills by writing a program that calculates all amicable and perfect numbers. Sadly I'm having issues with my code! If anyone knows how I can stop the program after all numbers are…
Jooarye
  • 27
  • 3
1
vote
1 answer

Understanding Deadlocks in MySQL

I am new to MySQL, I used to work in Oracle database. I am having some problem in resolving Deadlocks in my application. Please help me to understand the issue. Table Definition: CREATE TABLE `APPLICATION` ( `ID` varchar(60) CHARACTER SET…
1
vote
0 answers

Deadlock Encountered when using pt-online-schema-change

I am running pt-online-schema-change, creating an index on a column in that table. pt-online-schema-change D=pt_osc,t=pt_osc_Test,h=abcd-test.com,u=pt-osc --ask-pass --alter 'add index idx_CREATED_DATE(CREATED_DATE)' --alter-foreign-keys-method=auto…
1
vote
0 answers

parallelStream() seems to be deadlocking when called from static{} block

I have a strange deadlock that only seems to happen outside of main(). static { init(); } private static final void init() { ForkJoinPool forkJoinPool = null; try { forkJoinPool = new…
jordan t
  • 136
  • 10
1
vote
1 answer

2 competitive AI with Minimax

Simplified Game Rules: Pawns can move once per turn. Pawns can move in 4 directions. (up, down, left, right) Pawns move on a grid like a chess board. Pawn reaching the other's row wins. Other rules can be ignored for simplicity. Evaluation…
1
vote
1 answer

How to prevent deadlock in recursive function?

I have a recursive function that I will lock and mutate its internal state, however, it causes a deadlock. How can I implement such a recursive function without deadlock? package main import ( "fmt" "sync" ) type runner struct { …
Leo Zhang
  • 3,040
  • 3
  • 24
  • 38
1
vote
1 answer

After upgrade from MySQL 5.5 to 5.7 queries are more frequently encountering deadlock

Recently we migrated our production DB to Amazon RDS with version upgrade from 5.5 to 5.7 using AWS DMS service. After that, we are frequently getting deadlock issues for our insert...on duplicate key update queries and update queries. Whereas in…
Akhil Mathew
  • 1,571
  • 3
  • 34
  • 69
1
vote
0 answers

Transaction with many deletes followed by many inserts with Hibernate and Spring

I use spring boot + MySQL5 database. There is a periodic service that runs and need to do the following transaction: Delete records (with condition) Insert records In addition another service does select queries and should see a snapshot of the…
nadavgam
  • 2,014
  • 5
  • 20
  • 48
1
vote
2 answers

If I open and read the file which is periodically written, can I/O deadlock occur?

In my server process, it looks like this: Main backend processes: Processes Huge list of files and , record them inside MySQL. On every 500 files done, it writes "Progress Report" to a separate file /var/run/progress.log like this "200/5000 files…
Phyo Arkar Lwin
  • 6,673
  • 12
  • 41
  • 55
1
vote
2 answers

How to fix 'This operation can be a deadlock cause'

When i call sendDM() the second time i get a deadlock warning. How can i fix this? Im using the JDA Api and im trying to get the Message which i sent with the RestAction .complete() private void start(){ sendDM(getP1().getUser()); …
Gamal Hassan
  • 31
  • 2
  • 3
1
vote
1 answer

PDO false positive deadlock

We are running basic web app on PHP 7.0 and MariaDB 10.0. Every query goes into the database via PDO class. The problem is that PDO sometimes throws deadlock exception: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to…
Martin K
  • 21
  • 4