diff --git a/src/yb/master/ysql_ddl_handler.cc b/src/yb/master/ysql_ddl_handler.cc index c704c212ed60..f266be5e898e 100644 --- a/src/yb/master/ysql_ddl_handler.cc +++ b/src/yb/master/ysql_ddl_handler.cc @@ -379,6 +379,7 @@ Status CatalogManager::YsqlDdlTxnAlterTableHelper(const YsqlTableDdlTxnState txn table_pb.set_state_msg( strings::Substitute("Alter table version=$0 ts=$1", table_pb.version(), LocalTimeAsString())); + VLOG(3) << "Clearing ysql_ddl_txn_verifier_state from table " << txn_data.table->id(); table_pb.clear_ysql_ddl_txn_verifier_state(); table_pb.clear_transaction(); @@ -500,20 +501,32 @@ Status CatalogManager::TriggerDdlVerificationIfNeeded( return Status::OK(); } - table = verifier_state->tables.front(); if (verifier_state->txn_state != TxnState::kUnknown) { // We already know whether this transaction is a success or a failure. We don't need to poll // the transaction coordinator at this point. We can simply invoke post DDL verification // directly. const bool is_committed = verifier_state->txn_state == TxnState::kCommitted; - const string pb_txn_id = table->LockForRead()->pb_transaction_id(); - return background_tasks_thread_pool_->SubmitFunc( - [this, pb_txn_id, is_committed, epoch]() { - WARN_NOT_OK(YsqlDdlTxnCompleteCallback(pb_txn_id, is_committed, epoch), - "YsqlDdlTxnCompleteCallback failed"); + string pb_txn_id; + vector table_ids; + for (const auto& table : verifier_state->tables) { + table_ids.push_back(table->id()); + pb_txn_id = table->LockForRead()->pb_transaction_id(); + if (pb_txn_id.empty()) { + continue; } - ); + return background_tasks_thread_pool_->SubmitFunc( + [this, table, pb_txn_id, is_committed, epoch]() { + WARN_NOT_OK(YsqlDdlTxnCompleteCallback(pb_txn_id, is_committed, epoch), + Format("YsqlDdlTxnCompleteCallback failed, table: ", + table->id())); + } + ); + } + VLOG(3) << "All tables " << VectorToString(table_ids) + << " in transaction " << txn << " have pb_txn_id cleared"; + return Status::OK(); } + table = verifier_state->tables.front(); } // Schedule transaction verification.