Questions tagged [database-locking]
129 questions
35
votes
5 answers
How do I lock on an InnoDB row that doesn't exist yet?
How can I guarantee that I can search if a username exists in my database, then insert that username into the database as a new row without any intercept between the SELECT and INSERT statements?
Almost as if I am locking on a row that doesn't…

xLite
- 1,441
- 3
- 15
- 28
13
votes
3 answers
how does SQL Server know to lock view objects?
In SQL Server 2008 I have a view V over tables A and B that looks roughly like
create view V as
select * from A
union all
select * from B
Reading from V causes a query to take intent shared locks on the base tables, but also takes an…

Joe Kearney
- 7,397
- 6
- 34
- 45
11
votes
4 answers
Will Oracle lock the whole table while performing a DML statement or just the row
When i try to insert/update something in a db table, will Oracle lock the whole table or only the row being inserted/updated?
Is this something that can be controlled through external configuration?

Victor
- 16,609
- 71
- 229
- 409
9
votes
4 answers
inno db isolation levels and locking
I am reading a manual about innodb transactions but still, there is lots of unclear stuff to me. For instance, I don't quite understand to the following behaviour:
-- client 1 -- client 2
mysql> create table simple (col…

clime
- 8,695
- 10
- 61
- 82
9
votes
1 answer
When and how does Postgres use "transactionid" locks
I've ran into a need to figure this out on 9.6, but information on anything 9.6 or later would be appreciated.
I'm having an issue with my application being blocked on a database call because it's attempting to acquire an implicit transactionid lock…

Pawel Veselov
- 3,996
- 7
- 44
- 62
8
votes
1 answer
Postgres long-running transaction holding lock on parent partitioned table
TL;DR: we have long-running imports which seem to hold locks on the parent partitioned table even though nothing is directly referencing the parent table.
Background
In our system, we have inventories and inventory_items. Inventories tend to have…

Alexander Wallace Matchneer
- 3,289
- 1
- 23
- 26
8
votes
1 answer
Transaction lock in MongoDB
I am trying to develop a booking system, that books different assets after checking its availability. The system first tries to read records from the DB and checks if the slot being booked is available. If so, the system books the slot for them by…

sasidhar
- 7,523
- 15
- 49
- 75
7
votes
2 answers
How to update an object or bail if it has been deleted in Django
I have a Django app saving objects to the database and a celery task that periodically does some processing on some of those objects. The problem is that the user can delete an object after it has been selected by the celery task for processing,…

mgalgs
- 15,671
- 11
- 61
- 74
7
votes
3 answers
What is the difference between an explicit and an implicit lock in database?
What is the difference between an explicit and an implicit lock in database?

DayDayUp
- 71
- 1
- 1
- 2
6
votes
2 answers
SQLITE_BUSY The database file is locked (database is locked) in wicket
I am doing a project in wicket
How to solve the problem.
I came across such a message:
WicketMessage: Can't instantiate page using constructor public itucs.blg361.g03.HomePage()
Root cause:
java.lang.UnsupportedOperationException: [SQLITE_BUSY] The…

Burak Dağlı
- 512
- 2
- 10
- 33
6
votes
1 answer
What's the default lock granularity in SQL Server?
I've thoroughly read MSDN about table hints and I don't seem to find the locking granularity default. Suppose I have the following query:
SELECT TOP (1) * FROM MyTable WITH (UPDLOCK, READPAST) ORDER BY SomeColumn ASC;
You see, I specified UPDLOCK…

sharptooth
- 167,383
- 100
- 513
- 979
5
votes
1 answer
Mysql Deadlock - Is a transaction waiting on a lock it holds?
I'm having trouble interpreting this deadlock output from MySql (5.7, InnoDB). I understand that the deadlock will eventually be solved by changing application level code, and you can't find the root cause from this snippet. However, hopefully…

Kevin
- 1,080
- 3
- 15
- 41
5
votes
1 answer
Locks in elasticsearch
I tried to find on google but no success.
Can anybody explain at what level elastic search take locks to handle multiple threaded or multi process environment?
Whether it is at index or doctype or a particular document in a doc-type?

Prannoy Mittal
- 1,525
- 5
- 21
- 32
4
votes
1 answer
How to implement database locking across several function in a code igniter model?
I'm creating a system that involves the reservation of tickets by many users within a short period of time with only a certain number of reservations possible in total. Say 600 tickets available, potentially all being reserved in 3 hour period or…

CalumJEadie
- 189
- 4
- 12
4
votes
1 answer
Deadlock in mysql while adding foreign key
There is a table named company_competitors in our database. there is a job which truncates and loads this table daily.
The table has two columns company_id and competitor_id both references another table companies.
CREATE TABLE `company_competitors`…

Yash Thenuan
- 591
- 5
- 17