Questions tagged [locking]
Locking allows different types of resources to be used exclusively by one process at a time.
8,808
questions
0
votes
2
answers
30
views
Symfony framework.lock with .env set-up
Problem
I need to setup Symfony framework.yaml parameter framework.lock with 2+ memcached servers using .env. But when I'm try to do so, it not recognize 2 servers, but only one and with glitch.
...
0
votes
0
answers
10
views
Resource (GPU) locking across docker swarm stacks
I've got multiple instances of the same stack running on a (currently single-node) swarm. They're logically totally separate and therefore should remain different stacks.
The only thing they share is ...
0
votes
0
answers
29
views
PostgreSQL's processes blocking each other are not detected as deadlock
PostgreSQL's version: 13.10
Configuration: deadlock_timeout: 1s, log_lock_waits: off
I found in the logs some detected deadlocks:
2023-09-22 16:54:19.425 UTC 650dc6ba.5732 497942 22322 ERROR: ...
1
vote
1
answer
31
views
Rails pessimistic locking strategy not working in a Rails 7 / Postgresql app
In a Rails 7 app, with Postgresql database, I have a model Stat with a jsonb field data. I have a large concurrency happening, with several asynchronous processes which will add their own line in the ...
0
votes
0
answers
35
views
Sybase to MSSQL migration: Lock Datarows while create table
I am migrating a Sybase DB to a SQL Server DB. I can see that existing Sybase tables have lock datarows or lock allpages specified along with create table statement something like this:
create table ...
-3
votes
0
answers
27
views
No composer.lock file present. Updating dependencies to latest instead of installing from lock file [closed]
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
You can install
composer install
...
0
votes
0
answers
49
views
Can compiler optimize away locks accessible to only one thread?
C# provides reentrant locking:
lock (obj) { ... }
Can the current C# compiler deduce, from context, that only one thread will ever have access to obj and therefore optimize away all (reentrant) ...
1
vote
1
answer
28
views
Informix - How to get wait value of current connection lock mode using SQL
How to get wait value of current connection lock mode using SQL. Is it stored anywhere in the system tables?
2
votes
1
answer
28
views
SQLAlchemy 2.0 option for LOCK TABLE?
Does SQLAlchemy 2.0 has any options to perform LOCK TABLE table_name sql query?
Seems, that SQLAlchemy docs lack that information.
As an example I would like to perform
create_engine().connect()....
0
votes
2
answers
50
views
In Python, multiple processes in a process pool encountered errors while modifying shared variables generated by the Manager module
from multiprocessing import Pool, Manager
def task(args):
k, v, sharedDict, lock = args
with lock:
if k not in sharedDict:
sharedDict[k] = {}
sharedDict[k]['...
0
votes
2
answers
47
views
Java multiple reads on same SQL table
I want to migrate my app to clusters so I have to
deal with mysql locking.
For this post, I have simple table with 'id' and 'flag' whether is
record updated or not.
There are 3 threads reading table ...
0
votes
1
answer
62
views
Why does modifying condition for condition variable require owning the mutex?
Consider this case (which is the standard usage in cppreferences):
std::atomic<bool> condition(false);
thread 1:
lock
// check condition the last time before waiting
if (condition == true) { ...
0
votes
0
answers
4
views
mariadb: select table prevents insertions due to locking
using mariadb 10.3.35, linux 7, no galera cluster, no slave: a simple instance.
I have 2 innodb big tables (millions of rows) that are identical, except one is partitioned and the other not:
CREATE ...
-1
votes
0
answers
13
views
How to create in sql this error:Lock wait timeout exceeded; try restarting transaction
I am trying to create an SQL query/s that will eventually end up in: " Lock wait timeout exceeded; try restarting transaction".
Can that be achieved using basic Select/Update commands in ...
0
votes
0
answers
4
views
Is this variant of double-checked locking safe?
Consider this code based on the examples on Wikipedia but note that the question isn't restricted to Java.
class Foo {
private Helper helper;
private int initialized = 0;
public Helper ...
0
votes
1
answer
46
views
How to store a uuid type into bigint effectively?
In my application in Python, I have a function that accepts (_id: uuid.UUID) which is 128-bit value. I need to store this value into postgres database as a advisory lock using pg_advisory_xact_lock ...
0
votes
0
answers
22
views
Advisory lock in Python not accepting bigint?
for my application I had to implement an transaction advisory_lock using sqlalchemy.
The function to lock on the id is like this:
async def acquire_lock(self, _id: int) -> None:
lock_query = ...
0
votes
0
answers
25
views
Laravel Atomic Locks
I want to use an atomic lock on a specific method in my controller. I tried implementing it and it works but not the way I expected it to.
I want the users to only submit a single request after every ...
0
votes
0
answers
35
views
Why does a locked mutex prevent http.ResponseWriter from sending a response?
I understand that one should unlock a mutex using defer in case an error comes up. Otherwise, if you left the mutex locked, other goroutines would be blocked if they tried to access it. But what I don'...
0
votes
2
answers
47
views
C# Mutex not beeing released? EZCAD2MUTEX_MARKING | Check if EzCad is Marking
I'm trying to detect whether the EzCad2 software is currently laser marking (mutex locked/signaled) or idle (mutex released/nonsignaled) using a publicly documented mutex. According to the ...
1
vote
1
answer
49
views
Datastore transaction does not lock
I'm trying to use Datastore as a distributed lock. Based on the docs, I'd expect the following to fail with datastore: concurrent transaction, but it only fails <5% of the time. The database used ...
0
votes
2
answers
87
views
What is the actual usecase of trylock in java
What is the actual usecase of trylock in java.
If I check trylock in if block and write an else block, I will end up loosing actual business logic which is there in if block and thread will never hit ...
0
votes
0
answers
29
views
Laravel job lock wait timeout, SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded
I got this below error
SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction (SQL: select * from jobs where queue = default and ((reserved_at is null and ...
0
votes
2
answers
57
views
How to mutex on a static function (in Java)?
I've been struggling with java mutexing for a while now, I'm trying to have ByteIterator objects each print a new (and unique) byte[] they get from the JobQueue, but they continually print repeat ...
0
votes
0
answers
15
views
Bitbucket git push tag --no-verify results is pre-receive declined because someone else has an LFS lock on a file
We have a release script that creates a branch, pulls in the commits necessary and then performs a commit and push of a tag. Originally we did not use the --no-verify push option but changed after ...
0
votes
1
answer
29
views
How to design a hotel booking system with a on hold feature
I encountered this system design question in a interview and I didn't have the best answer.
The question is: we want to hold a room for 5 mins for a user, how do we do that?
The inventory data looks ...
0
votes
1
answer
54
views
RAII Locking with std::lock_guard<std::mutex>(m_mutex); instead of std::lock_guard<std::mutex> lk(m_mutex);
It's probably a stupid question, but I discovered a few occurences of a lock_guard without variable.
void func() {
std::lock_guard<std::mutex>(m_mutex);
m_value = "2";
}
Instead ...
1
vote
1
answer
48
views
C++: atomically increment counter variable
If I have two std::atomic<int> counters, a and b (both only doing increments). What I want to do is increment a if it's strictly less than b, and return the old value of a. In the presence of ...
0
votes
0
answers
27
views
Manage shared data in multi-thread-process applications
I have a web application in Python. Each API request is handled in a new thread. Therefore, I need to use mutexes to prevent race conditions.
However, some threads can spawn new processes. One thread ...
-1
votes
1
answer
75
views
Improve lock process in ASP.net core
How can I improve the lock process in the following function?
This function adds the web sockets of users of each page of a site to the lists in a static dictionary
public void Add(TKey key, ...
0
votes
0
answers
54
views
Printf causes deadlock.. but why?
I was messing around with mutexes in C and found that the following program eventually deadlocks in the parent process if and only if there is a call to printf within the critical section in the child ...
0
votes
1
answer
64
views
Fail to unlock terraform state due to version not matching
I'm trying to unlock a terraform state with the command
terraform force-unlock <id>
but I'm getting
Failed to load state: Remote workspace Terraform version "1.4.5" does not match ...
4
votes
3
answers
256
views
Difference between threads in Go and C++
I have this thread safe queue (implemented in Go and C++) where I am spawning more than 100K threads to push data into a shared queue. On my laptop I have 8 cores and 16 logical processors with 16GB ...
0
votes
1
answer
28
views
How to set lock_timeout for transaction in snowflake through connection string
I am connecting snowflake via .net application, but currently my transaction are getting locked and default timeout for transaction locks are 12 hours can I set it to 5 mins through connection string
...
0
votes
0
answers
11
views
How to optimize query if it uses Pessimistic Write Lock
I have a method that can have 1000 requests per second. I need to pause request until one finishes the method. I used Lock Pessimistic Write but It slows response(time about 10 seconds )
What can do ...
2
votes
1
answer
33
views
Is it necessary to close the SharedMemory at all times?
I noticed constantly closing and opening memory under heavy loads affects performance (example 1 get/set_shm).
Can I keep an open SharedMemory in different processes and keep a link to a numpy array ...
0
votes
1
answer
19
views
Handling Concurrent Product Orders and Quantity Updates Safely in NestJS
I'm currently facing a challenge in my NestJS application related to managing concurrent product orders and quantity updates. Below is a simplified version of the code I'm using to create orders:
...
0
votes
0
answers
18
views
Should I make a mutex (or lock) for writing to LiteDatabase?
I am writing considerably many data to the LiteDatabase.
Fortunately there is only one UserCollection in the database.
I am not sure there would be a conflict when there are several write accesses at ...
0
votes
1
answer
125
views
Does VarHandle 'getAndSet' uses 'xchg' instruction, and how does x86 'lock' prefix handle backpressure?
While trying to understand how Java's VarHandle "getAndSet" worked as opposed to it's JDK7 version:
public final V getAndSet(V newValue) {
while (true) {
V x = get();
if (...
1
vote
1
answer
32
views
JavaDoc for AbstractQueuedSynchronizer is unclear
Two sentences in the JavaDoc for AbstractQueuedSynchronizer are in my opinion unclear/misleading, and therefore I would like to clarify such issues.
The first sentence states:
Even though this class ...
0
votes
0
answers
17
views
How to handle simultaneous read-write operations in MongoDB?
I'm struggling with concurrency access to a document of a mongoDB.
I would clarify some concepts.
I'm using mongoose
mongoose.connect('mongodb://127.0.0.1:27017/myapp');
const ProductSchema = new ...
0
votes
0
answers
22
views
What are cause executeUpdate to remain executable for long time until kill the db sessions?
I have valid update statement using below code but when call function executeUpdate()for some reasons it keep executing until kill session !!
this block of code executed once at time , as I am locking ...
0
votes
2
answers
52
views
Lock Condition.notify is throwing java.lang.IllegalMonitorStateException
I wrote a program to demonstrate Lock.Condition of java for multithreading purpose. I am getting IllegalMonitorStateException.
It is throwing an exception the below is output.
I am acquiring lock ...
0
votes
1
answer
46
views
What i am doing wrong? Excel lock range
What i am doing wrong?
I get error "impossible to set range property "locked"
For i = 1 To ActiveWorkbook.Worksheets.Count
For j = 1 To 2000
For k = 1 To 500
If ...
0
votes
1
answer
47
views
Lock on the SQL tables
Suppose I have a procedure, which is trying to insert records into a separate table one by one based on the condition evaluation and using sys_refcursor I am trying to out that table in which we ...
3
votes
3
answers
107
views
Can I use a non-atomic boolean to synchronize a shared vector between two threads, where one thread is reading and the other is writing?
I'm looking to create a fast synchronization model to share a message queue between two threads. I'm looking at a class with one vector, a mutex, and a dirty flag like so.
#include <vector>
#...
0
votes
0
answers
50
views
Why don't I see frequent thread ID changes when I use a lock from 2 threads?
The following program counts to hundret from two threads, both using the same iterator variable i.
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Security;
...
0
votes
0
answers
48
views
Record lock issue in MySQL
Since a couple of days, I've been experiencing a MySQL issue in a large table (over 800,000 records). I've determined so far that the issue so far seems to be with 2 records, s I'm unable to update ...
0
votes
0
answers
47
views
What's the proper way to use a lock guarded singleton between nested functions?
I have a arena singleton as following:
pub struct ComponentArena {
components: HashMap<ComponentID, Component>,
next_id: AtomicUsize,
}
impl ComponentArena {
pub fn new() -> Self ...
0
votes
0
answers
17
views
Heroku poatgres replication to Rds using Bucardo
i tried to set up a replication between Heroku postgres and rds via bucardo running on Ec2 instance.
I get an error when I try to add the sync , saying validation failed for herokudb
I can connect to ...