DBM::Deep->_throw_error( "Cannot begin_work - no available transactions" );
}
- $self->set_trans_ctr(
- $self->get_txn_staleness_counter( $self->trans_id ),
- );
-
return;
}
$slots[$self->trans_id] = 0;
$self->write_txn_slots( @slots );
$self->inc_txn_staleness_counter( $self->trans_id );
- $self->set_trans_ctr( 0 );
$self->set_trans_id( 0 );
return 1;
$slots[$self->trans_id] = 0;
$self->write_txn_slots( @slots );
$self->inc_txn_staleness_counter( $self->trans_id );
- $self->set_trans_ctr( 0 );
$self->set_trans_id( 0 );
return 1;
sub get_txn_staleness_counter {
my $self = shift;
my ($trans_id) = @_;
- return unpack( 'N',
+ my $x = unpack( 'N',
$self->storage->read_at(
- $self->trans_loc + 4 * ($trans_id - 1), 4,
+ $self->trans_loc + 4 * ($trans_id - 1),
+ 4,
)
);
+ print "$trans_id => $x\n";
+ return $x;
}
sub inc_txn_staleness_counter {
my $self = shift;
my ($trans_id) = @_;
$self->storage->print_at(
- $self->trans_loc,
+ $self->trans_loc + 4 * ($trans_id - 1),
pack( 'N', $self->get_txn_staleness_counter( $trans_id ) + 1 ),
);
}
$self->set_trans_loc( $header_fixed + 2 );
$self->set_chains_loc( $header_fixed + 2 + 4 + 4 * $self->num_txns );
- $self->set_trans_ctr( 0 );
return;
}
$self->set_trans_loc( $header_fixed + 2 );
$self->set_chains_loc( $header_fixed + 2 + 4 + 4 * $self->num_txns );
- $self->set_trans_ctr( 0 );
if ( @values < 2 || grep { !defined } @values ) {
$self->storage->close;
sub trans_id { $_[0]{trans_id} }
sub set_trans_id { $_[0]{trans_id} = $_[1] }
-sub trans_ctr { $_[0]{trans_ctr} }
-sub set_trans_ctr { $_[0]{trans_ctr} = $_[1] }
-
sub trans_loc { $_[0]{trans_loc} }
sub set_trans_loc { $_[0]{trans_loc} = $_[1] }
my ($loc, $staleness) = unpack( $StP{$e->byte_size} . ' N', $buffer );
# We have found an entry that is old, so get rid of it
- if ( $staleness != $e->get_txn_staleness_counter( $args->{trans_id} ) ) {
+ if ( $staleness != (my $s = $e->get_txn_staleness_counter( $args->{trans_id} ) ) ) {
+ print "Killing $args->{trans_id} ( $staleness <-> $s )\n";
$e->storage->print_at(
$spot,
pack( $StP{$e->byte_size} . ' N', (0) x 2 ),
$db2->begin_work;
-is( $db1->{foo}, 'bar2', "After DB2 transaction begin, DB1's foo is bar2" );
-is( $db2->{foo}, 'bar', "After DB2 transaction begin, DB2's foo is bar" );
-is( $db3->{foo}, 'bar', "After DB2 transaction begin, DB3's foo is bar" );
+is( $db1->{foo}, 'bar2', "After DB2 transaction begin, DB1's foo is still bar2" );
+is( $db2->{foo}, 'bar', "After DB2 transaction begin, DB2's foo is still bar" );
+is( $db3->{foo}, 'bar', "After DB2 transaction begin, DB3's foo is still bar" );
__END__
ok( exists $db1->{bar}, "After DB2 transaction begin, DB1's bar exists" );
ok( !exists $db2->{bar}, "After DB2 transaction begin, DB2's bar doesn't exist" );