Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#22882] YSQL: Fix unexpected DDL atomicity log message
Summary: In working on https://phorge.dev.yugabyte.com/D32682, the test PgDdlAtomicityColocatedStressTest.TestFailDdlRollback showed logs like the following: ``` [m-1] W0614 20:35:35.849383 26140 ysql_ddl_handler.cc:551] YsqlDdlTxnCompleteCallback failed: Corruption (yb/util/uuid.cc:312): Invalid length of binary data with TransactionId '': 0 (expected 16) ``` The relevant code are: ``` 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"); } ); ``` and ``` Status CatalogManager::YsqlDdlTxnCompleteCallback(const string& pb_txn_id, bool is_committed, const LeaderEpoch& epoch) { SleepFor(MonoDelta::FromMicroseconds(RandomUniformInt<int>(0, FLAGS_TEST_ysql_max_random_delay_before_ddl_verification_usecs))); auto txn = VERIFY_RESULT(FullyDecodeTransactionId(pb_txn_id)); ``` It is possible that `pb_txn_id` of `table` is already cleared. In this case `pb_txn_id` is an empty string. The error is reported when an empty string is passed to `FullyDecodeTransactionId`. I made a fix not to call `YsqlDdlTxnCompleteCallback` if all the tables in the DDL transaction verifier state have their `pb_txn_id` already cleared. In other words, we only call `YsqlDdlTxnCompleteCallback` when we can find a table in the DDL transaction verifier state that has `pb_txn_id` and this `pb_txn_id` is the transaction id that we pass to `YsqlDdlTxnCompleteCallback` to process all the tables in this DDL transaction. Jira: DB-11784 Test Plan: Tested in the context of https://phorge.dev.yugabyte.com/D32682. ./yb_build.sh --sj --cxx-test pg_ddl_atomicity_stress-test --gtest_filter=PgDdlAtomicityColocatedStressTest.TestFailDdlRollback -n 20 --tp 2 Reviewers: fizaa Reviewed By: fizaa Subscribers: ybase, yql Differential Revision: https://phorge.dev.yugabyte.com/D35879
- Loading branch information