locking

How to write my own global lock / unlock functions for PostgreSQL

I have postgresql (in perlu) function getTravelTime(integer, timestamp), which tries to select data for specified ID and timestamp. If there are no data or if data is old, it downloads them from external server (downloading time ~300ms). Multiple process use this database and this function. There is an error when two process do not fin...

How to improve INSERT INTO ... SELECT locking behavior

In our production database, we ran the following pseudo-code SQL batch query running every hour: INSERT INTO TemporaryTable (SELECT FROM HighlyContentiousTableInInnoDb WHERE allKindsOfComplexConditions are true) Now this query itself does not need to be fast, but I noticed it was locking up HighlyContentiousTableInInnoDb, even though i...

Database locking: ActiveRecord + Heroku

I'm building a Sinatra based app for deployment on Heroku. You can imagine it like a standard URL shortener but where old shortcodes expire and become available for new URLs (I realise this is a silly concept but its easier to explain this way). I'm representing the shortcode in my database as an integer and redefining its reader to give...

ActiveRecord and transactionsin between `before_save` and `save`

I have some logic in before_save whereby (only) when some conditions are met I let the new row be created with special_number equal to the maximum special_number in the database + 1. (If the conditions aren't met then I do something different, so I can't use auto-increments) My worry is that two threads acting on this database at once m...

iPad Orientation Lock Notification?

Is there a way to receive a notification when the iPad gets orientation locked? When the orientation lock is set on or off, it does send a receivedRotate: notification, but I need a way to be able to distinguish normal rotations from lock "rotations". The problem is I am rotating things in my view when the rotation changes. When the loc...

Does IsolatedStorageFileStream.Lock work under SIlverlight4?

Silverlight uses an IsolatedStorageFileStream to open files. The IsolatedStorageFileStreamunder NET.4 claims to support the Lock Method (Inherited from FileStream) The following code IsolatedStorageFile isf; IsolatedStorageFileStream lockStream = new IsolatedStorageFileStream( "my.lck", FileMode.OpenOrCreate, isf ); lockStream.Lock(...

Java Concurrency: CAS vs Locking

Im currently reading the Book Java Concurrency in Practice. In the Chapter 15 they are speaking about the Nonblocking algorithms and the compare-and-swap (CAS) Method. It is written that the CAS perform much better than the Locking Methods. I want to ask the people which already worked with both of this concepts and would like to hear ...

Isolation level and DIRT READ SQL SERVER 2005 (advanced question)

Hi all! I will describe my problem for an easier explanation: I have a table and my soft is accessing it (update, insert) using transaction. The problem is that I want to enable DIRT READ in this table. But I cant use with (nolock) in my sql statements because I cant change the soft source. So I was thinking in enable dirty read in th...

What data is actually stored in a B-tree database in CouchDB?

I'm wondering what is actually stored in a CouchDB database B-tree? The CouchDB: The Definitive Guide tells that a database B-tree is used for append-only operations and that a database is stored in a single B-tree (besides per-view B-trees). So I guess the data items that are appended to the database file are revisions of documents, no...

ZooKeeper and RabbitMQ/Qpid together - overkill or a good combination?

Greetings, I'm evaluating some components for a multi-data center distributed system. We're going to be using message queues (via either RabbitMQ or Qpid) so agents can make asynchronous requests to other agents without worrying about addressing, routing, load balancing or retransmission. In many cases, the agents will be interacting w...

FileStream to save file then immediately unlock in .NET ?

I have this code that saves a pdf file. FileStream fs = new FileStream(SaveLocation, FileMode.Create); fs.Write(result.DocumentBytes, 0, result.DocumentBytes.Length); fs.Flush(); fs.Close(); It works fine. However sometimes it does not release the lock right away and that causes file locking exceptions with functions run after this on...

sql rowlock on select statement

I have an ASP.Net webpage where the user selects a row for editing. I want to use the row lock on that row and once the user finishes the editing and updates another user can edit that row i.e. How can I use rowlock so that only one user can edit a row? Thank you ...

What does System.Concurrency.AsyncLock do?

The System.Reactive.dll adds a class AsyncLock to System.Concurrency. It has a single instance method, Wait, that takes an Action. The documentation page I found just tells it it pre-release documentation, so I ask here: What does this class do? ...

Is MySQL InnoDB is appropriate for this scenario?

My MysQL database contains multiple MyISAM tables, with each table containing millions of rows. There is a heavy insert load on the database, so I cannot issue SELECTs on that live database. Instead, I create a replica of the database for queries and conduct analysis on that. For the analysis, I need to issue multiple parallel queries....

linq to sql with nservicebus table lock issue

I am building a system using NServiceBus and my DataLayer is using Linq 2 SQL. The system is made up of 2 services. Service1 receives messages from NSB. It will query Table1 in my database and inserts a record into Table1 If a certain condition is met a new NSB message is sent to the 2nd service Service2 will update records also in Ta...

.NET 3.5 C# does not offer what I need for locking: Count async saves until 0 again.

I have some records, that I want to save to database asynchronously. I organize them into batches, then send them. As time passes, the batches are processed. In the meanwhile the user can work on. There are some critical operations, that I want to lock him out from, while any save batch is still running asynchronously. The save is don...

Oracle transaction read-consistency ?

I have a problem understanding read consistency in database (Oracle). Suppose I am manager of a bank . A customer has got a lock (which I don't know) and is doing some updating. Now after he has got a lock I am viewing their account information and trying to do some thing on it. But because of read consistency I will see the data as ...

Is lock returned by ReentrantReadWriteLock equivalent to it's read and write locks?

Hello, I have been looking around for the answer to this, but no joy. In Java, is using the lock created by ReentrantReadWriteLock equivalent to getting the read and write locks as returned by readLock.lock() and writeLock.lock()? In other words, can I expect the read and write locks associated with the ReentrantReadWriteLock to be re...

lock shared data using c#

Hi, I have a program (C#) with a list of tests to do. Also, I have two thread. one to add task into the list, and one to read and remove from it the performed tasks. I'm using the 'lock' function each time one of the threads want to access to the list. Another thing I want to do is, if the list is empty, the thread who need to read from ...

Release another user's lock obtained with sp_getapplock on SQL Server

We have a system that uses sp_getapplock to create an exclusive mutex any time someone opens an order in the GUI. This is used to prevent multiple people from making changes to an order simultaneously. Sometimes people will open an order and go home, leaving it open. This effectively blocks anyone from being able to make changes to the ...