Hi,
we have a contention problem because of an application which tries to
insert a duplicate row in a table with primary key. This insert fails
of course but the locks are not released within this transcation.
Why DB2 does not release the X lock after a failed insert???
We use DB2 UDB EEE Version 7.2 Fixpak 9, but we also can reproduce the
Problem on DB2 UDB ESE 8.1 Linux Fixpak 4.
I can reproduce this behavior with the statements below.
db2 +c insert into testtab values(1)
DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0803N One or more values in the INSERT statement, UPDATE
statement, or
foreign key update caused by a DELETE statement are not valid because
the
primary key, unique constraint or unique index identified by "1"
constrains
table "DB2ADMIN.TESTTAB" from having duplicate rows for those columns.
SQLSTATE=23505
db2 get snapshot for locks for application agentid 3
Application Lock Snapshot
Snapshot timestamp = 22/04/2004
10.53.23.324831
Application handle = 3
Application ID = *LOCAL.DB2.040422084540
Sequence number = 0001
Application name = db2bp.exe
Authorization ID = DB2ADMIN
Application status = UOW Waiting
Status change time = Not Collected
Application code page = 1252
Locks held = 5
Total wait time (ms) = Not Collected
List Of Locks
Lock Object Name = 4
Node number lock is held at = 0
Object Type = Row
Tablespace Name = USERSPACE1
Table Schema = DB2ADMIN
Table Name = TESTTAB
Mode = W
Status = Granted
Lock Escalation = NO
Lock Object Name = 5
Node number lock is held at = 0
Object Type = Row
Tablespace Name = USERSPACE1
Table Schema = DB2ADMIN
Table Name = TESTTAB
Mode = X
Status = Granted
Lock Escalation = NO
Lock Object Name = 22
Node number lock is held at = 0
Object Type = Table
Tablespace Name = USERSPACE1
Table Schema = DB2ADMIN
Table Name = TESTTAB
Mode = IX
Status = Granted
Lock Escalation = NO
Lock Object Name = 0
Node number lock is held at = 0
Object Type = Internal V Lock
Tablespace Name =
Table Schema =
Table Name =
Mode = S
Status = Granted
Lock Escalation = NO
Lock Object Name = 0
Node number lock is held at = 0
Object Type = Internal P Lock
Tablespace Name =
Table Schema =
Table Name =
Mode = S
Status = Granted
Lock Escalation = NO
Thanks, Florian 10 5089
I doubt DB2 releases a (row) lock on statement failure.
You need to rollback or commit.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
I doubt DB2 releases a (row) lock on statement failure.
You need to rollback or commit.
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
"florian" <au*****@web.de> wrote in message
news:35*************************@posting.google.co m... Hi,
we have a contention problem because of an application which tries to insert a duplicate row in a table with primary key. This insert fails of course but the locks are not released within this transcation.
Why DB2 does not release the X lock after a failed insert???
We use DB2 UDB EEE Version 7.2 Fixpak 9, but we also can reproduce the Problem on DB2 UDB ESE 8.1 Linux Fixpak 4.
I can reproduce this behavior with the statements below.
db2 +c insert into testtab values(1)
When you use +c you are turning off auto-commit so you need to do an
explicit commit to release the lock(s).
"florian" <au*****@web.de> wrote in message
news:35*************************@posting.google.co m... Hi,
we have a contention problem because of an application which tries to insert a duplicate row in a table with primary key. This insert fails of course but the locks are not released within this transcation.
Why DB2 does not release the X lock after a failed insert???
We use DB2 UDB EEE Version 7.2 Fixpak 9, but we also can reproduce the Problem on DB2 UDB ESE 8.1 Linux Fixpak 4.
I can reproduce this behavior with the statements below.
db2 +c insert into testtab values(1)
When you use +c you are turning off auto-commit so you need to do an
explicit commit to release the lock(s).
That's the point. Of course DB2 does release the lock when i do
commit/rollback. My question is: why DB2 generates that lock even if
the insert fails?
cheers
Florian
"Mark A" <ma@switchboard.net> wrote in message news:<Zs**************@news.uswest.net>... When you use +c you are turning off auto-commit so you need to do an explicit commit to release the lock(s).
That's the point. Of course DB2 does release the lock when i do
commit/rollback. My question is: why DB2 generates that lock even if
the insert fails?
cheers
Florian
"Mark A" <ma@switchboard.net> wrote in message news:<Zs**************@news.uswest.net>... When you use +c you are turning off auto-commit so you need to do an explicit commit to release the lock(s).
> "Mark A" <ma@switchboard.net> wrote in message
news:<Zs**************@news.uswest.net>... When you use +c you are turning off auto-commit so you need to do an explicit commit to release the lock(s)."florian" <au*****@web.de> wrote
in message news:35*************************@posting.google.co m... That's the point. Of course DB2 does release the lock when i do commit/rollback. My question is: why DB2 generates that lock even if the insert fails?
cheers Florian
DB2 obtains the lock before it knows whether the insert will fail or be
successful. If DB2 did not obtain the lock beforehand, the lock would be
useless.
> "Mark A" <ma@switchboard.net> wrote in message
news:<Zs**************@news.uswest.net>... When you use +c you are turning off auto-commit so you need to do an explicit commit to release the lock(s)."florian" <au*****@web.de> wrote
in message news:35*************************@posting.google.co m... That's the point. Of course DB2 does release the lock when i do commit/rollback. My question is: why DB2 generates that lock even if the insert fails?
cheers Florian
DB2 obtains the lock before it knows whether the insert will fail or be
successful. If DB2 did not obtain the lock beforehand, the lock would be
useless.
> DB2 obtains the lock before it knows whether the insert will fail or be successful. If DB2 did not obtain the lock beforehand, the lock would be useless.
Ok, you are right, after thinking it over it makes sense and my
question was kind of stupid.
Thank you
Florian
> DB2 obtains the lock before it knows whether the insert will fail or be successful. If DB2 did not obtain the lock beforehand, the lock would be useless.
Ok, you are right, after thinking it over it makes sense and my
question was kind of stupid.
Thank you
Florian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kragen Sitaker |
last post by:
ERROR: Cannot insert a duplicate key into unique index pg_class_relname_nsp_index
We've been getting this error in our application every once in a while
--- typically once an hour to once a day,...
|
by: florian |
last post by:
Hi,
we have a contention problem because of an application which tries to
insert a duplicate row in a table with primary key. This insert fails
of course but the locks are not released within...
|
by: robert |
last post by:
been ruminating on the question (mostly in a 390/v7 context) of
whether, and if so when, a row update becomes an insert/delete.
i assume that there is a threshold on the number of columns of
the...
|
by: Ray |
last post by:
I am having my first experience using BLOB as a row in a table. I am
using it to insert graphics for labels we print. I have no problem
inserting into and select from the table. The graphic is...
|
by: bughunter |
last post by:
Description
The maximum number of locks held during this transaction.
It's not true. :-( When I tried found longest transactions I see
next picture:
uow_start_time T1, uow_stop T2,...
|
by: shenanwei |
last post by:
I have db2 v8.2.5 on AIX V5.3 with all the switches on
Buffer pool (DFT_MON_BUFPOOL) = ON
Lock (DFT_MON_LOCK) = ON
Sort ...
|
by: nano2k |
last post by:
Hi
Shortly, I keep invoices in a table.
Occasionally, someone will fire the execution of a stored procedure
(SP) that performs several UPDATEs against (potentially) all invoices
OLDER than a...
|
by: nano |
last post by:
Does sql server have a way to handle errors in a sproc which would allow
one to insert rows, ignoring rows which would create a duplicate key
violation? I know if one loops one can handle the error...
|
by: sticky |
last post by:
Hi
I need to be able to lock a table against INSERT and UPDATE, but not
SELECT, for the duration of a transaction.
The transaction will be defined at the application level in c#, and
then use...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |