locking

read-access to a MyISAM table during a long INSERT?

On mysql and using only myisam tables, I need to access the contents of a table during the course of a long-running INSERT. Is there a way to prevent the INSERT from locking the table in a way that keeps a concurrent SELECT from running? This is what I am driving at: to inspect how many records have been inserted up to now. Unfortuna...

How to use tcp_keepalives settings in Postgresql?

Postgresql has 3 keepalive settings for managing dropped connections (in postgresql.conf): tcp_keepalives_count tcp_keepalives_idle tcp_keepalives_interval By default these are 0. The behavior I would like is for Postgresql to drop client connections after a period of time, should the client lose its network connection or go to sleep....

C# - confused on lock

Hello guys, For my network based project I need to lock some codes to prevent simultaneous access. This is my code using System; using System.Collections.Generic; using System.Linq; using System.Text; using Utility; using DataBaseConnection; using System.Net.Sockets; using System.Data; using System.IO; namespace SunHavenClasses { ...

When is a database table locked?

Is a table locked every time I insert sth. in it? Because I want to insert thousands of rows each second so I want to know if having more than one thread for inserting helps effectively or not. If each insert locks the table just one thread is almost as efficient as for example 10 threads. If it depends on the Database engine, I use SQL ...

Subsonic: Select on a View, locks the table update?

Hi, I have a Web site live and running now. I am using the Subsonic to handle the database connections etc. I am getting time out expired error while updating a table (say Employee). When I check sp_who2, I see the suspended connection for the PID which is updating with a block by anothor pid, so I run the profiler and found out when e...

What SQL-Server lock level is suitable for insert?

I want to make almost 1000 inserts in a table in each second. And also each day I want to query all inserted rows just once at altogether. And I want to improve efficiency by multi-threading and connection-pooling. But i want to know which level of concurrency control is more suitable for me. The list of options for SQL-Server are in MSD...

How to find locked rows in Oracle

We have an Oracle database, and the customer account table has about a million rows. Over the years, we've built four different UIs (two in Oracle Forms, two in .Net), all of which remain in use. We have a number of background tasks (both persistent and scheduled) as well. Something is occasionally holding a long lock (say, more than 3...

.NET app locks file

Okay I;m really new to VB.NET and desktop application development. Simplified this is what is happening in my application: Dim Files() As New List(Of IO.FileInfo) Files.Add( (New IO.FileInfo("C:\img1.jpg")) ) Files.Add( (New IO.FileInfo("C:\img2.jpg")) ) 'Picture is a Windows.Forms.PictureBox in my WinForm ' Picture.Image = New System....

In .Net using File.CreateText() also locks file, why?

I was using the CreateText method to create an empty file (as below) in "App1". Then tried to have another application write to that file but it failed b/c it was locked. It was not unlocked until I closed "App1" File.CreateText(path) To fix this I can do this: Dim sw As StreamWriter = File.CreateText(path) sw.Close() Why does ca...

Handle version conflict when multiple concurrent editor on the same model rails

how to Handle version conflict when multiple concurrent editor on the same model rails? for example user A click edit on the post controller and start editing the content user B click edit on the post controller and start editing the title user B is done and click save user A is done and click save and override the modifications done by...

oracle db lock issue, commit

This is oracle 10g. If I issue an update on a table from sqlplus but do not commit, then in another session update the same row and try to commit, it just hangs until I commit the first one. I know some would argue it's the locking mechanism but the application we have does the same thing and users are being blocked. Whats the best way ...

How can I lock a file from a program started as a cron job on Linux?

I use fcntl in my codes to lock file and unlock to practice like mutex in windows... I start my app in linux manually, i got right result, with the app runs smoothly... but i was asked to make a bash script to start the app daily.... my script is cd myapppaht ./myapp however, i got [Bad file descriptor] when it try to lock a file pos...

Lock mechanism between process on multiple machines

I have a C# application with NHibernate that must do some operations over a SQL Server DB. Our goal is to run this app multiple times in the same machine and also in other machines. Actually app insert a row in a SQL Table and check if the first row with minimum date is the row with the correct PID and machine name so the app set the l...

Need to beat the GC and have object destroyed once it goes out of scope

I have several sections of code that I need to protect with a Mutex. The problem is that the code looks something like this: lock(mylockobject) { if(!foo()) throw new MyException("foo failed"); if(!bar()) throw new MyException("bar failed"); } Using lock, it works as I'd like, but now I need to use a mutex. The obvious p...

Java Concurrency: lock effiency

Hello My program has 100 threads. Every single thread does this: 1) if arrayList is empty, add element with certain properties to it 2) if arrayList is not empty, iterate through elements found in arrayList, if found suitable element (matching certain properties), get it and remove the arrayList The problem here is that while one th...

should I lock 'event'?

should I lock event in the following case: event foo; thread A: will call foo += handler; thread B: will call foo -= handler; should I lock foo? ...

Is an operation in SQL guaranteed to be atomic if performed in a single update statement?

I'm trying to remove the need to explicitly lock a table with the following code but from reports I've been getting it may be possible that the parameter and value in the row are suffering from a race condition. Declare @NextNumber Int; Update MyParameterTable Set NextNumber = NextNumber + 1, @NextNumber = NextNumber + ...

Is there a physical lock that can demonstrate asymmetric crytographic principles?

I wish to demonstrate asymmetric encryption using real-world locks. For example, I want to write a secret on a piece of paper and deposit it in a locked box. Is there a lock I can buy that comes with two keys, one that only locks the lock and another that only unlocks the lock? ...

Is a lock (threading) atomic?

This may sound like a stupid question, but if one locks a resource in a multi-threaded app, then the operation that happens on the resource, is that done atomically? I.E.: can the processor be interrupted or can a context switch occur while that resource has a lock on it? If it does, then nothing else can access this resource until it'...

Lock usb when plugged in c#

Hey, I am trying to make a program that when a usb is plugged into the computer it will lock the usb, so it is not accessable, and then when the user enters the correct password the usb will be accessable. Is this possible? Any help would be appreciated, Thanks. ...