A mechanism for managing concurrent access to shared data or resources by granting temporarily exclusive access to the processes requesting the lock.

learn more… | top users | synonyms (1)

2
votes
0answers
19 views

Does Disabling Page Level Locking Have an Adverse Effect on Other DBs

I got the following from a vendor about what their software (“IM”) needs: “IM needs its own SQL Server Instance if the DB is installed on a shared SQL server. This is a mandatory prerequisite because ...
1
vote
1answer
61 views

PostgreSQL optimistic reads (equivalent to SQL Server's Read Committed Snapshot)

Does PostgreSQL provide a built-in optimistic concurrency control mechanism such as SQL Server's Read Committed Snapshot Isolation? Readers can read all the rows without blocking, but writes will ...
2
votes
0answers
47 views

SQL Server Check Constraint Lock Order

I'm having problems with SQL Server 2012 filetable. Filetable defines an check constraint on a path_locator field with definition as: /*ParentsAreDirectories*/ ...
3
votes
1answer
117 views

How to get SQL insert and/or update to not lock entire table on MS SQL Server

Very much a newbie on DB work, so appreciate your patience with a basic question. I'm running SQL Server 2014 on my local machine, and I have a small table and a basic client application to test ...
1
vote
2answers
43 views

SELECT…FOR UPDATE - Will only an UPDATE release the lock?

I'm using a SELECT ...FOR UPDATE in a Java PreparedStatement. I may or may not need to execute the update depending on the results of the SELECT. If I execute a rs.close(); or pStmt.close(); without ...
9
votes
2answers
178 views

Good reasons to use SELECT… WITH XLOCK?

I am facing some re-occurring deadlocks, one of which is a Keylock and contains a SELECT query with XLOCK hint that becomes the deadlock victim. The other statement is an INSERT into one of the tables ...
1
vote
2answers
46 views

How can I ensure that only one user at a time can call a stored procedure? Can I lock an SP?

I have a procedure that generates reports basis user requests. The request is such that at a time only one user can call the procedure. Is there any way I can handle this using DB2? Like place a lock ...
13
votes
1answer
194 views

Massive INSERTs blocking SELECTs

I have a problem with a massive amount of INSERTs that are blocking my SELECT operations. Schema I have a table like this: CREATE TABLE [InverterData]( [InverterID] [bigint] NOT NULL, ...
0
votes
0answers
14 views

ReportServerTempDB - SessionLock table Locked [duplicate]

When a number of SSRS reports are run in a short period of time, I see a number of locks occur on the ReportServerTempDB. The table locked is dbo.SessionLock. The locks sit there until I restart the ...
4
votes
1answer
46 views

Deadlock best practices

We are running Postgres 9.3, and we have occasional deadlock issues. Currently someone notices and will manually kill off the processes. Is there a best practice in dealing with these when they ...
6
votes
1answer
348 views

What happens when we add an index to an existing table with a large amount of data?

I've a table which will contain around ~15 Million records. Now I need to add an index to the table. Adding an index will take some time to update every entry in the table. I'm quite confused ...
7
votes
1answer
145 views

Does UPDLOCK guarantee concurrency

I have a table called tblOrderNumber which has 1 row and 1 column. This table stores what the next order number will be for my ecommerce website. It is ABSOLUTELY VITAL that the same order number is ...
1
vote
0answers
27 views

How to make a PostgreSQL trigger thread-safe

I want to make my PostgreSQL trigger function do something like incrementing counters etc (something complex with multiple queries etc) thread-safely (so the same function triggered concurrently won't ...
0
votes
1answer
36 views

Generate incrementing IDs without sequences

Suppose there's a multi-tenant application where users can create some kind of documents with basic structure like CREATE TABLE users (id SERIAL PRIMARY KEY, email TEXT); CREATE TABLE documents ( ...
0
votes
1answer
26 views

Putting an order in the way how locks are aquired in MySQL

From MySQL documentation: A locking read, an UPDATE, or a DELETE generally set record locks on every index record that is scanned in the processing of the SQL statement. It does not matter whether ...
1
vote
1answer
32 views

Help understanding InnoDB Deadlock Detection

I have a deadlock occurring when executing an Update and a Select in seperate threads but I'm not sure what can be done about it. Previously my understanding was that this could happen in parallel but ...
2
votes
1answer
26 views

Which Table Will Get Locked With This Query

INSERT INTO stats.cps (time_stamp,entries,cust_id) select start_time, count(*) , c_id from gb.str where start_time between '$DATE10' and '$DATE' group by start_time, src_id order by start_time ASC ...
4
votes
1answer
159 views

“Lock request time out period exceeded” when publishing SqlServer databases in parallel

I am working on a continuous integration environment using SqlServer2014. There I need to publish many SqlServer databases simultaneously on the same instance. Our publish process uses a .sqlproj file ...
1
vote
1answer
98 views

Excessive page locking

There is a query: SELECT entry_id FROM table_name WHERE (path_id = 7 AND value_string = N'00020003-0004-0005-0006-000700080009' ) The table in this query contains some millions of records. Both ...
1
vote
2answers
80 views

DB randomly locks up when innodb_buffer_pool_size is set high

I have been struggling to work out what could be happening here but for many months, since upgrading to mysql 5.6 we seem to be experiencing random lag spikes in page loads which has been tracked back ...
4
votes
2answers
77 views

Best practice regarding concurrency for INSERT into a table with composite primary key?

Say I've got the tables users, teams and a teams_users junction table (team_ID, user_ID / composite PK). If I wanted to add a user to a team, what's the best option when it comes to performance / ...
2
votes
1answer
24 views

Refreshing a table using CREATE TABLE, DROP and Rename

A read-only database (database1) is updated via log shipping every minute, then a procedure queries multiple tables in it and refreshes a large table on database2. For this process I run an ...
1
vote
0answers
26 views

2 phase locking with added increment mode

I have this assignment question where increment mode is added in addition to read and write lock modes in two phase locking.But I cant seem to figure out whether each lock mode has its own seperate ...
1
vote
1answer
79 views

Locking and checkout mechanism

Tables: Clients (20+ fields) Id int, Name varchar, [State] varchar, Address varhcar ClientCheckout ClientId CheckedOutAt Datetime null I'm using a separate table for managing the ...
3
votes
2answers
65 views

How to handle lock information?

Due to analyzing several deadlocks I used sp_blitzIndex to get an overview about locks. There is a high accordance between the tables (and views) affected by the deadlocks and the tables being ...
0
votes
0answers
76 views

Long running query with index seek

I was tuning this query, the execution plan looks fine for me but based on the statistics the Lock waits time is very high .What should i do to fix this problem? (@P0 bigint) SELECT mgmtemails0_.Id ...
1
vote
1answer
81 views

How do I insert tens of thousands of rows without locking?

I have a server that receives data from thousands of locations all over the world. Periodically, that server connects to my DB server and inserts records, one row at a time in rapid succession. There ...
1
vote
1answer
47 views

Using RowLock to enforce Once-And-Only-Once

I have a Web Service that can fire off a chain of events for an order. It does this when it gets a message telling it to (max of about 2 per second). The problem I have is that I have more than one ...
1
vote
0answers
56 views

How to avoid deadlocks when running queries on a remote server

I need to pull data from many different systems, all on remote, LIVE SQL Servers into one place for a one-off piece of work that will last a few weeks. This has to be run multiple times during the ...
2
votes
0answers
88 views

SELECT blocking SELECT?

I have huge outputs from pg_stat_activity and the result from the second "combination of blocked and blocking activity" report from https://wiki.postgresql.org/wiki/Lock_Monitoring (2nd version), with ...
0
votes
2answers
136 views

FLUSH TABLES WITH READ LOCK not working?

I use this command to "lock" my database, flush logs , take a LVM snapshot and release it. Testing the recover + binlogs , appear it's not working. (I discovery this when during the recover, applying ...
9
votes
1answer
118 views

Blocked sessions waiting with PAGELATCH_* wait types?

Edited : Why are sessions reporting being blocked but waiting with PAGELATCH_*, and not LCK_M_ related wait types? I previously assumed that SQL server would only report a blocking session in the ...
1
vote
0answers
45 views

Long Transaction On File Upload Locks Strategies

I need to upload files to some SFTP or FTP servers (using libcurl) and register them in database. For this I have several tables -- locations to store files - some SFTP and FTP servers CREATE TABLE ...
0
votes
1answer
39 views

Global Read Lock for Snapshot of MySQL Data

I have a database that is entirely comprised of MyISAM tables(yes, I did not create it). I need to create a slave and start replication so we could point read-only queries there. Here is my idea: ...
2
votes
2answers
113 views

Is there any reason not to use foreign keys in MySQL?

I've never really used foreign keys before but I am building a project where they could come in handy. I have looked at some other large software such as some forum systems and they don't use foreign ...
2
votes
1answer
129 views

what happens when I try to insert data into mysql while table is locked?

Simple question but somehow impossible to find a clear answer: What happens when I try to insert data into mysql while the table is locked? 1) INSERT query fails 2) INSERT query waits until lock is ...
0
votes
2answers
99 views

How to manage concurrencies without locking tables in MySQL?

In our php app, we have a table that records orders recieved at the reception. Since we can have up to 7 agents/active accounts, how is it possible to manage the concurrencies in the orders table ...
1
vote
2answers
85 views

Oracle UPDATE statements lock race condition

Say I have a table MY_TABLE without optimistic lock column. I have the following update statement that will be executed with org.hibernate.SQLQuery: UPDATE MY_TABLE SET NAME = ? WHERE SOME_NUMBER = ? ...
5
votes
1answer
297 views

Why does UPDLOCK cause SELECTs to hang (lock)?

I've got a select in SQL SERVER that locks the whole table. Here's the setup script (make sure you don't overwrite anything) USE [master] GO IF EXISTS(SELECT 1 FROM sys.databases d WHERE d.name = ...
3
votes
2answers
207 views

Using sp_getapplock to implement a queue. Is it correct? Is there a better way?

I've been reading a series of posts by Paul White about SQL Server Isolation Levels and came across a phrase: To emphasise the point, pseudo-constraints written in T-SQL have to perform ...
1
vote
2answers
59 views

Can I make postgres more verbosely tell me what it's doing?

I'm trying to use ALTER TABLE on a live db (not in production, just poking around at a dev box and trying to learn some things) Here is the command I'm trying: psql -h $IP -p 5432 -U $DBUSER -d ...
2
votes
1answer
67 views

Deleting large amounts of cascading records with minimal locking

I'm looking for a strategy to purge large amounts of logically deleted data from a MySQL database. The deleted records are in a relatively small table, but are referred to with many ON DELETE CASACDE ...
3
votes
1answer
134 views

Can a Table Lock eliminate a deadlock or make it worse Oracle

We have a situation in which an Oracle Database is having deadlocks issues. I said that perhaps we should lock into some table locks, and a guys response to me was "Unless I am misunderstanding ...
2
votes
1answer
135 views

how to find the T-SQL of a sleeping session that is blocking some other process?

I have a stored procedure called sp_radhe that I put on my servers and it has been helping me to "see" what is happening internally. here is the code of this stored procedure: USE [master] GO SET ...
1
vote
2answers
174 views

FLUSH TABLE : can't execute the given command because you have active locked tables mysql

If I execute these queries one by one, all fail except the first: Query1 : flush table tablename1 with read lock; Works Query2 : flush table tablename2 with read lock; Error : can't ...
5
votes
1answer
184 views

Exactly what error is returned by PostgreSQL `FOR UPDATE NOWAIT` when a selected row cannot be locked immediately?

The PostgreSQL 9.4 documentation states that adding the NOWAIT option to a SELECT FOR UPDATE means an error is generated when a row cannot be locked: To prevent the operation from waiting for ...
1
vote
2answers
72 views

Spotlight for SQL Server LockType explanation required

I have just started using Spotlight as I'm a software developer, but I am forced to identify database issues causing blocking (Spotlight shows me AWAITING_COMMAND at the points and all other processes ...
1
vote
0answers
40 views

Row locks on selects

select t.*, row_number() over ( partition by t.Entity_Identifier order by t.Message_Sequence ) as seqnum from Process_Activity t (ROWLOCK) where t.Process_Id = Is it possible for ...
5
votes
1answer
162 views

Locking in Postgres for UPDATE / INSERT combination

I have two tables. One is a log table; another contains, essentially, coupon codes that can only be used once. The user needs to be able to redeem a coupon, which will insert a row into the log table ...
0
votes
1answer
63 views

MySql Lock Tables Blocking Logic

The MySQL documentation (5.5) for Lock tables states: Let's say that I'm trying to lock table1 and table2 in a single query, but table2 is already locked. Will MySQL hold onto a lock on table1 and ...