Checkpoint.
- Fix a couple of edge cases while switching between collections. - Raise error if attempting to switch collections mid-transaction. - Add logic for re-entrancy with long-running transactions. - Revert to the prior collection if passing a block to #collection. - Add a predicate to tell if you're currently within a long-running transaction. - Add separate commit/rollback to long-running transactions. FossilOrigin-Name: 711239e6fc2f25479a26fb54805da1e5db792f97f28a8b5724e0b38eb11cdb07
This commit is contained in:
parent
ceb92fad16
commit
81ee69295c
7 changed files with 239 additions and 29 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env rspec -cfd
|
||||
# vim: set nosta noet ts=4 sw=4 ft=ruby:
|
||||
|
||||
require_relative '../lib/helper'
|
||||
|
||||
|
|
@ -113,6 +114,12 @@ RSpec.describe( MDBX::Database ) do
|
|||
expect( db['key'] ).to be_truthy
|
||||
end
|
||||
|
||||
it "revert back to the previous collection when used in a block" do
|
||||
expect( db.collection ).to be_nil
|
||||
db.collection( 'bucket' ) { 'no-op' }
|
||||
expect( db.collection ).to be_nil
|
||||
end
|
||||
|
||||
it "can be cleared of contents" do
|
||||
db.collection( 'bucket' )
|
||||
10.times {|i| db[i] = true }
|
||||
|
|
|
|||
57
spec/mdbx/stats_spec.rb
Normal file
57
spec/mdbx/stats_spec.rb
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env rspec -cfd
|
||||
# vim: set nosta noet ts=4 sw=4 ft=ruby:
|
||||
|
||||
require_relative '../lib/helper'
|
||||
|
||||
|
||||
RSpec.fdescribe( MDBX::Database ) do
|
||||
|
||||
let!( :db ) { described_class.open( TEST_DATABASE.to_s, max_readers: 500 ) }
|
||||
|
||||
let( :stats ) { db.statistics }
|
||||
|
||||
after( :each ) do
|
||||
db.close
|
||||
end
|
||||
|
||||
it "returns the configured max_readers" do
|
||||
expect( stats.dig(:environment, :max_readers) ).to be >= 500
|
||||
end
|
||||
|
||||
it "returns compile time flags and options" do
|
||||
build = stats[ :build ]
|
||||
expect( build.keys.size ).to be( 4 )
|
||||
expect( build.keys ).to include( :compiler, :flags, :options, :target )
|
||||
expect( build[:compiler] ).to be_a( String )
|
||||
expect( build[:flags] ).to be_a( String )
|
||||
expect( build[:target] ).to be_a( String )
|
||||
expect( build[:options] ).to be_a( Hash )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
__END__
|
||||
{:environment=>
|
||||
{:pagesize=>4096,
|
||||
:last_txnid=>125,
|
||||
:last_reader_txnid=>125,
|
||||
:maximum_readers=>122,
|
||||
:readers_in_use=>1,
|
||||
:datafile=>
|
||||
{:size_current=>65536,
|
||||
:pages=>16,
|
||||
:type=>"dynamic",
|
||||
:size_lower=>12288,
|
||||
:size_upper=>1048576,
|
||||
:growth_step=>65536,
|
||||
:shrink_threshold=>131072}},
|
||||
:readers=>
|
||||
[{:slot=>0,
|
||||
:pid=>45436,
|
||||
:thread=>34374651904,
|
||||
:txnid=>0,
|
||||
:lag=>0,
|
||||
:bytes_used=>0,
|
||||
:bytes_retired=>0}]}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue