Skip to content

Commit e4f353e

Browse files
mahnunchikvtnerd
authored andcommitted
Fix MDB_BAD_RSLOT in subaddress_reader::update_reader() causing permanently missed subaddress outputs (#278)
* fix: regtest * fix: MDB_BAD_RSLOT
1 parent bc21b9b commit e4f353e

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/server_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ namespace
387387
mempool = std::make_shared<lws::mempool>();
388388
}
389389

390-
auto client = scanner.sync(ctx.connect().value(), prog.untrusted_daemon).value();
390+
auto client = scanner.sync(ctx.connect().value(), prog.untrusted_daemon, prog.regtest).value();
391391

392392
lws::rest_server server{
393393
epee::to_span(prog.rest_servers),

src/util/ownership_test.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ namespace lws
305305

306306
void subaddress_reader::update_reader()
307307
{
308+
// Release the current read txn before opening the next one - `reader = disk.start_read()`
309+
// would otherwise begin the new LMDB read txn (inside start_read()) while the old one
310+
// is still open on this thread, which LMDB's default (non-MDB_NOTLS) reader-slot tracking
311+
// does not support and reports as MDB_BAD_RSLOT.
312+
reader = expect<db::storage_reader>{common_error::kInvalidArgument};
308313
reader = disk.start_read();
309314
if (!reader)
310315
MERROR("Subadress lookup failure: " << reader.error().message());

tests/unit/scanner.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ LWS_CASE("lws::scanner::sync and lws::scanner::run")
944944

945945
auto reader = MONERO_UNWRAP(db.start_read());
946946
auto outputs = MONERO_UNWRAP(reader.get_outputs(lws::db::account_id(1)));
947-
EXPECT(outputs.count() == 6);
947+
EXPECT(outputs.count() == 7);
948948
auto output_it = outputs.make_iterator();
949949
for (auto output_it = outputs.make_iterator(); !output_it.is_end(); ++output_it)
950950
{
@@ -1003,7 +1003,7 @@ LWS_CASE("lws::scanner::sync and lws::scanner::run")
10031003

10041004
{
10051005
const std::vector<lws::db::subaddress_dict> expected_range{
1006-
{lws::db::major_index(0), {{lws::db::index_range{lws::db::minor_index(0), lws::db::minor_index(2)}}}}
1006+
{lws::db::major_index(0), {{lws::db::index_range{lws::db::minor_index(0), lws::db::minor_index(3)}}}}
10071007
};
10081008
EXPECT(MONERO_UNWRAP(reader.get_subaddresses(lws::db::account_id(1))) == expected_range);
10091009
}

0 commit comments

Comments
 (0)