@@ -561,10 +561,13 @@ void CellDbIn::store_block_state_permanent_bulk(std::vector<td::Ref<BlockData>>
561561 new_blocks, async_executor,
562562 [this , SelfId = actor_id (this ), timer = std::move (timer), timer_prepare = std::move (timer_prepare),
563563 promise = std::move (promise)](td::Result<std::vector<PermanentCellDbUpdate>> R) mutable {
564- TRY_RESULT_PROMISE (promise, updates, std::move (R));
565564 td::actor::send_lambda_later (
566- SelfId, [=, this , timer = std::move (timer), timer_prepare = std::move (timer_prepare),
567- updates = std::move (updates), promise = std::move (promise)]() mutable {
565+ SelfId, [=, this , timer = std::move (timer), timer_prepare = std::move (timer_prepare), R = std::move (R),
566+ promise = std::move (promise)]() mutable {
567+ SCOPE_EXIT {
568+ release_db ();
569+ };
570+ TRY_RESULT_PROMISE (promise, updates, std::move (R));
568571 TD_PERF_COUNTER (celldb_store_cell_multi);
569572 timer_prepare.pause ();
570573 td::Timer timer_write;
@@ -608,7 +611,6 @@ void CellDbIn::store_block_state_permanent_bulk(std::vector<td::Ref<BlockData>>
608611 cell_db_statistics_.store_cell_bulk_queries_ ++;
609612 cell_db_statistics_.store_cell_bulk_total_blocks_ += updates.size ();
610613 }
611- release_db ();
612614 promise.set_result (td::Unit ());
613615 });
614616 });
0 commit comments