Skip Menu |

This queue is for tickets about the LMDB_File CPAN distribution.

Report information
The Basics
Id: 98972
Status: open
Priority: 0/
Queue: LMDB_File

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.06
Fixed in: (no value)



Subject: Not clear at all how to use ->renew

I've been poking at trying to get ->renew to do something, but it doesn't like me at all :(

 

->renew seems to want an active transaction, and I don't know how to exactly construct such a thing without it already being a usable transaction.

Attached attempt

Subject: reuse_txn.pl
use strict; use warnings; use LMDB_File qw( :all ); use Path::Tiny; my $tdir = Path::Tiny->tempdir; my $dbi; my $env = LMDB::Env->new( "$tdir", { mapsize => ( 10 * 1024 * 1024 ), maxdbs => 1024, }); sub initial_setup { my $txn = $env->BeginTxn; $dbi = $txn->open( 'test', MDB_CREATE ); my $db = LMDB_File->new( $txn, $dbi ); $txn->commit; } sub reuse_dbi { my $txn = $env->BeginTxn; my $db = LMDB_File->new( $txn, $dbi ); $txn->commit; } sub write_action { my $txn = $env->BeginTxn; my $db = LMDB_File->new( $txn, $dbi ); $db->put('Chunky' => 'Bacon'); $txn->commit; } my $read_txn; sub readonly_action { if ( $read_txn ) { $read_txn->renew; } else { $read_txn = $env->BeginTxn(MDB_RDONLY); } my $db = LMDB_File->new( $read_txn, $dbi ); print "Got value\n" if $db->get( 'Chunky' ) eq 'Bacon'; $read_txn->commit; } initial_setup; write_action; readonly_action; readonly_action;
$Txn->renew is intended to be used after a $Txn->reset, please read the liblmdb documentation for the intended usage. The general idea is to break an otherwise long-lived RO transaction into small short-lived ones avoiding the associated transaction allocation/locking ovehead. In the current release both methods are supported but the implementation is somewhat incomplete, the next release fixes that. El Jue Sep 18 15:44:12 2014, KENTNL escribió: Show quoted text
> I've been poking at trying to get ->renew to do something, but it > doesn't like > me at all :( > > ->renew seems to want an active transaction, and I don't know how to > exactly > construct such a thing without it already being a usable transaction. > > Attached attempt