locking

Problem with MySQL RENAME and CREATE TABLE statements clashing

I have a problem where a RENAME statement clashes with a CREATE TABLE statement to cause deadlock. I have a CREATE TABLE statement of the form CREATE TABLE `ProductTitles` ( PRIMARY KEY (`ProductId`), INDEX ( `Title`, `ProductScore` ) ) SELECT p.ProductId, p.Title, ps.ProductScore FROM Products p JOIN ProductScores ps USING...

SQL Server transactions - whole db locked ?

Hi, I have a problem on specific SQL Server 2008 customer installation. I wrote the code below to simulate the problem which happens in more complex system. There are two connections (each one with own transaction) opened and each connection modifies a table. Modified tables do not relate to each other. On development platform and other ...

Default table lock hint on SQL Server 2005/2008

How do you look up a default global table locking hint? -- Questions Are there any DMV/DMF (Dynamic Management View/Function) that return such information? And also, is there a way to change the default lock hint? Currently I am adding nolock hint almost everywhere to prevent locks. I'd like to avoid doing so by changing the d...

Setting Locking Granularity for All Statements in a Stored Procedure - Microsoft SQL Server 2000

I'm developing an ETL application with batch processing. There is low (i.e. no) concurrency for updates. I'd like to avoid the overhead of granular locks and lock escalation by merely locking the entire table. I'd like to avoid having to specify TABLOCK in every statement. Is there any way to set the locking granularity at the top of...

Default Locking Granularity for Local Temp Tables - Microsoft SQL Server 2000

What is the locking granularity used for local temp tables in MSSQL? Given that local temp tables are local to sessions, and sessions are the same as connections in MSSQL2K, and that there is no way to execute any statements or other code in parallel on the same connection through TSQL or other means (I believe), then intuitively the DB...

Perforce File Locked By Departed User

I have a file that is locked/checked out exclusively by a user who is no longer with the company. I need to make changes and want to know how to "steal the lock". ...

MySQL Cluster transaction isolation level - READ_COMMITTED

Hello, I'm a beginner. I'm learning by mostly reading the documentation. Unfortunately, http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html#isolevel_read-committed doesn't say anything, while it says everything. Confused? Me too. ndb engine supports only "READ_COMMITTED" transaction isolation level. A. It starts by saying "set...

Locking a static field

I'm maintaining an application that consumes a common library that has a static instance of a class(ClassWrapper). This class is a basically a wrapper around the Microsoft patterns and practices's CacheManager (v3.1 of the EL) The library is hosted in a web application and also in a windows service app, (both are inherently multi thre...

Understanding locking behavior in SQL Server

I tried to reproduce the situation of question [1]. On table, taken and filled with data from wiki's "Isolation (database systems)" [2], in SQL Server 2008 R2 SSMS, I executed: 1) first in first tab (window) of SSMS -- transaction isolation level in first window does not influence results (?) -- initially I thought that second ...

Does python's fcntl.flock function provide thread level locking of file access?

Python's fcnt module provides a method called [flock][1] to proved file locking. It's description reads: Perform the lock operation op on file descriptor fd (file objects providing a fileno() method are accepted as well). See the Unix manual flock(2) for details. (On some systems, this function is emulated using fcntl().)fu...

LINK : fatal error LNK1104: cannot open file 'D:\...\MyProj.exe'

Using Visual Studio 2010, when I build + run my application in short intervals I often get the following error. If I just wait a minute or two and try again it works fine. Unlocker claims no handle is locking the executable file. How can I discover what's locking it? If it's Visual Studio itself, what should I do to make it stop? or alte...

Lock a hashset in Java

I have a static HashSet of object references in my code, which has to disallow all write requests until a given method is running (which uses the hashset only for read purposes). I have read the Thread basics but am yet not clear how to proceed doing this. Can anyone please help me out ? ...

Any downsides to locking a collection vs. a syncRoot?

I'm wondering if there are any downsides to locking over a collection such as a List<T>, HashSet<T>, or a Dictionary<TKey, TValue> rather than a simple object. Note: in the following examples, that is the only place where the locks occur, it's not being locked from multiple places, but the static method may be called from multiple threa...

Handling Simultaneous Session Updates

In my django app, I have one AJAX view that gets flooded with calls to an update method, which I'll call IncrementMagicNumber: def IncrementMagicNumber(request) : number = request.GET['increment'] request.session['magicnumber'] = request.session['magicnumber'] + int(number) return HttpResponse("OK!") This works fine for one u...

wxWidgets and locking resources.

I'm new to wxWidgets (C++), and threads for that matter. What should I be aware of concerning shared resources? Should I implement some sort of semaphore-based locking of resources that may be used by both the GUI thread and the worker thread(s)? Does wxWidgets offer some capability for dealing with this? ...

flock() question

I have a question about how flock() works, particularly in python. I have a module that opens a serial connection (via os.open()). I need to make this thread safe. It's easy enough making it thread safe when working in the same module using threading.Lock(), but if the module gets imported from different places, it breaks. I was thinkin...

Locking Windows Phone with Custom Screen C#

I need to lock Windows Mobile Screen (without using default locking system) on perticular activity. I have seen on web that developers are using SHDeviceLockAndPrompt or EnableHardwareKeyboard for achieving lock. This will show default window lock screen. I need to show my screen with own checking of password with my own database. How ...

Oracle equivalent of ROWLOCK, UPDLOCK, READPAST query hints

In SQL Server I used the following hints inside queries: rowlock (row level locking) updlock (prevents dirty reads) readpast (don't block waiting for a rowlock, go to the first unlocked row) e.g. select top 1 data from tablez with (rowlock,updlock,readpast); Are there equivalent in-query hints for Oracle? ...

Initialize costly value in map with minimum lock contention (C++)

Suppose we have a map that is shared between multiple threads. It represents a node in some hierarchical structure (say, a directory in a file system) that is stored on disk. Constructing a Value is expensive both in time and in memory. This is the classic 'initialize on demand' problem, with a twist: we're initializing values in a map w...

Select top N with "for update skip locked" in Oracle

In Oracle, I can select the top 1 message in a sorted table with select messageid from( select messageid, RANK() over (order by messageid asc) as msg_rank from messages ) where msg_rank=1; And as I discovered in a previous question I can select a row exclusively with select * from messages where rownum < 2 ...