Questions tagged [locks]

A lock generally refers to something that prevents another process from starting or accessing the same information until the lock is released. Use with an appropriate language tag. Do not use for physical locks.

433 questions
10
votes
1 answer

How to lock a row for select in MySQL

A program will SELECT several records from a table and update each row, while it can be executed many times, which will lead to several process will complete the same task simultaneously. How can I prevent two different processes to update the same…
Allen Koo
  • 1,996
  • 3
  • 14
  • 15
9
votes
3 answers

InnoDB SELECT ... FOR UPDATE statement locking all rows in a table

MySQL Server version 5.1.41 with InnoDB plugin enabled. I have the following three tables for invoices: invoices, invoice_components and invoice_expenses. Table invoices has invoice_id primary key. Both invoice_components and invoice_expenses are…
Miloš Rašić
  • 2,229
  • 5
  • 24
  • 43
9
votes
1 answer

Why isn't !locks working for me?

I'm using windbg (the latest available from the MSDN download page). I'm trying to debug a deadlock in my app, and !locks would be very useful. However, it's not working: 0:023> !locks NTSDEXTS: Unable to resolve ntdll!RTL_CRITICAL_SECTION_DEBUG…
i_am_jorf
  • 53,608
  • 15
  • 131
  • 222
8
votes
3 answers

How do I replace a table in Postgres?

Basically I want to do this: begin; lock table a; alter table a rename to b; alter table a1 rename to a; drop table b; commit; i.e. gain control and replace my old table while no one has access to it.
user3416742
  • 168
  • 1
  • 1
  • 7
7
votes
4 answers

Threads trying to acquire pthread_mutex_lock(&mutex) What happens if they don't get the lock?

C Programming: What happens when a thread tries to acquire a mutex lock, and fails to get it? Does it go to sleep? Will the thread be woken up when pthread_mutex_unlock(&mutex); is called? Then try to obtain the lock again?
Bobby S
  • 4,006
  • 9
  • 42
  • 61
6
votes
1 answer

Why python throws "multiprocessing.managers.RemoteError" for shared lock?

I am using python 3.6.7 with Ubuntu 18.04 After running the following script in which every process has its own shared lock : from multiprocessing import Process, Manager def foo(l1): with l1: print('lol') if __name__ == '__main__': …
6
votes
0 answers

Error: Could not do a physical-order read to fetch next row

We're facing an issue Error logged in application server log: "Error: Could not do a physical-order read to fetch next row" We are using IBM informix 12.10 database. I've checked for the locks using onstat -k, it shows the intent exclusive lock.…
Mukesh Tanuku
  • 61
  • 1
  • 2
6
votes
1 answer

What kind of lock is placed for SELECT statement within a transaction in SQL Server

I believe that each SELECT statement in SQL Server will cause either a Shared or Key lock to be placed. But will it place that same type of lock when it is in a transaction? Will Shared or Key locks allow other processes to read the same…
Junior
  • 11,602
  • 27
  • 106
  • 212
6
votes
2 answers

wakeup/waiting race in a lock?

I am reading through the OSTEP book by prof.Remzi http://pages.cs.wisc.edu/~remzi/OSTEP/ I could only partially understand how the following code results in wakeup/waiting race condition.(The code is taken from the books…
Raghupathy
  • 823
  • 1
  • 9
  • 21
6
votes
3 answers

All threads only in one method at a time?

I have several objects inheriting from ClassA, which has an abstract method MethodA. Each of these inheriting objects can allow up to a specific number of threads simutaneously into their MethodA. The catch: Threads can only be in an object's…
cdbeelala89
  • 2,066
  • 3
  • 28
  • 39
6
votes
1 answer

java.lang.IllegalMonitorStateException: object not locked by thread before wait()

But I am synchronizing on the 'roster' object everywhere it gets new'ed. How come ? The offending code: public Roster getRoster() { if (roster == null) { return null; } if (!roster.rosterInitialized) { try { …
kellogs
  • 2,837
  • 3
  • 38
  • 51
5
votes
1 answer

Windbg "!locks" command doesn't work, can I get information anyway?

While debugging dump files, regularly I need to check for locks, for which I use the windbg extension command !locks. When everything goes well, this provides an output like the following: CritSec +54a8a8 at 0054a8a8 WaiterWoken No LockCount …
Dominique
  • 16,450
  • 15
  • 56
  • 112
5
votes
0 answers

Informix error on read: could not do a physical order read

Problem in nutshell executed data updates on couple of tables using dbeaver later reads from these tables started failing looks like the rows/pages in these tables are locked by the session where updates are done cant seem to get the locks…
Schu
  • 1,124
  • 3
  • 11
  • 23
5
votes
2 answers

Why are locks said to violate the principles of abstraction and composability?

I failed to find any definite answer on Google or even StackOverflow to answer this question. From my understanding Threads that use locks can break abstraction Locks are not composable But how and why does a lock break abstraction and…
Starwolf-001
  • 182
  • 11
5
votes
1 answer

Synchronized Method vs ReentrantLock

Say I have a server with multiple threads that share a reference to a Data instance. Quick eg, edit1: Updated for readability public void main() { Data data = new Data(); ReentrantLock rl = new ReentrantLock(true); ReadThread t1 = new…
I2obiN
  • 181
  • 3
  • 18
1
2
3
28 29