From 5f55944e51f9188145875bc9c36bbcdcd4fccbb6 Mon Sep 17 00:00:00 2001 From: obdev Date: Tue, 18 Apr 2023 12:11:27 +0000 Subject: [PATCH] add print log for debug that tx_end is mis-set --- src/storage/tablet/ob_tablet.cpp | 12 ++++++++++ src/storage/tablet/ob_tablet.h | 2 ++ .../tablet/ob_tablet_binding_helper.cpp | 4 ++-- .../tablet/ob_tablet_create_delete_helper.cpp | 22 ++++--------------- .../tablet/ob_tablet_create_delete_helper.h | 1 - 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/storage/tablet/ob_tablet.cpp b/src/storage/tablet/ob_tablet.cpp index 505fddf419..237d1edc5a 100644 --- a/src/storage/tablet/ob_tablet.cpp +++ b/src/storage/tablet/ob_tablet.cpp @@ -3411,5 +3411,17 @@ int ObTablet::set_frozen_for_all_memtables() return ret; } + +void ObTablet::print_memtables_for_table() +{ + int ret = OB_SUCCESS; + common::ObSArray memtables; + if (OB_FAIL(get_memtables(memtables, true))) { + LOG_WARN("failed to get_memtables", K(ret), KPC(this)); + } else { + LOG_INFO("memtables print", K(memtables), KPC(this)); + } +} + } // namespace storage } // namespace oceanbase diff --git a/src/storage/tablet/ob_tablet.h b/src/storage/tablet/ob_tablet.h index d5a687fc66..43ad7c5f6c 100644 --- a/src/storage/tablet/ob_tablet.h +++ b/src/storage/tablet/ob_tablet.h @@ -504,6 +504,7 @@ private: const share::SCN &scn, const bool for_replay, const memtable::MemtableRefOp ref_op); + void print_memtables_for_table(); private: static const int32_t TABLET_VERSION = 1; @@ -651,6 +652,7 @@ int ObTablet::prepare_data(T &multi_source_data_unit, const transaction::ObMulSo TRANS_LOG(WARN, "invalid args", K(ret), K(multi_source_data_unit)); } else if (OB_UNLIKELY(multi_source_data_unit.is_tx_end())) { TRANS_LOG(INFO, "skip for is_tx_end is true", K(multi_source_data_unit)); + print_memtables_for_table(); } else if (FALSE_IT(multi_source_data_unit.set_tx_end(true))) { } else if (OB_FAIL(save_multi_source_data_unit(&multi_source_data_unit, scn, trans_flags.for_replay_/*for_replay*/, memtable::MemtableRefOp::INC_REF))) { TRANS_LOG(WARN, "failed to save multi_source_data", K(ret), K(multi_source_data_unit), K(scn)); diff --git a/src/storage/tablet/ob_tablet_binding_helper.cpp b/src/storage/tablet/ob_tablet_binding_helper.cpp index 060ae5f2aa..64b5e4c5bd 100644 --- a/src/storage/tablet/ob_tablet_binding_helper.cpp +++ b/src/storage/tablet/ob_tablet_binding_helper.cpp @@ -951,7 +951,7 @@ int ObTabletBindingHelper::set_scn(ObTabletHandle &handle, const ObMulSourceData LOG_WARN("failed to get data", K(ret)); } else if (OB_UNLIKELY(data.tx_id_ != tx_id)) { ret = OB_ERR_UNEXPECTED; - ObTabletCreateDeleteHelper::print_memtables_for_table(handle); + handle.get_obj()->print_memtables_for_table(); LOG_WARN("cannot set log ts for unlocked tablet", K(ret), K(tx_id), K(data), "tablet_id", tablet->get_tablet_meta().tablet_id_); } else if (OB_UNLIKELY(!data.tx_scn_.is_valid())) { ret = OB_ERR_UNEXPECTED; @@ -1051,7 +1051,7 @@ int ObTabletBindingHelper::unlock_tablet_binding(ObTabletHandle &handle, const O } else { const ObTabletMeta &tablet_meta = tablet->get_tablet_meta(); LOG_WARN("already unlocked or bug", K(ret), K(tablet_meta), K(scn), K(trans_flags), K(tx_data)); - ObTabletCreateDeleteHelper::print_memtables_for_table(handle); + handle.get_obj()->print_memtables_for_table(); } } return ret; diff --git a/src/storage/tablet/ob_tablet_create_delete_helper.cpp b/src/storage/tablet/ob_tablet_create_delete_helper.cpp index c716120b88..af669af735 100644 --- a/src/storage/tablet/ob_tablet_create_delete_helper.cpp +++ b/src/storage/tablet/ob_tablet_create_delete_helper.cpp @@ -639,7 +639,7 @@ int ObTabletCreateDeleteHelper::do_commit_create_tablet( } else if (OB_UNLIKELY(trans_flags.tx_id_ != tx_data.tx_id_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("tx id does not equal", K(ret), K(key), K(trans_flags), K(tx_data)); - print_memtables_for_table(tablet_handle); + tablet_handle.get_obj()->print_memtables_for_table(); } else if (OB_UNLIKELY(ObTabletStatus::CREATING != tx_data.tablet_status_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("tablet status is not CREATING", K(ret), K(key), K(trans_flags), K(tx_data)); @@ -924,7 +924,7 @@ int ObTabletCreateDeleteHelper::do_abort_create_tablet( } else if (OB_UNLIKELY(trans_flags.tx_id_ != tx_data.tx_id_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("tx id does not equal", K(ret), K(tablet_id), K(trans_flags), K(tx_data)); - print_memtables_for_table(tablet_handle); + tablet_handle.get_obj()->print_memtables_for_table(); } else if (OB_UNLIKELY(ObTabletStatus::CREATING != tx_data.tablet_status_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("tablet status is not CREATING", K(ret), K(tablet_id), K(trans_flags), K(tx_data)); @@ -1161,7 +1161,7 @@ int ObTabletCreateDeleteHelper::do_commit_remove_tablet( } else if (OB_UNLIKELY(trans_flags.tx_id_ != tx_data.tx_id_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("tx id does not equal", K(ret), K(key), K(trans_flags), K(tx_data)); - print_memtables_for_table(tablet_handle); + tablet_handle.get_obj()->print_memtables_for_table(); } else if (OB_UNLIKELY(ObTabletStatus::DELETING != tx_data.tablet_status_)) { ret = OB_ERR_UNEXPECTED; LOG_WARN("tablet status is not DELETING", K(ret), K(key), K(trans_flags), K(tx_data)); @@ -1259,7 +1259,7 @@ int ObTabletCreateDeleteHelper::do_abort_remove_tablet( } else if (OB_UNLIKELY(trans_flags.tx_id_ != tx_data.tx_id_)) { is_valid = false; LOG_INFO("tx id does not equal", K(ret), K(key), K(trans_flags), K(tx_data)); - print_memtables_for_table(tablet_handle); + tablet_handle.get_obj()->print_memtables_for_table(); } else if (OB_UNLIKELY(ObTabletStatus::DELETING != tx_data.tablet_status_)) { is_valid = false; LOG_INFO("tablet status is not DELETING", K(ret), K(key), K(trans_flags), K(tx_data)); @@ -2559,19 +2559,5 @@ int ObTabletCreateDeleteHelper::prepare_data_for_binding_info(const ObTabletID & return ret; } -void ObTabletCreateDeleteHelper::print_memtables_for_table(ObTabletHandle &tablet_handle) -{ - int ret = OB_SUCCESS; - common::ObSArray memtables; - if (!tablet_handle.is_valid()) { - ret = OB_INVALID_ARGUMENT; - LOG_WARN("tablet_handle is not valid", K(ret), K(tablet_handle)); - } else if (OB_FAIL(tablet_handle.get_obj()->get_memtables(memtables, true))) { - LOG_WARN("failed to get_memtables", K(ret), K(tablet_handle)); - } else { - LOG_INFO("memtables print", K(memtables), K(tablet_handle)); - } -} - } // namespace storage } // namespace oceanbase diff --git a/src/storage/tablet/ob_tablet_create_delete_helper.h b/src/storage/tablet/ob_tablet_create_delete_helper.h index ef3c1f7096..944ebc0fae 100644 --- a/src/storage/tablet/ob_tablet_create_delete_helper.h +++ b/src/storage/tablet/ob_tablet_create_delete_helper.h @@ -150,7 +150,6 @@ public: static int prepare_data_for_tablet_status(const ObTabletID &tablet_id, const ObLS &ls, const transaction::ObMulSourceDataNotifyArg &trans_flags); static int prepare_data_for_binding_info(const ObTabletID &tablet_id, const ObLS &ls, const transaction::ObMulSourceDataNotifyArg &trans_flags); - static void print_memtables_for_table(ObTabletHandle &tablet_handle); private: static int verify_tablets_absence( const obrpc::ObBatchCreateTabletArg &arg,