Morning all,
waiting (a minimum of) 1 second for a DML lock isn't really
all that unusual (unless of course you're bulk-inserting which
apparently is
not the case here)
Norm/Roger or anyone know why this would be the case?
Calling DBMS_LOCK.SLEEP(1) is not waiting one second for a lock, it is
inserting a pause of one second between INSERTs.
Strangely enough, I came across something like this very 'problem' just
last week. It made me so angry!
I had a release on a system which had (random) commits all the way
through it, or so it appeared. IN light of our SQL scripting standards,
I advised the people responsible and removed the commits. The script
failed with duplicate PK values (in a trigger), so I abandoned the
release, rolled back and advised the developers of the problem.
Here's the laugh:
Updating the table resulted in the firing of a trigger to create a
history record in another table. The PK on the history table is the
updated table's PK plus a DATE. (Who can see the problem yet?)
So, when we run on a s-l-o-w server all is well. When we get onto a fast
one, the resolution of the DATE column is too large and allows duplicate
values. The solution from the Duh-veloper(s) in this case was not "lets
investigate and fix it" but "lets bung in a few commits to slow it down"
- so the actual transaction control went out the window. Sensible or
what?
I was told (dangerous!) to put the commit's back into the script exactly
as they were and run it again. I refused. ![:wink: :wink:](https://emoji.discourse-cdn.com/twitter/wink.png?v=12)
I was told that the script was running too fast and they commits helped
slow it down so that there were no duplicate values. Put the commits
back in!
I refused and pointed them at DBMS_LOCK.SLEEP() and lo, we were all
happy! Well, I was happy-ish as I also told them about a TIMESTAMP data
type which has micro-second resolution and even running in a tight loop,
can't generate duplicate values.
Anyway, the use of DBMS_LOCK.SLEEP(1) could be because the rows are
being inserted into a table that has a DATE column as part of its PK (or
some unique constraint) and the sleep is to ensure that no two rows are
inserted with the same SYSDATE value.
Maybe?
Cheers,
Norm. [TeamT]
Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else. We have checked this email and its attachments for viruses. But you should still check any attachment before opening it. We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes. If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk
Information in this message may be confidential and may be legally privileged. If you have received this message by mistake, please notify the sender immediately, delete it and do not copy it to anyone else.
We have checked this email and its attachments for viruses. But you should still check any attachment before opening it.
We may have to make this message and any reply to it public if asked to under the Freedom of Information Act, Data Protection Act or for litigation. Email messages and attachments sent to or from any Environment Agency address may also be accessed by someone other than the sender or recipient, for business purposes.
If we have sent you information and you wish to use it please read our terms and conditions which you can get by calling us on 08708 506 506. Find out more about the Environment Agency at www.environment-agency.gov.uk