Update of /cvsroot/popfile/engine/POPFile
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24449/POPFile
Modified Files:
Tag: b0_22_2
History.pm
Log Message:
Use transactions inserting, updating and deleting records in history table to improve performance and avoid 'database is locked' error messages.
Index: History.pm
===================================================================
RCS file: /cvsroot/popfile/engine/POPFile/History.pm,v
retrieving revision 1.29.4.1
retrieving revision 1.29.4.2
diff -C2 -d -r1.29.4.1 -r1.29.4.2
*** History.pm 6 Feb 2006 15:15:53 -0000 1.29.4.1
--- History.pm 16 Oct 2007 17:19:52 -0000 1.29.4.2
***************
*** 284,287 ****
--- 284,290 ----
$self->log_( 2, "reserve_slot selected random number $r" );
+ # Avoid another POPFile process using the same committed id
+ $self->db__()->begin_work;
+
# TODO Replace the hardcoded user ID 1 with the looked up
# user ID from the session key
***************
*** 291,294 ****
--- 294,298 ----
if ( defined( $test ) ) {
+ $self->db__()->commit;
next;
}
***************
*** 306,309 ****
--- 310,314 ----
my $result = $self->db__()->selectrow_arrayref(
"select id from history where committed = $r limit 1;");
+ $self->db__()->commit;
my $slot = $result->[0];
***************
*** 502,505 ****
--- 507,511 ----
}
+ $self->db__()->begin_work;
foreach my $entry (@{$self->{commit_list__}}) {
my ( $session, $slot, $bucket, $magnet ) = @{$entry};
***************
*** 640,643 ****
--- 646,650 ----
}
}
+ $self->db__()->commit;
$self->{commit_list__} = ();
***************
*** 722,725 ****
--- 729,733 ----
$self->{classifier__}->tweak_sqlite( 1, 1, $self->db__() );
+ $self->db__()->begin_work;
}
***************
*** 736,739 ****
--- 744,748 ----
my ( $self ) = @_;
+ $self->db__()->commit;
$self->{classifier__}->tweak_sqlite( 1, 0, $self->db__() );
}
|