Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Perl DBI module hanging (transaction isolation)

Reply
Thread Tools

Perl DBI module hanging (transaction isolation)

 
 
dn.perl@gmail.com
Guest
Posts: n/a
 
      01-06-2010

I am running a perl script (on ancient Perl 5.6, with which I am
stuck) which uses DBI module. The script runs select, delete and
insert statements against an Oracle table. The script runs properly
most of the time.

I also have a 'sqlplus' session running.
There are 5 records in table tt22.

Case A)
In sqlplus session: I delete all the 5 records from the table; issue a
'commit', and run the perl script. It runs fine.

Case B)
In sqlplus session, I delete all the 5 records from the table but do
not run commit.
Then I run the perl script but it hangs.
I issue 'commit' via sqlplus, and the 'hanging' perl script starts
running at once.

I do not want my perl script to hang. Is it possible to set a
transaction isolation level via DBI (perhaps immediately after
connecting to the database DBI->connect) which will enable the perl
script to run smoothly even when I have deleted some records in the
sqlplus session without commiting the delete action.
 
Reply With Quote
 
 
 
 
Xho Jingleheimerschmidt
Guest
Posts: n/a
 
      01-07-2010
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I am running a perl script (on ancient Perl 5.6, with which I am
> stuck) which uses DBI module. The script runs select, delete and
> insert statements against an Oracle table. The script runs properly
> most of the time.


Your definition of "properly" is improper.

> I also have a 'sqlplus' session running.
> There are 5 records in table tt22.
>
> Case A)
> In sqlplus session: I delete all the 5 records from the table; issue a
> 'commit', and run the perl script. It runs fine.
>
> Case B)
> In sqlplus session, I delete all the 5 records from the table but do
> not run commit.
> Then I run the perl script but it hangs.
> I issue 'commit' via sqlplus, and the 'hanging' perl script starts
> running at once.
>
> I do not want my perl script to hang. Is it possible to set a
> transaction isolation level via DBI (perhaps immediately after
> connecting to the database DBI->connect) which will enable the perl
> script to run smoothly even when I have deleted some records in the
> sqlplus session without commiting the delete action.


No. Oracle does not work that way. You may be able to do something
with the "skip locked", I think it is called. But that will probably do
more harm than good.

Maybe you can set autocommit to on in sqlplus.

But why you have a burning desire to achieve data corruption is beyond
me. Maybe you can switch to a database that specializes in corrupting
your data.

Xho

 
Reply With Quote
 
 
 
 
Jochen Lehmeier
Guest
Posts: n/a
 
      01-07-2010
(Sorry for the bad quote, don't have the previous message.)

On Thu, 07 Jan 2010 04:12:42 +0100, Xho Jingleheimerschmidt
<(E-Mail Removed)> wrote:

> (E-Mail Removed) wrote:
>> I am running a perl script (on ancient Perl 5.6, with which I am
>> stuck) which uses DBI module. The script runs select, delete and
>> insert statements against an Oracle table. The script runs properly
>> most of the time.


As long as you do not need CPAN modules which require 5.8 or newer, and as
long as you do not work with Unicode, perl 5.6 is fine, especially
together with Oracle.

This finished the perl specific part of the question, nevertheless:

>> Case B)
>> In sqlplus session, I delete all the 5 records from the table but do
>> not run commit.
>> Then I run the perl script but it hangs.
>> I issue 'commit' via sqlplus, and the 'hanging' perl script starts
>> running at once.
>> I do not want my perl script to hang.


No, it does not hang. It merely waits on a lock (hard to tell which one
without knowing what your perl script does; if you need to know, then
Google will quickly turn up SQL queries you can use to find out which
particular kind of lock it is).

Oracle is extremely robust in respect to "hanging" - it usually
automatically and immediately detects real hangs (deadlocks) and aborts
one of the involved transactions with an error.

The only kind of "hanging" you will experience is the one you have found:
one transaction is being kept open (i.e., neither a rollback or a commit
happens), and while it does, it can hold certain locks. Although in
Oracle, you're lucky in that there are only very few occasions where you
actually have to wait on another transaction. It would be interesting to
know what exactly your perl script is trying to do.

>> Is it possible to set a
>> transaction isolation level via DBI (perhaps immediately after
>> connecting to the database DBI->connect) which will enable the perl
>> script to run smoothly even when I have deleted some records in the
>> sqlplus session without commiting the delete action.


It does not make sense to ask the question like this. The answer to this
particular question is "no" simply because there is no way in Oracle to
influence locking/transaction behaviour in regard to a particular DML
statement (i.e., specific for DELETE).

And on another level, the answer is also "no", because there *is* a reason
why Oracle locks there. Oracle is not like other DBs that lock everything
"just in case"; if locks do happen, there is a good reason, and usually by
avoiding the lock, you are not doing yourself a favour at all.

> Maybe you can set autocommit to on in sqlplus.


.... but be sure to understand what it does (towards the original poster).
It *will* get rid of your current problem, but maybe not in the way you
want/expect to, and it can burn you later.

> But why you have a burning desire to achieve data corruption is beyond
> me. Maybe you can switch to a database that specializes in corrupting
> your data.


ACK.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DBI Mysql storing DBI:binary, trouble with character 26 Jerome Hauss Ruby 0 10-13-2004 03:04 PM
Oracle's RPAD problematic via Perl's DBI module dn_perl@hotmail.com Perl Misc 4 08-25-2004 11:50 AM
DBI and DBI::Oracle packages configuration ulloa Perl 1 07-22-2004 05:52 PM
DBI problem : How can I load quickly one huge table with DBI ??. Tim Haynes Perl Misc 3 09-13-2003 03:43 AM
Mason, DBI, and DBI::Pg Asby Perl Misc 0 07-24-2003 09:04 PM



Advertisments