locking

lock down view to be uneditable

I am building a database that contains public, private(limited to internal) and confidential data (limited to very few). It has very specific requirements that the security of the the data is managed on the database side, but I am working in an environment where I do not have direct control of the permissions, and requests to change the...

How to don incremental multi user updates with NHibernate

Hello, I use nhibernate as my orm and i am trying to implement something that looks straightforward but has become unneccessarily difficult. It concerns how to implement concurrent updates to an entity where it is expected that the entity will be updated simultaneously by more than one user in a multiuser scenario. The entity is an acc...

Blocking a record from editing while another user is editing the record - how?

I'm trying to add record locking to a site. This isn't database locking where I have 2 processes editing the same record at the same time, but instead 2 users editing the same record at the same time. Here's the situation: I need to be able to lock a record while 1 person is editing it so someone else can make changes to record at the s...

Block a row from reads whilst sp executes

Hi, I have many .NET processes reading messages from an SQL Server 2008 DB table and processing them one at a time. I implement a simple SP to 'lock' the row that is being read by any one process, to avoid any two processes processing the same row. BEGIN TRAN SELECT @status = status FROM t WHERE t.id = @id IF @status = 'L' BEGIN ...

Distributed locking in .NET

I'm looking for recommendations for a locking mechanism that will work across multiple machines. In my case I basically just want to be able to start a service on 2 machines and have one block until the other finishes as a simple way to insure redundancy in case a service machine goes down. Sort of along the same lines as http://stacko...

Synchronized block lock object question

I know the difference between synchronized method and synchronized block but I am not sure about the synchronized block part. Assuming I have this code class Test { private int x=0; private Object lockObject = new Object(); public void incBlock() { synchronized(lockObject) { x++; } System.out.println("x="+x); ...

MySql Transactions

So I have two methods. Method one adds a row to my database. Method two selects and updates the latest 10 rows of the table. If method one adds a new row after method two selects the data but before it updates it will method two update the wrong 10 rows? Will transactions help here or do i need to lock tables? function one(){ inser...

PH&Sessions: Is there any way to disable PHP session locking?

Hi. Is there any way to disable the session locking in PHP while using the default session handler? [EDIT:] Or is there at least a way to restart a session after calling session_write_close()? `session_start()' does not work if any output is already sent to the browser. Thanks, Taloncor ...

spin_lock on non-preemtive linux kernels

I read that on a system with 1 CPU and non preemtive linux kernel (2.6.x) a spin_lock call is equivalent to an empty call, and thus implemented that way. I can't understand that: shouldn't it be equivalent to a sleep on a mutex? Even on non-preemtive kernels interrupt handlers may still be executed for example or I might call a function...

Mutual Exclusion Without Touching Both Processes

I have a unique problem. There are two processes (P0 and P1) trying to access one file. P0 is writing information to the file and P1 is reading the information. There is a race condition occurring between the two in which P1 is reading before P0 is finished writing. I have considered using Locks, Semaphores, etc. However, P1 exists in a ...

Large array and multiple threads - spinlocks or local buffers or something else?

I have an array with 250k entities (with a size of 20 bytes) and 4 threads. Each thread modifies ~100k random entities (that means, you can't predict which entities it will touch). It can modify the same entity multiple times. Each entity gets modified up to ~10 times. The modification takes ~10-6 seconds. Each entity gets modified by m...

Berkeley DB: Number of lock objects for hash access method

Hello, This page says that "for the Hash access method, you only need a single lock object". http://www.oracle.com/technology/documentation/berkeley-db/db/programmer_reference/lock_max.html Does this mean that all the processes/threads that access the database will try to lock the same lock object? Doesn't it cause a very high lock co...

Python 3.2 - GIL - good/bad?

Python 3.2 ALPHA is out. From the Change Log, it appears the GIL has been entirely rewritten. A few questions: Is having a GIL good or bad? (and why). Is the new GIL better? If so, how? UPDATE: I'm fairly new to Python. So all of this is new to my but I do at least understand that the existence of a GIL with CPython is a huge deal...

Master database DB STARTUP problem

I have a SQL Server 2008 database and I have a problem with this database that I don't understand. The steps that caused the problems are: I ran a SQL query to update a table called authors from another table called authorAff The authors table is 123,385,300 records and the authorsAff table is 139,036,077 The query took about 7 days e...

Is this a valid use of the lock keyword in C#?

I have a singleton class AppSetting in an ASP.NET app where I need to check a value and optionally update it. I know I need to use a locking mechanism to prevent multi-threading issues, but can someone verify that the following is a valid approach? private static void ValidateEncryptionKey() { if (AppSetting.Instance.EncryptionKey.Equ...

Only inserting a row if it's not already there

Hello, I had always used something similar to the following to achieve it: INSERT INTO TheTable SELECT @primaryKey, @value1, @value2 WHERE NOT EXISTS (SELECT NULL FROM TheTable WHERE PrimaryKey = @primaryKey) ...but once under load, a primary key violation occurred. This is the onl...

XCode SVN lock - unlock

i am developing iphone projects on xcode. In SCM i am using svn but it is not possible to lock a file that on the svn to prevent other team member check out the file again (it copies the hole project to work offline). Is there any extension for xcode to solve that problem? ...

Lock file but allow usage by current process?

I want to be able to lock a file in Win32 so that it can only be used by my current process. The most obvious way to accomplish that seemed to be via CreateFile: HANDLE file = ::CreateFile("c:\\foo.txt", GENERIC_READ | GENERIC_WRITE, 0, NULL, ...

Deleting many rows without locking them

Hello good people. In PostgreSQL I have a query like the following which will delete 250k rows from a 1m row table: DELETE FROM table WHERE key = 'needle'; The query takes over an hour to execute and during that time, the affected rows are locked for writing. That is not good because it means that a lot of update queries have to wait ...

I want to the information about my screen (if it's locked or not), Android

Hi there, i'm making a program that disables your wifi when you lock your screen but i can't find an object the holds that kind of information (wether it's locked or not) ...