Skip to content

Commit

Permalink
fix no callback problems (FISCO-BCOS#2812)
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyShi22 authored Aug 30, 2022
1 parent dc6a910 commit 07f3ca4
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions bcos-scheduler/src/BlockExecutive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ void BlockExecutive::batchBlockCommit(
{
auto status = std::make_shared<CommitStatus>();
status->total = 1 + m_scheduler->m_executorManager->size(); // self + all executors
status->checkAndCommit = [this, callback = std::move(callback)](const CommitStatus& status) {
status->checkAndCommit = [this, callback](const CommitStatus& status) {
if (!m_isRunning)
{
callback(BCOS_ERROR_UNIQUE_PTR(SchedulerError::Stopped, "BlockExecutive is stopped"));
Expand All @@ -1181,34 +1181,32 @@ void BlockExecutive::batchBlockCommit(
params.number = number();
params.timestamp = 0;
m_scheduler->m_storage->asyncCommit(
params, [rollbackVersion, status, this, callback = std::move(callback)](
Error::Ptr&& error, uint64_t commitTS) {
params, [rollbackVersion, status, this, callback](Error::Ptr&& error, uint64_t commitTS) {
if (error)
{
SCHEDULER_LOG(ERROR)
<< BLOCK_NUMBER(number()) << "Commit node storage error! need rollback"
<< error->errorMessage();

batchBlockRollback(rollbackVersion,
[this, callback = std::move(callback)](Error::UniquePtr&& error) {
if (error)
{
SCHEDULER_LOG(ERROR)
<< BLOCK_NUMBER(number())
<< "Rollback storage(for commit scheduler storage error) failed!"
<< LOG_KV("number", number()) << " " << error->errorMessage();
// FATAL ERROR, NEED MANUAL FIX!
batchBlockRollback(rollbackVersion, [this, callback](Error::UniquePtr&& error) {
if (error)
{
SCHEDULER_LOG(ERROR)
<< BLOCK_NUMBER(number())
<< "Rollback storage(for commit scheduler storage error) failed!"
<< LOG_KV("number", number()) << " " << error->errorMessage();
// FATAL ERROR, NEED MANUAL FIX!

callback(std::move(error));
return;
}
else
{
callback(BCOS_ERROR_UNIQUE_PTR(SchedulerError::CommitError,
"Commit scheduler storage error, rollback"));
return;
}
});
callback(std::move(error));
return;
}
else
{
callback(BCOS_ERROR_UNIQUE_PTR(SchedulerError::CommitError,
"Commit scheduler storage error, rollback"));
return;
}
});
return;
}
else
Expand Down

0 comments on commit 07f3ca4

Please sign in to comment.