[CP] Add transfer src sstable count overlimit defence.

This commit is contained in:
godyangfight 2024-05-22 11:41:50 +00:00 committed by ob-robot
parent 8e10ce3c36
commit 19466707ca
2 changed files with 12 additions and 1 deletions

View File

@ -517,6 +517,7 @@ int ObTabletBackfillTXTask::get_all_backfill_tx_tables_(
table_array.reset();
ObArray<ObTableHandleV2> minor_sstables;
ObArray<ObTableHandleV2> memtables;
const int64_t emergency_sstable_count = ObTabletTableStore::EMERGENCY_SSTABLE_CNT;
if (!is_inited_) {
ret = OB_NOT_INIT;
@ -535,7 +536,11 @@ int ObTabletBackfillTXTask::get_all_backfill_tx_tables_(
}
} else {
// The backfill of sstable needs to start with a larger start_scn
if (OB_FAIL(ObTableStoreUtil::reverse_sort_minor_table_handles(minor_sstables))) {
if (minor_sstables.count() > emergency_sstable_count) {
ret = OB_TOO_MANY_SSTABLE;
LOG_WARN("transfer src tablet has too many sstable, cannot backfill, need retry", K(ret),
"table_count", minor_sstables.count(), "emergency sstable count", emergency_sstable_count);
} else if (OB_FAIL(ObTableStoreUtil::reverse_sort_minor_table_handles(minor_sstables))) {
LOG_WARN("failed to sort minor tables", K(ret));
} else if (OB_FAIL(append(table_array, minor_sstables))) {
LOG_WARN("failed to append minor sstables", K(ret), KPC(tablet), K(minor_sstables));

View File

@ -2156,6 +2156,8 @@ int ObCheckStartTransferTabletsDelegate::check_transfer_out_tablet_sstable_(cons
int ret = OB_SUCCESS;
ObTableStoreIterator ddl_iter;
ObTabletMemberWrapper<ObTabletTableStore> wrapper;
const int64_t emergency_sstable_count = ObTabletTableStore::EMERGENCY_SSTABLE_CNT;
if (OB_ISNULL(tablet)) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("tablet is null", K(ret));
@ -2163,6 +2165,10 @@ int ObCheckStartTransferTabletsDelegate::check_transfer_out_tablet_sstable_(cons
LOG_WARN("fetch table store fail", K(ret), KP(tablet));
} else if (!wrapper.get_member()->get_major_sstables().empty()) {
// do nothing
} else if (wrapper.get_member()->get_table_count() > emergency_sstable_count) {
ret = OB_TOO_MANY_SSTABLE;
LOG_WARN("transfer src tablet has too many sstable, cannot transfer, need retry", K(ret),
"table_count", wrapper.get_member()->get_table_count(), "emergency sstable count", emergency_sstable_count);
} else if (OB_FAIL(tablet->get_ddl_sstables(ddl_iter))) {
LOG_WARN("failed to get ddl sstable", K(ret));
} else if (ddl_iter.is_valid()) { // indicates the existence of ddl sstable