У меня есть простая rocksdb
программа, в которой я создаю БД и помещаю в нее некоторые значения с помощью транзакций.
using namespace rocksdb;
std::string kDBPath = "D:\\Newdata";
int main() {
// open DB
Options options;
TransactionDBOptions txn_db_options;
options.create_if_missing = true;
TransactionDB* txn_db;
Status s = TransactionDB::Open(options, txn_db_options, kDBPath, &txn_db);
assert(s.ok());
WriteOptions write_options;
ReadOptions read_options;
TransactionOptions txn_options;
std::string value;
////////////////////////////////////////////////////////
//
// Simple Transaction Example ("Read Committed")
//
////////////////////////////////////////////////////////
// Start a transaction
Transaction* txn = txn_db->BeginTransaction(write_options);
assert(txn);
// Read a key in this transaction
//s = txn->Get(read_options, "abc", &value);
//assert(s.IsNotFound());
// Write a key in this transaction
s = txn->Put("abc", "def");
assert(s.ok());
// Read a key OUTSIDE this transaction. Does not affect txn.
s = txn_db->Get(read_options, "abc", &value);
assert(s.IsNotFound());
// Write a key OUTSIDE of this transaction.
// Does not affect txn since this is an unrelated key.
s = txn_db->Put(write_options, "xyz", "zzz");
assert(s.ok());
// Write a key OUTSIDE of this transaction.
// Fail because the key conflicts with the key written in txn.
s = txn_db->Put(write_options, "abc", "def");
assert(s.subcode() == Status::kLockTimeout);
// Value for key "xyz" has been committed, can be read in txn.
s = txn->Get(read_options, "xyz", &value);
assert(s.ok());
assert(value == "zzz");
// Commit transaction
s = txn->Commit();
assert(s.ok());
std::cout << "End program";
return 0;
}
Сначала происходит сбой Put
. Ошибка:
Exception thrown at 0x00007FF7FCAD0D84 in Rocksdbtest.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.
Unhandled exception thrown: read access violation.
txn->**** was 0xFFFFFFFFFFFFFF27.
Отладка с использованием VS показывает <Unable to read memory>
для поля name
из txn
. Та же программа работала нормально до обновления VS.