diff --git a/test/nested.cc b/test/nested.cc index e02fe8b1..1f7e8b5e 100644 --- a/test/nested.cc +++ b/test/nested.cc @@ -70,9 +70,8 @@ static unsigned edge2count(uint64_t edge, unsigned count_max) { void testcase_nested::push_txn() { MDBX_txn *txn; - int err = mdbx_txn_begin( - db_guard.get(), txn_guard.get(), - prng32() & (MDBX_NOSYNC | MDBX_NOMETASYNC | MDBX_MAPASYNC), &txn); + unsigned flags = prng32() & (MDBX_NOSYNC | MDBX_NOMETASYNC | MDBX_MAPASYNC); + int err = mdbx_txn_begin(db_guard.get(), txn_guard.get(), flags, &txn); if (unlikely(err != MDBX_SUCCESS)) failure_perror("mdbx_txn_begin(nested)", err); #if __cplusplus >= 201703L @@ -81,7 +80,8 @@ void testcase_nested::push_txn() { stack.push(std::make_tuple(scoped_txn_guard(txn), serial, fifo, speculum)); #endif std::swap(txn_guard, std::get<0>(stack.top())); - log_verbose("begin level#%zu txn, serial %" PRIu64, stack.size(), serial); + log_verbose("begin level#%zu txn #%" PRIu64 ", flags 0x%x, serial %" PRIu64, + stack.size(), mdbx_txn_id(txn), flags, serial); } bool testcase_nested::pop_txn(bool abort) { @@ -90,8 +90,9 @@ bool testcase_nested::pop_txn(bool abort) { MDBX_txn *txn = txn_guard.release(); bool commited = false; if (abort) { - log_verbose("abort level#%zu txn, undo serial %" PRIu64 " <- %" PRIu64, - stack.size(), serial, std::get<1>(stack.top())); + log_verbose( + "abort level#%zu txn #%" PRIu64 ", undo serial %" PRIu64 " <- %" PRIu64, + stack.size(), mdbx_txn_id(txn), serial, std::get<1>(stack.top())); int err = mdbx_txn_abort(txn); if (unlikely(err != MDBX_SUCCESS)) failure_perror("mdbx_txn_abort()", err); @@ -152,8 +153,8 @@ bool testcase_nested::trim_tail(unsigned window_width) { while (fifo.size() > window_width) { uint64_t tail_serial = fifo.back().first; const unsigned tail_count = fifo.back().second; - log_trace("nested: pop-tail (serial %" PRIu64 ", count %u)", tail_serial, - tail_count); + log_verbose("nested: pop-tail (serial %" PRIu64 ", count %u)", + tail_serial, tail_count); fifo.pop_back(); for (unsigned n = 0; n < tail_count; ++n) { log_trace("nested: remove-tail %" PRIu64, tail_serial); @@ -170,8 +171,10 @@ bool testcase_nested::trim_tail(unsigned window_width) { failure("nested: unexpected key-space overflow on the tail"); } } - } else { - log_trace("nested: purge state"); + } else if (!fifo.empty()) { + log_verbose("nested: purge state %" PRIu64 " - %" PRIu64 ", fifo-items %zu", + fifo.front().first, fifo.back().first + fifo.back().second, + fifo.size()); db_table_clear(dbi, txn_guard.get()); fifo.clear(); speculum.clear(); diff --git a/test/test.cc b/test/test.cc index f32befd7..ff167627 100644 --- a/test/test.cc +++ b/test/test.cc @@ -674,6 +674,7 @@ bool testcase::speculum_verify() { MDBX_val mkey, mvalue; err = mdbx_cursor_get(cursor, &akey, &avalue, MDBX_FIRST); + unsigned extra = 0, lost = 0, n = 0; assert(std::is_sorted(speculum.cbegin(), speculum.cend(), ItemCompare(this))); auto it = speculum.cbegin(); while (true) { @@ -696,14 +697,15 @@ bool testcase::speculum_verify() { } else if (err == MDBX_SUCCESS && (it == speculum.cend() || S_key < it->first || (S_key == it->first && S_data < it->second))) { + extra += 1; if (it != speculum.cend()) { - log_error("extra pair: db{%s, %s} < mi{%s, %s}", + log_error("extra pair %u/%u: db{%s, %s} < mi{%s, %s}", n, extra, mdbx_dump_val(&akey, dump_key, sizeof(dump_key)), mdbx_dump_val(&avalue, dump_value, sizeof(dump_value)), mdbx_dump_val(&mkey, dump_mkey, sizeof(dump_mkey)), mdbx_dump_val(&mvalue, dump_mvalue, sizeof(dump_mvalue))); } else { - log_error("extra pair: db{%s, %s} < mi.END", + log_error("extra pair %u/%u: db{%s, %s} < mi.END", n, extra, mdbx_dump_val(&akey, dump_key, sizeof(dump_key)), mdbx_dump_val(&avalue, dump_value, sizeof(dump_value))); } @@ -712,12 +714,13 @@ bool testcase::speculum_verify() { } else if (it != speculum.cend() && (err == MDBX_NOTFOUND || S_key > it->first || (S_key == it->first && S_data > it->second))) { + lost += 1; if (err == MDBX_NOTFOUND) { - log_error("lost pair: db.END > mi{%s, %s}", + log_error("lost pair %u/%u: db.END > mi{%s, %s}", n, lost, mdbx_dump_val(&mkey, dump_mkey, sizeof(dump_mkey)), mdbx_dump_val(&mvalue, dump_mvalue, sizeof(dump_mvalue))); } else { - log_error("lost pair: db{%s, %s} > mi{%s, %s}", + log_error("lost pair %u/%u: db{%s, %s} > mi{%s, %s}", n, lost, mdbx_dump_val(&akey, dump_key, sizeof(dump_key)), mdbx_dump_val(&avalue, dump_value, sizeof(dump_value)), mdbx_dump_val(&mkey, dump_mkey, sizeof(dump_mkey)), @@ -732,6 +735,7 @@ bool testcase::speculum_verify() { } else { assert(!"WTF?"); } + n += 1; } mdbx_cursor_close(cursor);