Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [deadlock]

A situation caused by two or more processes being unable to proceed (and thus release their locks) because they are blocked by locks on resources held by the other process.

Filter by
Sorted by
Tagged with
3 votes
1 answer
114 views

Locking for update inside CTEs

If I make a query using CTEs that looks like that: WITH cte_a AS ( SELECT a.id, a.something FROM a WHERE a.something IS NOT NULL ), -- [...] some other CTEs cte_d AS ( SELECT ...
Adrian B.'s user avatar
  • 167
4 votes
1 answer
91 views

Deadlocks in Update/Insert procedure

I have an UPDATE and INSERT stored procedure for a table which is getting executed multiple times to update rows (once every 5 seconds). This procedure is used in multiple procedures so the execution ...
HITESH KARSHINKAR's user avatar
0 votes
0 answers
11 views

Getting Deadlock in Azure SQL Server and Victim query in Microsoft Internal Query

I am getting Deadlock in Azure SQL Server There is only 1 Victim query which "Looks like" Microsoft Internal query. The other Query is Alter Column Statement ALTER TABLE [SomeSchemaName].[...
Sagar's user avatar
  • 101
2 votes
0 answers
29 views

Concurrent update to one record in same table created a deadlock between primary key and secondary index

Concurrent reqs under odd case has triggered the same update query twice which surprisingly led to deadlock between primary key and secondary index update in the same table. The update query will ...
kumarssk8's user avatar
8 votes
2 answers
577 views

%%LOCKRES%% - SQL Server - Row identifier causing Deadlocks - possible bug

Recently I came across an issue where I am facing deadlocks in SQL Server databases (19.2.56.2) due to the internal hashing mechanism of the Row identifier virtual column - %%LOCKRES%% On analysis I ...
Govardhanan's user avatar
1 vote
1 answer
86 views

Locks acquired during drop table (postgres)

I have a table A, that is referencing two other tables B and C. I would like to understand what's happening exactly when i am dropping A. When dropping A my understanding is that an access exclusive ...
Rémi Pradal's user avatar
0 votes
1 answer
58 views

Postgres VIEW locking: CREATE OR REPLACE vs. DROP and CREATE

My question relates to a production incident in which it was necessary to replace a poorly performing Postgres VIEW under load. We tried numerous times to redefine the VIEW using CREATE OR REPLACE; ...
Paul Keister's user avatar
0 votes
3 answers
261 views

Can using UPDLOCK and ROWLOCK help me fight of deadlocks in my situation?

I have a table tblImportData that looks like this CREATE TABLE [dbo].[tblImportData] ( [ImportDataID] INT IDENTITY(1,1) NOT NULL, [ImportFileNumber] VARCHAR(50) ...
GuidoG's user avatar
  • 129
-2 votes
1 answer
93 views

Data Is Null. The Method or Property cannot be call on null values. Exception

In my application ultiple users request the API and in the API I am calling the stored Procedure via Entity Framework but some times getting exception Data Is Null. The Method or Property cannot be ...
Diya Rawat's user avatar
0 votes
0 answers
84 views

Handling deadlocks in Laravel during concurrent DELETE and INSERT , ON DUPLICATE KEY UPDATE operations

in Laravel I have a service which is not wrapped in a transaction and involves both INSERT ... ON DUPLICATE KEY UPDATE and DELETE statements targeting the same table, customers. INSERT INTO customers (...
u LoV's user avatar
  • 1
2 votes
0 answers
94 views

'Deadlock found when trying to get lock; try restarting transaction' in AWS RDS MySQL 8.0.36 after upgrading from MySQL 5.7.42. Django v4.1.6

Following an upgrade of our AWS RDS instance from MySQL version 5.7.42 to version 8.0.36, we are encountering persistent deadlock issues across concurrent transactions, affecting even basic read ...
Karan Raj's user avatar
0 votes
0 answers
28 views

Deadlock - due to long transaction SQL server

I've got a stored procedure that runs 3 inner procedures all within a one BEGIN TRANSACTION. The environment is : Azure database sql as a result i have many deadlocks for the table : TranStatus. the ...
dexon's user avatar
  • 47
2 votes
1 answer
94 views

SQL Server 2016 Deadlock

I want to validate my understanding of the sqlserver deadlock report: context: parent_table(id); child_table(parent_id, col1, col2, ...); constraint primary_key(id) on parent_table; constraint ...
brownsugarpearl's user avatar
0 votes
0 answers
56 views

Are SERIALIZABLE deadlocks avoided or just detected?

SERIALIZABLE is the highest standard isolation level. It avoids dirty reads, phantoms,... by ensuring that, whatever happens, the ultimate result of a transaction schedule is equal to the result of a ...
A. Darwin's user avatar
  • 119
0 votes
1 answer
119 views

Understanding Lock Behavior in SQL Server Deadlock Scenario with INSERT

Hello SQL Server Experts, I'm currently experimenting with SQL Server deadlocks and have intentionally created one to better understand locking behavior. After setting up a test table, I ran two ...
Just a learner's user avatar
0 votes
0 answers
57 views

batch insert dead lock

Can anyone help me? Why is this deadlocked? mysql: 8.0.22 design tables Note that this is the desensitized table structure CREATE TABLE `room_db`.`Untitled` ( `id` bigint NOT NULL AUTO_INCREMENT, `...
atlan's user avatar
  • 1
2 votes
2 answers
197 views

SQL Server: Trigger with UPDATE statement causes deadlocks

I have added a trigger to perform a change tracking mechanism on a table that has a relatively high load. During testing, we encountered no issues but now as it is in production there are deadlocks ...
JannikB's user avatar
  • 21
0 votes
1 answer
325 views

PostgreSQL: does the order of rows in a bulk insert control the order of `FOR EACH ROW` triggers?

I have a trigger like BEFORE INSERT ON table_a FOR EACH ROW EXECUTE FUNCTION upsert_into_table_b(). If I execute a bulk insert like INSERT INTO table_a ([columns]) VALUES ([row 1 values]), ([row 2 ...
Nathan Long's user avatar
0 votes
1 answer
168 views

Mysql deadlock on non unique index

I'm getting the deadlock on MySQL v8.0.32 which is very strange for me because of the following: I'm trying to insert the data: parent-child record (users, user_roles) - each transactions inserts new ...
Andrey Khataev's user avatar
0 votes
1 answer
109 views

Getting deadlocks very frequently in Mysql insert query

=2023-09-15 15:16:35 0x1530b7bc17002023-09-15 15:16:35 0x1530b7bc1700 *** (1) TRANSACTION: TRANSACTION 55060584750, ACTIVE 0 sec inserting mysql tables in use 1, locked 1 LOCK WAIT 8 lock struct(s), ...
Paras Sahu's user avatar
1 vote
0 answers
137 views

Same update on different rows results in deadlocking

We are testing our SQL Server database for concurrency issues and it appears that a single, simple update statement being run concurrently in transactions is resulting in deadlocks. Here is the ...
theta-fish's user avatar
1 vote
1 answer
520 views

How to handle deadlocks while multiple batch inserts?

I need suggestions/ideas of handling a issue with deadlocks. I'm having multiple batch inserts commands to same table: insert into ip (id, p_id, m_type, m_id, sha256, path) VALUES ($1, $2, $3, $4, $5, ...
KaliTheGreat's user avatar
1 vote
1 answer
435 views

Postgres: deadlock when ATTACH PARTITION to a table with a lots of INSERTs

I have a partitioned table user_stay which has many INSERTs and UPDATEs. db=> \d user_stay; Partitioned table "public.user_stay" Column | ...
iForests's user avatar
  • 113
0 votes
1 answer
83 views

Simultaneous INSERTs which lock the target table inside a before-insert trigger result in a deadlock

I'm working on a web application which uses a PostgreSQL database for storage. There are many logical entities in this application which are related to each other like hotel --> hotel_floor --> ...
Alex F's user avatar
  • 101
0 votes
1 answer
57 views

Locking order in a nested query

I'm trying to prevent deadlocks in my code because i may use both in different parts of my project. Do they lock rows in the same order? Nested select * from `carts` where `carts`.`user_id` = ? and ...
Jacqueline's user avatar
0 votes
0 answers
202 views

Resolving deadlock between an UPDATE and a SELECT with query hint

I bumped into a page lock deadlock on a table when two queries are running at the same time in two separate sessions, one is selecting from the table (holds S lock on page x and waits for S lock on ...
user1589188's user avatar
0 votes
1 answer
238 views

Deadlock on DELETE statements (stored procedure & adhoc query)

I am experiencing an issue with deadlocks when running a stored procedure that is run every 15 minutes. There is also an adhoc query that is being run by an external program (I don't have access to). ...
Drees's user avatar
  • 11
0 votes
0 answers
83 views

Updating 2 tables in same order by 2 different process yield deadlock

For some reason, we have multiple processes that get a request to update some tables (legacy code). Let's say we have 2 process that simultaneously updating MyTable1 and MyTable2 in a transaction. ...
Imran Qadir Baksh - Baloch's user avatar
0 votes
1 answer
295 views

Is it safe to configure Lock Escalation as 'AUTO' for partitioned tables

LOCK_ESCALATION= AUTO. In one of our Data warehousing product we use partitioned tables. They are partitioned based on an integer column. We have implemented partitioning here so we can easily switch ...
ishan verma's user avatar
0 votes
2 answers
553 views

Deadlock while concurrently updating multiple rows on the same table

We have a database where concurrent kafka streams are updating multiple rows at the same time, We are seeing deadlock occur in very few cases and I am not entirely sure what's causing it --------------...
owl's user avatar
  • 3
1 vote
1 answer
714 views

Deadlock in AFTER INSERT trigger

I have an AFTER INSERT trigger for table A that updates multiple rows in table B (incrementing a column in table B). Normally, the web server would insert multiple rows into table A using a single ...
Alvin's user avatar
  • 35
0 votes
1 answer
2k views

Is deadlock possible on first SELECT FOR UPDATE in transaction in PostgreSQL

I've got a Deadlock error deadlock detected DETAIL: Process 14565 waits for ShareLock on transaction 1986906143; blocked by process 14567. Process 14567 waits for ShareLock on transaction 1986906141; ...
Dmitry's user avatar
  • 3
-1 votes
1 answer
340 views

MariaDB / MySQL: Database Froze

We have had weird database freezes happen randomly. Usually, killing the troublesome process or thread helps, but in this case, nothing helped at all! Nearly all of the queries in the process list ...
Areeb's user avatar
  • 107
1 vote
1 answer
652 views

How to determine if a query can potentially deadlock in Postgres?

When implementing database queries I'm often wondering if the query I'm writing can potentially deadlock when executed in parallel by many clients. Often I only find out by running the query in ...
bluenote10's user avatar
1 vote
1 answer
737 views

Why my clustered index causing deadlock (Keylocks and Pagelocks)

We are experiencing deadlock 2-3 times a day in SQL Server. Upon analysis, we have found that the deadlock is caused by a combination of keylock and pagelock occurring simultaneously. We are actually ...
Jishnu Chandran's user avatar
-1 votes
1 answer
3k views

How to avoid deadlock inside transaction? [closed]

I have a transaction that wraps two code paths that update/insert related tables in the opposite order. Outside of a transaction I understand why that would cause a deadlock, but why does it happen ...
chell's user avatar
  • 195
0 votes
1 answer
113 views

Deadlock, update where id=pk_value with different pk_values, figure out reason and how to fix

How it possible to have such kind of deadlock? id column is a unique primary key, so no gap to lock. I don't have any other conditions to lock more than one row. It is different rows, how that ...
Hayate's user avatar
  • 101
1 vote
0 answers
438 views

Deadlocks on Batch Updates Posgres 12

Having some massive issue with deadlocks currently and I can't seem to find anything that will fix it. We have a large sql query that contains quite a few CTEs, one of them does the locking/selecting ...
Matthew's user avatar
  • 11
1 vote
1 answer
94 views

Why is my non clustered index causing this deadlock?

I have an application that runs the following query in multiple parallel threads: update Table1 SET Col1 = 'Some value' WHERE Order_ID = @orderID Order_ID is NOT the primary key on this table, but ...
Eduardo Wada's user avatar
4 votes
1 answer
251 views

MySQL - Understanding what is causing deadlocks

I've researched the topic on the official documentation and other questions, however weeks into it I'm still failing to understand what's causing deadlocks in my application. It only happens in ...
DamiToma's user avatar
  • 141
1 vote
0 answers
250 views

What is the object involved in an Object Lock in SQL Server Profiler's Deadlock graph? [closed]

In searching documentation online, I have found that there can be row, page, or table locks. However, I ran a SQL Server Profiler trace and noticed both a Page Lock and an Object lock. I can easily ...
Paradox's user avatar
  • 155
3 votes
1 answer
2k views

Avoiding deadlocks when locking multiple rows without using NOWAIT

In a couple of answers I've been advised that NOWAIT is necessary to prevent deadlocks, which has surprised me because it's not mentioned in the Postgres documentation on locking and deadlocks Given ...
ChrisJ's user avatar
  • 601
0 votes
1 answer
378 views

Does UPDATE FROM VALUES lock rows in the order they are listed?

I'm bulk updating some rows using UPDATE ... FROM (values ... as described in this answer. Will the rows will be locked in the order that they appear in the values? Or do I need to do an explicit ...
ChrisJ's user avatar
  • 601
4 votes
1 answer
353 views

Why does SQL Server use INDEX SPOOL when there is already a relevant index during FK check?

I've got two tables in SQL SERVER 2019: Condition table with 2 FK on Reference table. Condition table has appropriate indexes on FK columns. The schema screenshot and SQL script to generate it are ...
Gleb Lashuk's user avatar
0 votes
1 answer
101 views

Cannot understand how deadlock happens

In fairly simple T-SQL code deadlock happens: INSERT INTO dbo.logs ( source, status, description, aId ) VALUES ( @source, @status, @description, @aid ) set @i = SCOPE_IDENTITY() if @...
mmierzwa's user avatar
0 votes
1 answer
350 views

Deadlock on Non Clustered Index

<deadlock> <victim-list> <victimProcess id="process1e4222068c8" /> </victim-list> <process-list> <process id=&...
JieLong's user avatar
  • 167
3 votes
0 answers
581 views

What is the cause of persistent SQL Server deadlocks with a chosen victim, where the victim is never stopped, and no transactions are rolled back?

We are experiencing an issue with Microsoft SQL Server where every few days of running our application against the database, it goes into a state where it keeps deadlocking. It logs a deadlock about ...
Mads K's user avatar
  • 31
1 vote
1 answer
161 views

MySQL does not open a transaction, is there a deadlock between different SQLs?

2 concurrent do not start transactions. Concurrent A locks 1-3-5 sequentially, of course, the actual locking process must be one by one.Concurrent B locks 5-8-1 sequentially, of course, the actual ...
feilong gao's user avatar
2 votes
1 answer
983 views

Deadlock on 2 inserts in MySQL

I'm trying to get this query to work: insert into `risks` (`created_at`, `description`, `metadata`, `notes`, `project_id`, `risk_number`, `updated_at`) values ( '2022-12-02 13:56:08.742', ...
jvdberg08's user avatar
0 votes
1 answer
82 views

Which two threads are handling which table and how to solve this?

I'm working on a multithreaded application (VB.Net/C#), who is working on an SQL-server database. Regularly, my customer is complaining that the application show "deadlock"-like exceptions ...
Dominique's user avatar
  • 581

1
2 3 4 5
13