Skip to content

Commit

Permalink
unify add/delete finish() as update
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyu85cn committed Jan 25, 2022
1 parent 266149d commit fca2ce4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
21 changes: 20 additions & 1 deletion src/storage/transaction/ChainAddEdgesLocalProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ cpp2::AddEdgesRequest ChainAddEdgesLocalProcessor::reverseRequest(
}

void ChainAddEdgesLocalProcessor::finish() {
auto rc = (rcPrepare_ == Code::SUCCEEDED) ? rcCommit_ : rcPrepare_;
if (rcPrepare_ == Code::SUCCEEDED) {
VLOG(1) << uuid_ << execDesc_ << makeReadableEdge(req_)
<< ", rcPrepare_=" << apache::thrift::util::enumNameSafe(rcPrepare_)
Expand All @@ -311,6 +310,26 @@ void ChainAddEdgesLocalProcessor::finish() {
}
} while (0);

auto rc = Code::SUCCEEDED;
do {
if (rcPrepare_ != Code::SUCCEEDED) {
rc = rcPrepare_;
break;
}

if (rcCommit_ != Code::SUCCEEDED) {
rc = rcCommit_;
break;
}

// rcCommit_ may be set SUCCEEDED in abort().
// which we should return the error code or remote.
if (rcRemote_ != Code::E_RPC_FAILURE) {
rc = rcRemote_;
break;
}
} while (0);

pushResultCode(rc, localPartId_);
finished_.setValue(rc);
onFinished();
Expand Down
20 changes: 19 additions & 1 deletion src/storage/transaction/ChainDeleteEdgesLocalProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,25 @@ void ChainDeleteEdgesLocalProcessor::finish() {
}
} while (0);

auto rc = (rcPrepare_ == Code::SUCCEEDED) ? rcCommit_ : rcPrepare_;
auto rc = Code::SUCCEEDED;
do {
if (rcPrepare_ != Code::SUCCEEDED) {
rc = rcPrepare_;
break;
}

if (rcCommit_ != Code::SUCCEEDED) {
rc = rcCommit_;
break;
}

// rcCommit_ may be set SUCCEEDED in abort().
// which we should return the error code or remote.
if (rcRemote_ != Code::E_RPC_FAILURE) {
rc = rcRemote_;
break;
}
} while (0);
pushResultCode(rc, localPartId_);
finished_.setValue(rc);
onFinished();
Expand Down
2 changes: 0 additions & 2 deletions src/storage/transaction/TransactionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ void TransactionManager::addPrime(GraphSpaceID spaceId,
if (lk) {
lk->unlock(egKey);
}
// delPrime(spaceId, partId, termId, egKey);
return;
}
auto fut = proc->getFinished();
Expand All @@ -173,7 +172,6 @@ void TransactionManager::addPrime(GraphSpaceID spaceId,
if (lk) {
lk->unlock(egKey);
}
// env_->txnMan_->delPrime(spaceId, partId, termId, egKey);
}
});
addChainTask(proc);
Expand Down

0 comments on commit fca2ce4

Please sign in to comment.