Update MySQLStyleTransactionTest to use SingleDelete (#9062)
Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/9062 Real MySQL-style transactions in MyRocks uses SingleDelete, which is missing in our existint MySQLStyleTransactionTest. Ths diff by lth fills the gap in test coverage. Reviewed By: lth Differential Revision: D31813015 fbshipit-source-id: 196ad761de30ae9ea1f92257058dfc265f211892
This commit is contained in:
parent
9e788be4b7
commit
8ef5b9ddfe
@ -165,12 +165,19 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn,
|
|||||||
// Increment key
|
// Increment key
|
||||||
std::string sum = ToString(int_value + incr);
|
std::string sum = ToString(int_value + incr);
|
||||||
if (txn != nullptr) {
|
if (txn != nullptr) {
|
||||||
s = txn->Put(key, sum);
|
s = txn->SingleDelete(key);
|
||||||
if (!get_for_update && (s.IsBusy() || s.IsTimedOut())) {
|
if (!get_for_update && (s.IsBusy() || s.IsTimedOut())) {
|
||||||
// If the initial get was not for update, then the key is not locked
|
// If the initial get was not for update, then the key is not locked
|
||||||
// before put and put could fail due to concurrent writes.
|
// before put and put could fail due to concurrent writes.
|
||||||
break;
|
break;
|
||||||
} else if (!s.ok()) {
|
} else if (!s.ok()) {
|
||||||
|
// Since we did a GetForUpdate, SingleDelete should not fail.
|
||||||
|
fprintf(stderr, "SingleDelete returned an unexpected error: %s\n",
|
||||||
|
s.ToString().c_str());
|
||||||
|
unexpected_error = true;
|
||||||
|
}
|
||||||
|
s = txn->Put(key, sum);
|
||||||
|
if (!s.ok()) {
|
||||||
// Since we did a GetForUpdate, Put should not fail.
|
// Since we did a GetForUpdate, Put should not fail.
|
||||||
fprintf(stderr, "Put returned an unexpected error: %s\n",
|
fprintf(stderr, "Put returned an unexpected error: %s\n",
|
||||||
s.ToString().c_str());
|
s.ToString().c_str());
|
||||||
@ -197,6 +204,10 @@ bool RandomTransactionInserter::DoInsert(DB* db, Transaction* txn,
|
|||||||
if (with_prepare) {
|
if (with_prepare) {
|
||||||
// Also try commit without prepare
|
// Also try commit without prepare
|
||||||
s = txn->Prepare();
|
s = txn->Prepare();
|
||||||
|
if (!s.ok()) {
|
||||||
|
fprintf(stderr, "Prepare returned an unexpected error: %s\n",
|
||||||
|
s.ToString().c_str());
|
||||||
|
}
|
||||||
assert(s.ok());
|
assert(s.ok());
|
||||||
ROCKS_LOG_DEBUG(db->GetDBOptions().info_log,
|
ROCKS_LOG_DEBUG(db->GetDBOptions().info_log,
|
||||||
"Prepare of %" PRIu64 " %s (%s)", txn->GetId(),
|
"Prepare of %" PRIu64 " %s (%s)", txn->GetId(),
|
||||||
|
Loading…
Reference in New Issue
Block a user