Updates to support libmdbx 0.12.x.

Also, close some hanging open transactions in some error states.

FossilOrigin-Name: 9582fff0788d3f78e9b33f292a2c48afeac32587c89496a5a7d5e97a98085683
This commit is contained in:
Mahlon E. Smith 2024-03-25 01:58:15 +00:00
parent 080235d55a
commit 7fc1ebb408
4 changed files with 42 additions and 6 deletions

22
.solargraph.yml Normal file
View file

@ -0,0 +1,22 @@
---
include:
- "**/*.rb"
exclude:
- spec/**/*
- test/**/*
- vendor/**/*
- ".bundle/**/*"
require: []
domains: []
reporters:
- rubocop
- require_not_found
formatter:
rubocop:
cops: safe
except: []
only: []
extra_args: []
require_paths: []
plugins: []
max_files: 5000

View file

@ -423,7 +423,7 @@ development.
## Reporting Issues
Tests are performed against the latest stable MRI Ruby, and I endeavor to test
against the latest stable libmdbx (as of this writing, the 0.11.x versioning),
against the latest stable libmdbx (as of this writing, the 0.12.x versioning),
on both x86 and ARM chipsets.
Things may work for you in other environments - I'm just not matrix testing

View file

@ -168,6 +168,12 @@ rmdbx_open_env( VALUE self )
rb_raise( rmdbx_eDatabaseError, "mdbx_env_open: (%d) %s", rc, mdbx_strerror(rc) );
}
/* Force populate the db->dbi handle. Under 0.12.x, getting a
* 'permission denied' doing this for the first access with a RDONLY
* for some reason. */
rmdbx_open_txn( db, MDBX_TXN_READWRITE );
rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
db->state.open = 1;
return Qtrue;
}
@ -189,8 +195,10 @@ rmdbx_clear( VALUE self )
rmdbx_open_txn( db, MDBX_TXN_READWRITE );
int rc = mdbx_drop( db->txn, db->dbi, false );
if ( rc != MDBX_SUCCESS )
if ( rc != MDBX_SUCCESS ) {
rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
rb_raise( rmdbx_eDatabaseError, "mdbx_drop: (%d) %s", rc, mdbx_strerror(rc) );
}
rmdbx_close_txn( db, RMDBX_TXN_COMMIT );
@ -229,8 +237,10 @@ rmdbx_drop( VALUE self, VALUE name )
rmdbx_open_txn( db, MDBX_TXN_READWRITE );
int rc = mdbx_drop( db->txn, db->dbi, true );
if ( rc != MDBX_SUCCESS )
if ( rc != MDBX_SUCCESS ) {
rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
rb_raise( rmdbx_eDatabaseError, "mdbx_drop: (%d) %s", rc, mdbx_strerror(rc) );
}
rmdbx_close_txn( db, RMDBX_TXN_COMMIT );
@ -238,6 +248,12 @@ rmdbx_drop( VALUE self, VALUE name )
db->subdb = NULL;
rmdbx_close_dbi( db ); /* ensure next access is not in the defunct subdb */
/* Force populate the new db->dbi handle. Under 0.12.x, getting a
* 'permission denied' doing this for the first access with a RDONLY
* for some reason. */
rmdbx_open_txn( db, MDBX_TXN_READWRITE );
rmdbx_close_txn( db, RMDBX_TXN_ROLLBACK );
return self;
}

View file

@ -58,8 +58,6 @@ rmdbx_log( const char *level, const char *fmt, va_dcl )
}
/*
* MDBX initialization
*/