简体   繁体   English

Perl DBI-并行事务

[英]Perl DBI - Parallel Transactions

I have a perl script with DBI doing various DML operations on multiple tables in a MySQL database in a sequence. 我有一个Perl脚本,其中DBI按顺序对MySQL数据库中的多个表执行各种DML操作。

I implemented transactions using dbh->begin_work and eval in my perl script. 我在perl脚本中使用dbh->begin_workeval实现了事务。 Now, I ran my script once and after some time I ran it again thereby initiating two transactions to my database. 现在,我运行了一次脚本,一段时间后再次运行了脚本,从而启动了两个到数据库的事务。 By the time, I ran the script for second time, the first transaction had completed operations on the fifth table yet my second transaction waits to do operations even on the first table. 到那时,我已经第二次运行脚本了,第一个事务已经在第五个表上完成了操作,但是我的第二个事务甚至在第一个表上也都做了操作。

Can I make the script get executed in parallel so that second transaction can be able to perform operations on the first table while the first transaction is working ahead of it? 我可以使脚本并行执行,以便第二个事务能够在第一个表之前执行时对第一个表执行操作吗?

Every database has its own transaction isolation levels. 每个数据库都有其自己的事务隔离级别。 Read something like this article: http://www.oracle.com/technetwork/issue-archive/2005/05-nov/o65asktom-082389.html 阅读类似本文的内容: http : //www.oracle.com/technetwork/issue-archive/2005/05-nov/o65asktom-082389.html

So every transaction may be locked and/or abandoned due to race conditions between simultaneous running transactions. 因此,由于同时运行的事务之间的竞争状况,每个事务都可能被锁定和/或放弃。

And read http://search.cpan.org/~timb/DBI-1.636/DBI.pm#Transactions chapter to use RaiseError anyway. 并阅读http://search.cpan.org/~timb/DBI-1.636/DBI.pm#Transactions一章以使用RaiseError。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM